Hello,i'm sorry since now for my bad english,i need to load my temperature value in a db that are located in a local web server,i've done the php page and it work(i've tried with GET method and it works),but i can't connect with arduino to this page,i've taken a arduino sketch on internet (i've modified a little this sketch because i have another sensor than it but i've tried the library of this sketch in another file and it works)but i think that i make a mistake when i select the ip,i thought ip server is the my pc ip but it seems do not work. i use Easyphp,thank you in advance for your help.
this is the sketch that i've found
#include <DHT.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//indirizzo server web (locale)
IPAddress server(192, 168, 1, 106);
//indirizzo ip dell'Arduino
IPAddress ip(192, 168, 1, 200);
//definizione pin arduino per sensore temp ecc
#define DHTPIN 8
// 8 è il pin di Arduino a cui collego il sensore di temperatura
#define DHTTYPE DHT11
// dht11 è il tipo di sensore che uso
DHT dht(DHTPIN, DHTTYPE);
EthernetClient client;
String strURL = "";
float temp = 0;
void setup()
{
Serial.begin(9600);
if (Ethernet.begin(mac) == 0) {
Serial.println("Configurazione DHCP fallita!");
Ethernet.begin(mac, ip);
}
delay(1000);
}
void loop()
{
UpdateTemp();
while (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("Disconnesso.");
client.stop();
}
//esegui la richiesta ogni 10 secondi
delay(10000);
}
void UpdateTemp()
{
Serial.println("Connessione...");
if (client.connect(server, 80)) {
Serial.println("Connesso");
//acquisisco il valore analogico dal sensore DHT11
temp = dht.readTemperature(); //leggo temperatura da sensore
//creo l'url utilizzanso una stringa
strURL = "GET /arduino/RaccogliementoDati.php?valore="; //devo modificare nome pagina
strURL += (int)temp;
strURL += "&localita=Sardegna HTTP/1.1"; //Inserisco località che più mi piace
//invio la richiesta al server
client.println(strURL);
client.println("Host: localhost");
client.println("Connection: close");
client.println();
//chiudo la connessione
client.stop();
}
else {
Serial.println("Errore Connessione");
}
}