Salve,
Sto lavorando ad una sonda che rileva la temperatura tramite in tmp36 e che scrive il tutto il una pagina web raggiungibile da remoto per poter osservare i cambiamenti di temperatura. Ed ad una soglia , tipo i 30 gradi, manda un messaggio di posta elettronica per avvisare di questo cambiamento, per il momento sono arrivato a leggere la temperatura e ad creare la pagina WEB tramite esempi trovati in giro ma dopo un ora Arduino non risponde più alle chiamate da Browser.
Ecco il codice se può essere di aiuto:
/*
Web Server
A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)
created 18 Dec 2009
by David A. Mellis
modified 4 Sep 2010
by Tom Igoe
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
//byte mac[] = { 0×00, 0×25, 0×22, 0×20, 0xee, 0×99 };
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x23, 0x5D };
byte ip[] = { 192,168,125, 177 };
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
int PIN_TEMP=0; //Assegniamo alla variabile il pin di ingresso analogico scelto
int temp; //Dichiariamo la variabile che conterrà il valore della temperatura
float temperatura;
int i = 0;
int cout=0;
void setup()
{
// start the Ethernet connection and the server:
Serial.begin(9600);
Ethernet.begin(mac, ip);
server.begin();
}
void loop()
{
temperatura_fun();
//delay(60000);
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if you’ve gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<html>");
client.print("<head><meta http-equiv=\”refresh\” content=\”1\”></head>");
client.println("<body>");
client.println("Arduino says:");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(analogRead(analogChannel));
client.println("
");
client.print(" <hr> ");
client.print("temperatura:");
client.print(temperatura);
}
client.println("</body></html>");
break;
}
if (c == '\n') {
// you’re starting a new line
currentLineIsBlank = true;
} else if (c != '\r') {
// you’ve gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
}
}
void temperatura_fun()
{
temp= analogRead(PIN_TEMP); //Assegniamo alla variabile temp il valore restituito dalle lettura del pin 5
temperatura= ((temp * 0.00488)-0.5)/0.01;
if(temperatura > 25)
Serial.println("CALDO!");
Serial.print(i);
Serial.print("-");
Serial.println(temperatura);
i++;
Serial.print("-------------------------------");
//delay(60000); //Aspettiamo 100 mS prima di leggere un nuovo valore
}
Grazie mille dell'aiuto ad un povero novizio