Bonjour,
Je suis entrain de configurer une base de données SQL, hébergée sur un serveur NAS en local.
Pour le moment j’arrive bien à imputer les valeurs dans la base via un fichier PHP.
Seulement je n'arrive à enregistrer qu'une seul ligne de valeurs dans la base (au démarrage de l'Arduino).
Si je veux une deuxième ligne, il me faut un RESET de l'Arduino....
Si quelqu'un a une petite idée......
Il serait fort aimable!!!
merci d'avance
Voici le code arduino:
#include "DHT.h"
#include <SPI.h>
#include <Ethernet.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x9B, 0xC9 };
IPAddress server(192,168,2,100); // My server
EthernetClient client;
void setup() {
Serial.begin(9600);
dht.begin();
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, 1080)) {
Serial.println("connected");
// Make a HTTP request:
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
if (client.connected()) {
float temp = dht.readHumidity();
float hum = dht.readTemperature();
client.print( "GET /add.php?");
client.print("temp=");
Serial.print("temp=");
client.print(temp);
Serial.print(temp);
client.print("&&");
Serial.print("&&");
client.print("hum=");
Serial.print("hum=");
client.print(hum);
Serial.print(hum);
client.println( " HTTP/1.1");
Serial.println( " HTTP/1.1");
client.println( "Host: 192.168.2.100:1080" );
Serial.println( "Host: 192.168.2.100:1080" );
client.println( "Content-Type: application/x-www-form-urlencoded" );
Serial.println( "Content-Type: application/x-www-form-urlencoded" );
client.println( "Connection: close" );
Serial.println( "Connection: close" );
client.println();
client.println();
client.stop();
}
delay( 5000 );
}