Update 'DHT11toMYSQL.ino'

This commit is contained in:
2022-04-05 12:48:22 +02:00
parent 7d765eadca
commit 5c629da05a

View File

@@ -18,24 +18,18 @@ String PATH_NAME = "/search";
WiFiClient client;
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
dht.begin();
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid); // print the network name (SSID);
// Connect to WPA/WPA2 network:
status = WiFi.begin(ssid, pass);
}
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
@@ -43,7 +37,8 @@ void setup() {
}
void loop(){
delay(30000); // 30sec measurement interval
// 30sec measurement interval
delay(30000);
float h = dht.readHumidity();
float t = dht.readTemperature();
@@ -56,13 +51,11 @@ delay(30000); // 30sec measurement interval
} else {
Serial.println("connection failed");
}
// send HTTP request header
client.println("GET "+ PATH_NAME + queryString + " HTTP/1.1");
client.println("Host: google.com");
client.println("Connection: close");
client.println(); // end HTTP request header
//send HTTP body
client.println(queryString);
@@ -72,7 +65,6 @@ client.println(); // end HTTP request header
char c = client.read();
Serial.print(c);
}
if(!client.connected())
{
// if the server's disconnected, stop the client: