diff --git a/_FIRMWARE/firmwares/NodeMCU Sensor/ESP_OS_NODE_STABLE/ESP_OS_NODE_STABLE.ino b/_FIRMWARE/firmwares/NodeMCU Sensor/ESP_OS_NODE_STABLE.ino similarity index 100% rename from _FIRMWARE/firmwares/NodeMCU Sensor/ESP_OS_NODE_STABLE/ESP_OS_NODE_STABLE.ino rename to _FIRMWARE/firmwares/NodeMCU Sensor/ESP_OS_NODE_STABLE.ino diff --git a/_FIRMWARE/firmwares/NodeMCU Sensor/ESP_OS_NODE_V2.ino/ESP_OS_NODE_V2.ino.ino b/_FIRMWARE/firmwares/NodeMCU Sensor/ESP_OS_NODE_V2.ino similarity index 100% rename from _FIRMWARE/firmwares/NodeMCU Sensor/ESP_OS_NODE_V2.ino/ESP_OS_NODE_V2.ino.ino rename to _FIRMWARE/firmwares/NodeMCU Sensor/ESP_OS_NODE_V2.ino diff --git a/_FIRMWARE/firmwares/Sonoff Original/ESP_END_POINT.ino b/_FIRMWARE/firmwares/Sonoff Original/ESP_END_POINT.ino deleted file mode 100644 index 247bd47..0000000 --- a/_FIRMWARE/firmwares/Sonoff Original/ESP_END_POINT.ino +++ /dev/null @@ -1,92 +0,0 @@ -//Includes -#include -#include -#include - -//Variables -const char* ssid = ""; -const char* pasw = ""; -const char* server = "http://ESP:ESP@dev.steelants.cz/projekty/rest_vasek/api/out.php"; -const char* hwId = ""; -int lastState = 0; - -//Constant -#define SONOFF 12 -#define SONOFF_LED 13 -#define SONOFF_BUT 0 - -void setup() { - Serial.begin(9600); - Serial.println("HW: " + String(hwId)); - pinMode(SONOFF, OUTPUT); - pinMode(SONOFF_LED, OUTPUT); - pinMode(SONOFF_BUT, OUTPUT); - pinMode(SONOFF_BUT, INPUT); - // WI-FI CONECTING - WiFi.persistent(false); - WiFi.mode(WIFI_STA); - WiFi.begin(ssid, pasw); -} - -void loop() { - if(WiFi.status() != WL_CONNECTED){ - WiFi.begin(ssid, pasw); - while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect - digitalWrite(SONOFF_LED, LOW); // LOW will turn on the LED - delay(1000); - digitalWrite(SONOFF_LED, HIGH); // HIGH will turn off the LED - delay(1000); - } - Serial.println("\nCONECTED TO WIFI"); - Serial.println("IP: " + String(WiFi.localIP())); - } - - bool buttonState = digitalRead(SONOFF_BUT); - HTTPClient http; - http.begin(server); - http.addHeader("Content-Type", "text/plain"); //Specify content-type header - String requestJson = "{"; - requestJson += "\"tocken\":\"" + String(hwId) + "\""; - - if (buttonState == true) { - requestJson += ","; - requestJson += "\"on/off\":{"; - requestJson += "\"value\":\"" + String(~lastState) + "\","; - requestJson += "\"unit\":\"\""; - requestJson += "}"; - } - - while(buttonState == true) { - delay(50); // keeps a small delay - } - - requestJson += "}"; - Serial.println("JSON: " + requestJson); - - int httpCode = http.POST(requestJson); - String payload = http.getString(); //Get the response payload - - Serial.println("HTTP CODE: " + String(httpCode) + ""); //Print HTTP return code - Serial.println("HTTP BODY: " + String(payload) + ""); //Print request response payload - - DynamicJsonDocument doc(1024); - deserializeJson(doc, payload); - - string hostname = doc["hostname"]; - WiFi.hostname(hostname); - - int state = doc["state"]; - - if (state == 1 && lastState == 0) { - Serial.println("ON"); - digitalWrite(SONOFF, HIGH); // Turn the LED on by making the voltage LOW - digitalWrite(SONOFF_LED, LOW); // Turn the LED on by making the voltage LOW - } else { - Serial.println("OFF"); - digitalWrite(SONOFF, LOW); // Turn the LED on by making the voltage LOW - digitalWrite(SONOFF_LED, HIGH); // Turn the LED on by making the voltage LOW - } - - lastState = state; - delay(1000); -} diff --git a/_FIRMWARE/firmwares/Sonoff_Basic/Sonoff_Basic.ino b/_FIRMWARE/firmwares/Sonoff_Basic/Sonoff_Basic.ino deleted file mode 100644 index 51d7e43..0000000 --- a/_FIRMWARE/firmwares/Sonoff_Basic/Sonoff_Basic.ino +++ /dev/null @@ -1,94 +0,0 @@ -//Includes -#include -#include -#include - -//Variables -const char* ssid = ""; -const char* pasw = ""; -const char* server = "http://ESP:ESP@dev.steelants.cz/projekty/rest_vasek/api/out.php"; -const char* hwId = ""; -int lastState = 0; - -//Constant -#define SONOFF 12 -#define SONOFF_LED 13 -#define SONOFF_BUT 0 - -void setup() { - Serial.begin(9600); - Serial.println("HW: " + String(hwId)); - pinMode(SONOFF, OUTPUT); - pinMode(SONOFF_LED, OUTPUT); - pinMode(SONOFF_BUT, OUTPUT); - pinMode(SONOFF_BUT, INPUT); - // WI-FI CONECTING - WiFi.persistent(false); - WiFi.mode(WIFI_STA); - WiFi.begin(ssid, pasw); -} - -void loop() { - if(WiFi.status() != WL_CONNECTED){ - WiFi.begin(ssid, pasw); - while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect - digitalWrite(SONOFF_LED, LOW); // LOW will turn on the LED - delay(1000); - digitalWrite(SONOFF_LED, HIGH); // HIGH will turn off the LED - delay(1000); - } - Serial.println("\nCONECTED TO WIFI"); - Serial.println("IP: " + String(WiFi.localIP())); - } - - bool buttonState = digitalRead(SONOFF_BUT); - HTTPClient http; - http.begin(server); - http.addHeader("Content-Type", "text/plain"); //Specify content-type header - String requestJson = "{"; - requestJson += "\"tocken\":\"" + String(hwId) + "\""; - - if (buttonState == true) { - requestJson += ","; - requestJson += "\"on/off\":{"; - requestJson += "\"value\":\"" + String(~lastState) + "\","; - requestJson += "\"unit\":\"\""; - requestJson += "}"; - } - - while(buttonState == true) { - delay(50); // keeps a small delay - } - - requestJson += "}"; - Serial.println("JSON: " + requestJson); - - int httpCode = http.POST(requestJson); - String payload = http.getString(); //Get the response payload - - Serial.println("HTTP CODE: " + String(httpCode) + ""); //Print HTTP return code - Serial.println("HTTP BODY: " + String(payload) + ""); //Print request response payload - - DynamicJsonDocument doc(1024); - deserializeJson(doc, payload); - - string hostname = doc["device"]["hostname"]; - sleepTime = doc["device"]["sleepTime"]; - - WiFi.hostname(hostname); - - int state = doc["state"]; - - if (state == 1 && lastState == 0) { - Serial.println("ON"); - digitalWrite(SONOFF, HIGH); // Turn the LED on by making the voltage LOW - digitalWrite(SONOFF_LED, LOW); // Turn the LED on by making the voltage LOW - } else { - Serial.println("OFF"); - digitalWrite(SONOFF, LOW); // Turn the LED on by making the voltage LOW - digitalWrite(SONOFF_LED, HIGH); // Turn the LED on by making the voltage LOW - } - - lastState = state; - delay(1000); -} \ No newline at end of file diff --git a/_FIRMWARE/firmwares/Sonoff_S20/Sonoff_S20.ino b/_FIRMWARE/firmwares/Sonoff_S20/Sonoff_S20.ino deleted file mode 100644 index d11e6b1..0000000 --- a/_FIRMWARE/firmwares/Sonoff_S20/Sonoff_S20.ino +++ /dev/null @@ -1,94 +0,0 @@ -//Includes -#include -#include -#include - -//Variables -const char* ssid = " "; -const char* pasw = ""; -const char* server = "http://dev.steelants.cz/vasek/home/api.php"; -const char* hwId = ""; -int lastState = 0; -int reconectAtemptsMax = 10; //time to wait before restart - -//Constant -#define SONOFF 12 -#define SONOFF_LED 13 -#define SONOFF_BUT 0 - - -void setup() { - Serial.begin(9600); - delay(10); - Serial.println('\n'); - Serial.println("HW: " + String(hwId)); - - pinMode(SONOFF, OUTPUT); - pinMode(SONOFF_LED, OUTPUT); - pinMode(SONOFF_BUT, INPUT); - - WiFi.persistent(false); - WiFi.mode(WIFI_STA); - - WiFi.begin(ssid, pasw); - Serial.print("Connecting to "); - Serial.print(ssid); Serial.println(" ..."); - - int i = 0; - while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect - delay(1000); - Serial.print(++i); Serial.print(' '); - } - - Serial.println('\n'); - Serial.println("Connection established!"); - Serial.print("IP address:\t"); - Serial.println(WiFi.localIP()); -} - -void loop() { - StaticJsonDocument<200> jsonContent; - jsonContent["token"] = hwId; - - if (!digitalRead(SONOFF_BUT)){ - jsonContent["values"]["on/off"]["value"] = (int) !lastState; - if (!lastState == 1) { - digitalWrite(SONOFF, HIGH) - } else if (!lastState == 0){ - digitalWrite(SONOFF, LOW) - } - while(!digitalRead(SONOFF_BUT)) { - delay(100); - } - } - - String requestJson = ""; - serializeJson(jsonContent, requestJson); - Serial.println("JSON: " + requestJson); - - HTTPClient http; - http.begin(server); - http.addHeader("Content-Type", "text/plain"); //Specify content-type header - int httpCode = http.POST(requestJson); - String payload = http.getString(); //Get the response payload - http.end(); - - Serial.println("HTTP CODE: " + String(httpCode) + ""); //Print HTTP return code - Serial.println("HTTP BODY: " + String(payload) + ""); //Print request response payload - - deserializeJson(jsonContent, payload); - String hostname = jsonContent["device"]["hostname"]; - int state = jsonContent["value"]; - WiFi.hostname(hostname); - - if (state != lastState){ - if (state == 1 && lastState == 0) { - Serial.println("ON"); - digitalWrite(SONOFF, HIGH); // Turn the LED on by making the voltage LOW - } else { - Serial.println("OFF"); - digitalWrite(SONOFF, LOW); // Turn the LED on by making the voltage LOW - } - } - lastState = state; -}