Arduino: Controllo (con simulazione di attivazione del climatizzatore) della temperatura da remoto – Resoconto attività 23 luglio 2014

Scritto da Alessandra De Rosa on . Postato in Formazione, Prodotti, Progetto Leonardo da Vinci, Servizi

Today we started a new project, which consisted on having a text box on the browser, where we could write a value for the temperature we wanted, this way the arduino would receive it and that value would appear below the text box.

Later we modified that project, adding new features like leds that would turn on depending on the value of the temperature we had written. If the led turned on was the red, it meant that the value was lower than the actual temperature. If it was the blue one, it meant that the value was higher than the actual one. Otherwise, if it was the green one, meant that both temperatures were the same.

Finally we made a tutorial and a video for the last project.

 

23 of July 2014

Alexandre Leitao

Gonçalo Neto

Arduino: Accendere e spegnere un led dal browser – Resoconto attività 22 luglio 2014

Scritto da Alessandra De Rosa on . Postato in Formazione, Prodotti, Progetto Leonardo da Vinci, Servizi

Today we started the day by making the project and its tutorial for the test we were doing, which consisted on controlling a led from the browser (ON/OFF).

Later we focused on the new project, which is based on the last and consists on controlling the led (ON/OFF) with different links. In addiction, it’s possible to check the temperature too.

Finally, we made a video for the current project and its tutorial.

22 July 2014

Alexandre Leitao

Gonçalo Neto

Tutorial Arduino: How to turn on and off a led from a web page while showing the temperature of the room

Scritto da Alessandra De Rosa on . Postato in Formazione, Prodotti, Progetto Leonardo da Vinci, Servizi, Tutorials Arduino

 

This project consists on turning ON and OFF a led from a web page and get the temperature of the room the circuit is in.

We used :

  • 1 Arduino
  • 1 Breadboard
  • 1 Ethernet shield
  • 1 Lm35
  • 1 Led
  • 1 Resistance
  • 1 Rj45

The first part of this tutorial is equal to our last one. Where you have to build a system to turn on and off a led.

This project is based on that one, but with a new interface and a new feature.

The new interface is made by this code:

 client.println("HTTP/1.1 200 OK.....");
        client.println("Content-Type: text/html");
        client.println();
       client.print("<html> <style> table ,th, dt{ border:1px solid black; border-collapse:collapse;}"); // creates the table and costumizes the border for the temperature
       client.println("th, dt {padding:5px;}</style>"); // also border costumization
       client.print("<p><a href='/?L=1'>ACCENDI</a> | <a href='/?L=0'>SPEGNI</a></p>");
       client.println("<table><tr><th>Led status:</th>");
       client.print("<th>");
          if (LEDON) {
              client.println("<span style='color:green; font-weight:bold;'>ON</span></font>");
            }
            else
            {
              client.println("<span style='color:grey; font-weight:bold;'>OFF</span></font>");
          }
      client.print("</th>");
      client.print("<tr><th>Reference Temperature</th>"); client.print("<th></th>");
      client.println("<tr><th>Temperature of the room</th>");
      client.print("<th>");     client.print(x2);   client.println("</th>"); 
        client.println("</body></html>");


Here we just built a different way of showing the on off switch and the status of the led and the temperature.

The sketch for this is :

arduino led temperature sketch

The pictures for this are :

When it’s ON:

arduino led temperature on

When it’s OFF:

arduino led temperature off

 

22 July 2014

Alexandre Leitao

Gonçalo Neto

Tutorial Arduino: How to turn on a Led from a browser – Come accendere un Led da un browser

Scritto da Alessandra De Rosa on . Postato in Formazione, Prodotti, Progetto Leonardo da Vinci, Servizi, Tutorials Arduino

For this tutorial, we’re testing the connection between the arduino and  the internet.

Components used:

  • 1 Arduino
  • 1 Ethernet Shield
  • 1 Led
  • 1 Resistance
  • 1 Cable RJ45

The web page is simple, it has a title and 2 links, one to turn on the led and another to turn it off.

Here is how it looks when the led is on:

arduino led control on

When the led if off:

arduino led control off

The sketch:

arduino led control sketch

 

Here is the code we used:

#include <String.h>
#include <SPI.h>
#include <Ethernet.h>
 
 
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // mac address
byte ip[] = { 192, 168, 1, 25 }; // ip arduino internet in
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
 
int outPin = 9; // pin 
String readString; //string
boolean LEDON = false; // flag status 
 

void setup(){
Ethernet.begin(mac, ip, subnet);
pinMode(outPin, OUTPUT);

Serial.begin(9600);
}
 
void loop()
{

/*Client*/

EthernetClient client = server.available();
if (client) {
  boolean currentLineIsBlank = true;
  while (client.connected()) {
    if (client.available()) {
      char c = client.read();
        readString.concat(c); //storages each character of the packet

      //if HTTP request has ended
      if (c == '\n' && currentLineIsBlank) {
         Serial.print(readString);
         
        if(readString.indexOf("L=1") > 0) {// Reads the information for the led to turn on
          digitalWrite(outPin, HIGH); // turns on the led
          LEDON = true;
          Serial.print("ON pin ");
          Serial.println(outPin);
          }
          else
          {
            if(readString.indexOf("L=0") > 0){
          digitalWrite(outPin, LOW); // turn off the led
          LEDON = false;
          Serial.print("OFF pin ");
          Serial.println(outPin);
        }
          }

        // Web page:
        client.println("HTTP/1.1 200 OK.....");
        client.println("Content-Type: text/html");
        client.println();
        client.print("<html><head><title>ARDUINO Led Control</title><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' ></head><body>");
        client.println("<h1>Led Control</h1>");
        client.println("<hr />");
        client.print("<h1>PIN control n. ");
        client.print(outPin);
        client.println("</h1>");
        client.println("<br />");
        //Led status
        client.print("<font size='5'>PIN status: ");
          if (LEDON) {
              client.println("<span style='color:green; font-weight:bold;'>ON</span></font>");
            }
            else
            {
              client.println("<span style='color:grey; font-weight:bold;'>OFF</span></font>");
          }
        client.print("<h2><a href='/?L=1'>ACCENDI</a> | <a href='/?L=0'>SPEGNI</a></h2>");
        client.println("<hr />");
        client.println("<hr />");
        client.println("</div>");
        client.println("</body></html>");
         readString="";
        client.stop();
         
        } 
    }
  }
} 
}


We simply receive the packet through the Ethernet and search for the keyword: L=1 || L=0.
The ‘1’ means ON and ‘0’ OFF.

Then it’s just a matter of controlling the led via arduino and close or maintain the connection with the client.

22 July 2014

Alexandre Leitao

Gonçalo Neto

Arduino: Interagire con PHP – Resoconto attività 21 Luglio 2014

Scritto da Alessandra De Rosa on . Postato in Formazione, Prodotti, Progetto Leonardo da Vinci, Servizi

Today we spent some time searching for the interaction of the php with arduino to use them for a test which consists on switching a led ON and OFF by pressing the button on the browser.

We’ve been learning php and used a program called xampp to simulate a local server.

We had some problems with functioning of the sketch,  we could not understand  why the serial connection between php and COM3 of arduino was not working properly.

 

 

21 July 2014

Alexandre Leitao

Gonçalo Neto

Google+