Firmware impruevement #2

This commit is contained in:
JonatanRek
2019-11-27 17:27:18 +01:00
parent 79864c23fd
commit 1e7f16d3b9
2 changed files with 21 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
//Includes
#include <DHT.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
@@ -73,6 +74,7 @@ void loop() {
//configuration setup
String hostName = doc["device"]["hostname"];
int sleepTime = doc["device"]["sleepTime"];
String ipAddress = doc["device"]["ipAddress"];
String state = doc["state"];
if (state != "succes") {
@@ -82,6 +84,14 @@ void loop() {
unsuccessfulRounds = 0;
}
//Set static ip
IPAddress addr;
if (addr.fromString(ipAddress)) {
IPAddress ip(addr);
Serial.print("IP address:\t");
Serial.println(WiFi.localIP());
}
WiFi.hostname(hostName);
http.end(); //Close connection