|
|
|
|
@ -1,7 +1,5 @@
|
|
|
|
|
//Bibliotheken der API Anbindung
|
|
|
|
|
#include <ESP8266WiFi.h>
|
|
|
|
|
#include <ESP8266HTTPClient.h>
|
|
|
|
|
#include <WiFiClient.h>
|
|
|
|
|
#include <ArduinoJson.h>
|
|
|
|
|
|
|
|
|
|
//Bibliotheken für die Temperatursensoren
|
|
|
|
|
@ -22,6 +20,7 @@ const char* password = "AndyNicoChiara";
|
|
|
|
|
|
|
|
|
|
const char* serverName = "http://192.168.178.170:3564/sensordata";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Moisture sensor variables
|
|
|
|
|
int sense_Pin = 0; // sensor input at Analog pin A0
|
|
|
|
|
int value = 0;
|
|
|
|
|
@ -32,6 +31,9 @@ int pos = 0;
|
|
|
|
|
//Konstante für die ZEit
|
|
|
|
|
const int timer = 30;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
|
Serial.begin(9600);
|
|
|
|
|
dht.begin();
|
|
|
|
|
@ -96,29 +98,16 @@ void loop() {
|
|
|
|
|
|
|
|
|
|
WiFiClient client;
|
|
|
|
|
HTTPClient http;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Your Domain name with URL path or IP address with path
|
|
|
|
|
http.begin(client, serverName);
|
|
|
|
|
// If you need an HTTP request with a content type: application/json, use the following:
|
|
|
|
|
//http.addHeader("Content-Type", "application/json");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
http.addHeader("Content-Type", "application/json");
|
|
|
|
|
int httpResponseCode = http.POST(requestBody);
|
|
|
|
|
|
|
|
|
|
// If you need an HTTP request with a content type: text/plain
|
|
|
|
|
//http.addHeader("Content-Type", "text/plain");
|
|
|
|
|
//int httpResponseCode = http.POST("Hello, World!");
|
|
|
|
|
|
|
|
|
|
Serial.print("HTTP Response code: ");
|
|
|
|
|
Serial.println(httpResponseCode);
|
|
|
|
|
http.end();
|
|
|
|
|
|
|
|
|
|
// Read response
|
|
|
|
|
Serial.print(http.getString());
|
|
|
|
|
Serial.println("closing connection");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Free resources
|
|
|
|
|
http.end();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Serial.println("WiFi Disconnected");
|
|
|
|
|
}
|
|
|
|
|
|