From adbb6e4e3b0c5a82a3e35b5bd28770f8dad61e04 Mon Sep 17 00:00:00 2001 From: "jp.av.dev" Date: Mon, 12 Jul 2021 20:13:43 -0400 Subject: [PATCH 1/8] dev ESP01 --- .gitignore | 1 + caldera_esp/caldera_esp.ino | 71 +++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .gitignore create mode 100755 caldera_esp/caldera_esp.ino diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ef240af --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +caldera_esp/confidencial.h diff --git a/caldera_esp/caldera_esp.ino b/caldera_esp/caldera_esp.ino new file mode 100755 index 0000000..377e48d --- /dev/null +++ b/caldera_esp/caldera_esp.ino @@ -0,0 +1,71 @@ +#include +#include +#include +#include + +ESP8266WebServer server(80); + +const int led = 13; + +void handleRoot() { + digitalWrite(led, 1); + server.send(200, "text/plain", "Hola desde el esp01 (2)!"); + digitalWrite(led, 0); +} + +void handleNotFound() { + digitalWrite(led, 1); + String message = "Archivo no encontrado\n\n"; + message += "URI: "; + message += server.uri(); + message += "\nMethod: "; + message += (server.method() == HTTP_GET) ? "GET" : "POST"; + message += "\nArguments: "; + message += server.args(); + message += "\n"; + for (uint8_t i = 0; i < server.args(); i++) { + message += " " + server.argName(i) + ": " + server.arg(i) + "\n"; + } + server.send(404, "text/plain", message); + digitalWrite(led, 0); +} + +void setup(void) { + pinMode(led, OUTPUT); + digitalWrite(led, 0); + Serial.begin(115200); + WiFi.mode(WIFI_STA); + WiFi.begin(ssid, password); + Serial.println(""); + + // Wait for connection + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } + Serial.println(""); + Serial.print("Connected to "); + Serial.println(ssid); + Serial.print("IP address: "); + Serial.println(WiFi.localIP()); + + if (MDNS.begin("esp8266")) { + Serial.println("MDNS responder started"); + } + + server.on("/", handleRoot); + + server.on("/inline", []() { + server.send(200, "text/plain", "esto funciona como debe"); + }); + + server.onNotFound(handleNotFound); + + server.begin(); + Serial.println("HTTP server started"); +} + +void loop(void) { + server.handleClient(); +} + From e882f48c5b4f8e2b3cf1619e9f341541fad54fef Mon Sep 17 00:00:00 2001 From: "jp.av.dev" Date: Mon, 12 Jul 2021 20:26:21 -0400 Subject: [PATCH 2/8] test config vars --- caldera_esp/caldera_esp.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caldera_esp/caldera_esp.ino b/caldera_esp/caldera_esp.ino index 377e48d..188511b 100755 --- a/caldera_esp/caldera_esp.ino +++ b/caldera_esp/caldera_esp.ino @@ -1,7 +1,7 @@ #include #include #include -#include +#include "ESP8266mDNS.h" ESP8266WebServer server(80); From e8067ec92cf9e8834c293dda7ceb246287576519 Mon Sep 17 00:00:00 2001 From: "jp.av.dev" Date: Mon, 12 Jul 2021 21:58:57 -0400 Subject: [PATCH 3/8] test esp web server-wifi client-(lib ESP8266WiFi), 'contenido dinamico' --- README.md | 6 ++++++ caldera_esp/caldera_esp.ino | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e69de29..f9df368 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,6 @@ + +Archivo de configuracion ***confidencial.h*** +```c +const char* ssid = "SSID"; +const char* password = "password"; +``` diff --git a/caldera_esp/caldera_esp.ino b/caldera_esp/caldera_esp.ino index 188511b..4656091 100755 --- a/caldera_esp/caldera_esp.ino +++ b/caldera_esp/caldera_esp.ino @@ -1,7 +1,10 @@ #include #include #include -#include "ESP8266mDNS.h" +#include +#include "confidencial.h" + +int loopcont; ESP8266WebServer server(80); @@ -9,7 +12,7 @@ const int led = 13; void handleRoot() { digitalWrite(led, 1); - server.send(200, "text/plain", "Hola desde el esp01 (2)!"); + server.send(200, "text/plain", "Hola desde el esp01! "+(String)loopcont); digitalWrite(led, 0); } @@ -36,6 +39,7 @@ void setup(void) { Serial.begin(115200); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); + loopcont = 0; Serial.println(""); // Wait for connection @@ -67,5 +71,6 @@ void setup(void) { void loop(void) { server.handleClient(); + loopcont+=1; } From fd36dc60624e1083759b303f62c74cbc235bda84 Mon Sep 17 00:00:00 2001 From: "jp.av.dev" Date: Tue, 13 Jul 2021 03:20:25 -0400 Subject: [PATCH 4/8] inteaccion Nano y ESP, MEJORAR lectura Serie --- caldera_esp/caldera_esp.ino | 131 +++++++++++++++++++++------------- caldera_rata/caldera_rata.ino | 6 +- 2 files changed, 85 insertions(+), 52 deletions(-) diff --git a/caldera_esp/caldera_esp.ino b/caldera_esp/caldera_esp.ino index 4656091..41df266 100755 --- a/caldera_esp/caldera_esp.ino +++ b/caldera_esp/caldera_esp.ino @@ -3,74 +3,107 @@ #include #include #include "confidencial.h" - -int loopcont; +String modo, estado, horaOn1, horaOff1, horaOn2, horaOff2, posOn1, posOn2, posOff1, posOff2, hora, minuto, segundo, dia, mes, ano; ESP8266WebServer server(80); - const int led = 13; void handleRoot() { - digitalWrite(led, 1); - server.send(200, "text/plain", "Hola desde el esp01! "+(String)loopcont); - digitalWrite(led, 0); + String mensaje, msj_arduino, valores_ino; + valores_ino = "Modo: "+modo+"\nEstado: "+estado+"\nHora encendido: "+horaOn1+"\nHora apagado: "+horaOff1+ + "\nHora encendido2: "+horaOn2+"\nHora apagado2: "+horaOff2+"\nPosiciones Servo ON1 y ON2: "+posOn1+", "+posOn2+ + "\nPosiciones Servo OFF1 y OFF2: "+posOff1+", "+posOff2+"\nHora y fecha: "+hora+":"+minuto+":"+segundo+" "+dia+ + "/"+mes+"/"+ano; + for (uint8_t i = 0; i < server.args(); i++) { + mensaje += " " + server.argName(i) + ": " + server.arg(i) + "\n"; + msj_arduino+=server.arg(i)+","; + } + server.send(200, "text/plain", "Argumentos: "+mensaje+"\nValores Arduino :\n"+valores_ino); + Serial.println(msj_arduino); + limpiaSerial(); } void handleNotFound() { - digitalWrite(led, 1); - String message = "Archivo no encontrado\n\n"; - message += "URI: "; - message += server.uri(); - message += "\nMethod: "; - message += (server.method() == HTTP_GET) ? "GET" : "POST"; - message += "\nArguments: "; - message += server.args(); - message += "\n"; - for (uint8_t i = 0; i < server.args(); i++) { - message += " " + server.argName(i) + ": " + server.arg(i) + "\n"; - } - server.send(404, "text/plain", message); - digitalWrite(led, 0); + String message = "Archivo no encontrado\n\n"; + message += "URI: "; + message += server.uri(); + message += "\nMethod: "; + message += (server.method() == HTTP_GET) ? "GET" : "POST"; + message += "\nArguments: "; + message += server.args(); + message += "\n"; + for (uint8_t i = 0; i < server.args(); i++) { + message += " " + server.argName(i) + ": " + server.arg(i) + "\n"; + } + server.send(404, "text/plain", message); } void setup(void) { - pinMode(led, OUTPUT); - digitalWrite(led, 0); - Serial.begin(115200); - WiFi.mode(WIFI_STA); - WiFi.begin(ssid, password); - loopcont = 0; - Serial.println(""); + pinMode(led, OUTPUT); + digitalWrite(led, 0); + Serial.begin(115200); + WiFi.mode(WIFI_STA); + WiFi.begin(ssid, password); + Serial.println(""); - // Wait for connection - while (WiFi.status() != WL_CONNECTED) { - delay(500); - Serial.print("."); - } - Serial.println(""); - Serial.print("Connected to "); - Serial.println(ssid); - Serial.print("IP address: "); - Serial.println(WiFi.localIP()); + // Wait for connection + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } + Serial.println(""); + Serial.print("Connected to "); + Serial.println(ssid); + Serial.print("IP address: "); + Serial.println(WiFi.localIP()); - if (MDNS.begin("esp8266")) { - Serial.println("MDNS responder started"); - } + if (MDNS.begin("esp8266")) { + Serial.println("MDNS responder started"); + } - server.on("/", handleRoot); + server.on("/", handleRoot); - server.on("/inline", []() { - server.send(200, "text/plain", "esto funciona como debe"); - }); + server.on("/inline", []() { + server.send(200, "text/plain", "esto funciona como debe"); + }); - server.onNotFound(handleNotFound); + server.onNotFound(handleNotFound); - server.begin(); - Serial.println("HTTP server started"); + server.begin(); + Serial.println("HTTP server started"); +} + +void limpiaSerial() { + while(Serial.available() > 0) { + char temp = Serial.read(); + } } void loop(void) { - server.handleClient(); - loopcont+=1; + if (Serial.available() > 0) { + modo = Serial.readStringUntil(','); + estado = Serial.readStringUntil(','); + if(estado == "1") { + estado = "Encendido"; + } else if(estado == "0") { + estado = "Apagado"; + } + horaOn1 = Serial.readStringUntil(','); + horaOff1 = Serial.readStringUntil(','); + horaOn2 = Serial.readStringUntil(','); + horaOff2 = Serial.readStringUntil(','); + posOn1 = Serial.readStringUntil(','); + posOn2 = Serial.readStringUntil(','); + posOff1 = Serial.readStringUntil(','); + posOff2 = Serial.readStringUntil(','); + hora = Serial.readStringUntil(','); + minuto = Serial.readStringUntil(','); + segundo = Serial.readStringUntil(','); + dia = Serial.readStringUntil(','); + mes = Serial.readStringUntil(','); + ano = Serial.readStringUntil(','); + } + limpiaSerial(); + server.handleClient(); } diff --git a/caldera_rata/caldera_rata.ino b/caldera_rata/caldera_rata.ino index 7aeeb84..8c48ba5 100644 --- a/caldera_rata/caldera_rata.ino +++ b/caldera_rata/caldera_rata.ino @@ -15,7 +15,7 @@ Servo myservo_X; RTC_DS3231 reloj; volatile DateTime fecha; -unsigned long intervalo_loop=500; +unsigned long intervalo_loop=1000; unsigned long previoMillisLoop=0; unsigned long previoMillisTermo=0; unsigned long previoMillisAUTO=0; @@ -40,7 +40,7 @@ byte hr, mn, sg, di, me; int an; void setup() { - Serial.begin(9600); + Serial.begin(115200); myservo_X.attach(9); reloj.begin(); estado=1; @@ -62,7 +62,7 @@ void loop() { switch(estado) { case 1: // funcionamiento autonomo, por defecto - if ((unsigned long)(actualMillis - previoMillisAUTO) >= 2000) { + if ((unsigned long)(actualMillis - previoMillisAUTO) >= 1000) { if((((fecha.hour() >= horaON1) && (fecha.hour() < horaOFF1)) || ((fecha.hour() >= horaON2) && (fecha.hour() < horaOFF2))) && (estado_termo==0)) { termoACC(posON1, posON2); From c7051a1da97f79688de76be012506f0664e77843 Mon Sep 17 00:00:00 2001 From: "jp.av.dev" Date: Tue, 13 Jul 2021 22:50:58 -0400 Subject: [PATCH 5/8] urls ESP, baudio,.. --- caldera_esp/caldera_esp.ino | 144 +++++++++++++++++++++++++--------- caldera_rata/caldera_rata.ino | 87 ++++++++++---------- 2 files changed, 152 insertions(+), 79 deletions(-) diff --git a/caldera_esp/caldera_esp.ino b/caldera_esp/caldera_esp.ino index 41df266..9f7fbd1 100755 --- a/caldera_esp/caldera_esp.ino +++ b/caldera_esp/caldera_esp.ino @@ -3,24 +3,104 @@ #include #include #include "confidencial.h" + String modo, estado, horaOn1, horaOff1, horaOn2, horaOff2, posOn1, posOn2, posOff1, posOff2, hora, minuto, segundo, dia, mes, ano; +String temporal; ESP8266WebServer server(80); -const int led = 13; void handleRoot() { - String mensaje, msj_arduino, valores_ino; - valores_ino = "Modo: "+modo+"\nEstado: "+estado+"\nHora encendido: "+horaOn1+"\nHora apagado: "+horaOff1+ - "\nHora encendido2: "+horaOn2+"\nHora apagado2: "+horaOff2+"\nPosiciones Servo ON1 y ON2: "+posOn1+", "+posOn2+ - "\nPosiciones Servo OFF1 y OFF2: "+posOff1+", "+posOff2+"\nHora y fecha: "+hora+":"+minuto+":"+segundo+" "+dia+ - "/"+mes+"/"+ano; - for (uint8_t i = 0; i < server.args(); i++) { - mensaje += " " + server.argName(i) + ": " + server.arg(i) + "\n"; - msj_arduino+=server.arg(i)+","; + server.send(200, "text/plain", temporal); +} + +void handleACCmanual() { + String mensaje; + if(server.arg(0) == "5") { + if(server.arg(1) == "on") { + mensaje = "Encendiendo Caldera"; + Serial.println("5,1"); + } else if(server.arg(1) == "off") { + mensaje = "Apagando Caldera"; + Serial.println("5,0"); + } else { + mensaje = "Opcion no valida, 5,?"; + } + } else { + mensaje = "Opcion no valida ?,?"; } - server.send(200, "text/plain", "Argumentos: "+mensaje+"\nValores Arduino :\n"+valores_ino); - Serial.println(msj_arduino); - limpiaSerial(); + server.send(200, "text/plain", mensaje); +} + +void handleSEThora() { + // dia mes año hora min seg + String mensaje_web, msj_a_arduino; + if(server.arg(0) == "2") { + msj_a_arduino = "2,"; + msj_a_arduino += server.arg(1)+","; + msj_a_arduino += server.arg(2)+","; + msj_a_arduino += server.arg(3)+","; + msj_a_arduino += server.arg(4)+","; + msj_a_arduino += server.arg(5)+","; + msj_a_arduino += server.arg(6); + mensaje_web = "Fecha y hora enviadas a arduino"; + Serial.println(msj_a_arduino); + } else { + mensaje_web = "Opcion no valida\n"; + } + server.send(200, "text/plain", mensaje_web); +} + +void handleHorasAcc() { + String mensaje_web, msj_a_arduino; + if(server.arg(0) == "3") { + msj_a_arduino = "3,"; + msj_a_arduino += server.arg(1)+","; + msj_a_arduino += server.arg(2)+","; + msj_a_arduino += server.arg(3)+","; + msj_a_arduino += server.arg(4); + mensaje_web = "Horas de funcionamiento enviadas a arduino"; + Serial.println(msj_a_arduino); + } else { + mensaje_web = "Opcion no valida\n"; + } + server.send(200, "text/plain", mensaje_web); +} + +void handleSETservo() { + String mensaje_web, msj_a_arduino; + if(server.arg(0) == "4") { + msj_a_arduino = "4,"; + msj_a_arduino += server.arg(1)+","; + msj_a_arduino += server.arg(2)+","; + msj_a_arduino += server.arg(3)+","; + msj_a_arduino += server.arg(4); + mensaje_web = "Posiciones del servo enviadas a arduino"; + Serial.println(msj_a_arduino); + } else { + mensaje_web = "Opcion no valida\n"; + } + server.send(200, "text/plain", mensaje_web); +} + +void handleSETlibre() { + String mensaje_web, msj_a_arduino; + if(server.arg(0) == "6") { + msj_a_arduino = "6,"; + msj_a_arduino += server.arg(1); + mensaje_web = "Posicion del servo enviada a arduino"; + Serial.println(msj_a_arduino); + } else { + mensaje_web = "Opcion no valida\n"; + } + server.send(200, "text/plain", mensaje_web); +} + +void handleSETauto() { + String mensaje_web, msj_a_arduino; + msj_a_arduino = "1"; + mensaje_web = "Enviando modo 1 (Autonomo) a arduino"; + Serial.println(msj_a_arduino); + server.send(200, "text/plain", mensaje_web); } void handleNotFound() { @@ -39,8 +119,6 @@ void handleNotFound() { } void setup(void) { - pinMode(led, OUTPUT); - digitalWrite(led, 0); Serial.begin(115200); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); @@ -62,6 +140,13 @@ void setup(void) { } server.on("/", handleRoot); + + server.on("/accion", handleACCmanual); + server.on("/sethora", handleSEThora); + server.on("/horasAcc", handleHorasAcc); + server.on("/setservo", handleSETservo); + server.on("/setlibre", handleSETlibre); + server.on("/auto", handleSETauto); server.on("/inline", []() { server.send(200, "text/plain", "esto funciona como debe"); @@ -79,31 +164,14 @@ void limpiaSerial() { } } +void leerSerial() { + while(Serial.available()){ + temporal = Serial.readStringUntil('\r'); + } +} + void loop(void) { - if (Serial.available() > 0) { - modo = Serial.readStringUntil(','); - estado = Serial.readStringUntil(','); - if(estado == "1") { - estado = "Encendido"; - } else if(estado == "0") { - estado = "Apagado"; - } - horaOn1 = Serial.readStringUntil(','); - horaOff1 = Serial.readStringUntil(','); - horaOn2 = Serial.readStringUntil(','); - horaOff2 = Serial.readStringUntil(','); - posOn1 = Serial.readStringUntil(','); - posOn2 = Serial.readStringUntil(','); - posOff1 = Serial.readStringUntil(','); - posOff2 = Serial.readStringUntil(','); - hora = Serial.readStringUntil(','); - minuto = Serial.readStringUntil(','); - segundo = Serial.readStringUntil(','); - dia = Serial.readStringUntil(','); - mes = Serial.readStringUntil(','); - ano = Serial.readStringUntil(','); - } - limpiaSerial(); + leerSerial(); server.handleClient(); } diff --git a/caldera_rata/caldera_rata.ino b/caldera_rata/caldera_rata.ino index 8c48ba5..7376930 100644 --- a/caldera_rata/caldera_rata.ino +++ b/caldera_rata/caldera_rata.ino @@ -66,9 +66,11 @@ void loop() { if((((fecha.hour() >= horaON1) && (fecha.hour() < horaOFF1)) || ((fecha.hour() >= horaON2) && (fecha.hour() < horaOFF2))) && (estado_termo==0)) { termoACC(posON1, posON2); + estado_termo=1; } else if((((fecha.hour() < horaON1) || (fecha.hour() >= horaOFF1)) && ((fecha.hour() < horaON2) || (fecha.hour() >= horaOFF2))) && (estado_termo==1)) { termoACC(posOFF1, posOFF2); + estado_termo=0; } } previoMillisAUTO = millis(); @@ -95,8 +97,10 @@ void loop() { if(espera_man) { if(manual == 1) { termoACC(posON1, posON2); + estado_termo=1; } else if (manual == 0){ termoACC(posOFF1, posOFF2); + estado_termo=0; } espera_man=0; } @@ -118,48 +122,50 @@ void loop() { void leerDatos() { if (Serial.available() > 0) { - byte temp_var=0; + byte temp_var; temp_var = Serial.readStringUntil(',').toInt(); - if(temp_var < 7 && temp_var > 0){ - estado = temp_var; - } else { - estado = 1; + if(temp_var) { + if(temp_var < 7 && temp_var > 0){ + estado = temp_var; + } else { + estado = 1; + } + switch (estado) { + case 1: + limpiaSerial(); + break; + case 2: + di = Serial.readStringUntil(',').toInt(); + me = Serial.readStringUntil(',').toInt(); + an = Serial.readStringUntil(',').toInt(); + hr = Serial.readStringUntil(',').toInt(); + mn = Serial.readStringUntil(',').toInt(); + sg = Serial.readStringUntil(',').toInt(); + break; + case 3: + horaON1 = Serial.readStringUntil(',').toInt(); + horaOFF1 = Serial.readStringUntil(',').toInt(); + horaON2 = Serial.readStringUntil(',').toInt(); + horaOFF2 = Serial.readStringUntil(',').toInt(); + break; + case 4: + posON1 = Serial.readStringUntil(',').toInt(); + posON2 = Serial.readStringUntil(',').toInt(); + posOFF1 = Serial.readStringUntil(',').toInt(); + posOFF2 = Serial.readStringUntil(',').toInt(); + break; + case 5: + manual = Serial.readStringUntil(',').toInt(); + espera_man = 1; + break; + case 6: + posTEMP = Serial.readStringUntil(',').toInt(); + break; + default: + limpiaSerial(); + } + limpiaSerial(); } - switch (estado) { - case 1: - limpiaSerial(); - break; - case 2: - di = Serial.readStringUntil(',').toInt(); - me = Serial.readStringUntil(',').toInt(); - an = Serial.readStringUntil(',').toInt(); - hr = Serial.readStringUntil(',').toInt(); - mn = Serial.readStringUntil(',').toInt(); - sg = Serial.readStringUntil(',').toInt(); - break; - case 3: - horaON1 = Serial.readStringUntil(',').toInt(); - horaOFF1 = Serial.readStringUntil(',').toInt(); - horaON2 = Serial.readStringUntil(',').toInt(); - horaOFF2 = Serial.readStringUntil(',').toInt(); - break; - case 4: - posON1 = Serial.readStringUntil(',').toInt(); - posON2 = Serial.readStringUntil(',').toInt(); - posOFF1 = Serial.readStringUntil(',').toInt(); - posOFF2 = Serial.readStringUntil(',').toInt(); - break; - case 5: - manual = Serial.readStringUntil(',').toInt(); - espera_man = 1; - break; - case 6: - posTEMP = Serial.readStringUntil(',').toInt(); - break; - default: - limpiaSerial(); - } - limpiaSerial(); } } @@ -197,7 +203,6 @@ void termoACC(byte pos1, byte pos2) { } } } while (cont<4); - estado_termo=!estado_termo; } void setVarsEP(){ From 08fa4ecc5134b086d8770cbda0df69e2200a2074 Mon Sep 17 00:00:00 2001 From: "jp.av.dev" Date: Wed, 14 Jul 2021 02:08:51 -0400 Subject: [PATCH 6/8] READMEs --- caldera_esp/README.md | 25 +++++++++++++++++++++++++ caldera_rata/README.md | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 caldera_esp/README.md create mode 100644 caldera_rata/README.md diff --git a/caldera_esp/README.md b/caldera_esp/README.md new file mode 100644 index 0000000..582eb79 --- /dev/null +++ b/caldera_esp/README.md @@ -0,0 +1,25 @@ +ESP01 +===== + +Archivo de configuracion ***confidencial.h*** +```c +const char* ssid = "SSID"; +const char* password = "password"; +``` + +## Urls +* '**/**' : muestra valores actuales de variables. + - ej. http://192.168.65.10/ +* '**/accion**' : accionamiento manual, espera argumentos on u off. + - ej. http://192.168.65.10/accion?mod=5&acc=on +* '**/sethora**' : configurar de fecha y hora. + - ej. http://192.168.65.10/sethora?mod=2&dia=14&mes=7&año=2021&hrs=1&mins=33&segs=24 +* '**/horasAcc**' : configurar horas de funcionamiento. + - ej. http://192.168.65.10/horasAcc?mod=3&hrOn1=5&hrOff1=7&hrOn2=16&hrOff2=18 +* '**/setservo**' : configurar posiciones de encendido y apagado. + - ej. http://192.168.65.10/setservo?mod=4 +* '**/setlibre**' : Mover servo libremente (15 < posicion > 165). + - ej. http://192.168.65.10/setlibre?mod=6&posServ=125 +* '**/auto**' : Modo autonomo. + - ej. http://192.168.65.10/auto + diff --git a/caldera_rata/README.md b/caldera_rata/README.md new file mode 100644 index 0000000..9e82249 --- /dev/null +++ b/caldera_rata/README.md @@ -0,0 +1,36 @@ +## Control de horarios de encendido caldera electrica +Trabaja de forma autonoma y/o comandado por puerto serie + +### 3 Modos de Operación + 1) Automatizado (por defecto) + 5) Manual + 6) Libre +3 Modos de Configuracion + 2) Configuracion de fecha y hora + 3) Configuracion horas de encendido y apagado + 4) Configuracion de posiciones de encendido y apagado + + +Arduino envia cada segundo los valores actuales de las variables de control. +``` +ej. +1,0,5,7,16,18,120,90,45,62,1,42,24,14,7,2021 + +1 > modo, +| 0 > estado termo (O = apagado, 1 = Encendido) +| | 5 > hora de encendido +| | | 7 > hora de apagado +| | | | 16 > 2da hora de encendido (opcional) +| | | | | 18 > 2da hora de apgado (opcional) +| | | | | | 120 > 1ra posicion encendido +| | | | | | | 90 > 2ra posicion encendido +| | | | | | | | 45 > 1ra posicion apagado +| | | | | | | | | 62 > 2ra posicion apagado +| | | | | | | | | | 1 > hora en RTC +| | | | | | | | | | | 42 > minutos en RTC +| | | | | | | | | | | | 24 > segundos en RTC +| | | | | | | | | | | | | 14 > dia en RTC +| | | | | | | | | | | | | | 7 > mes en RTC +| | | | | | | | | | | | | | | 2021 > año en RTC +1,0,5,7,16,18,120,90,45,62,1,42,24,14,7,2021 +``` From dba6fdb49e074cb71036cc81a889b9c858555fc9 Mon Sep 17 00:00:00 2001 From: "jp.av.dev" Date: Wed, 14 Jul 2021 18:28:06 -0400 Subject: [PATCH 7/8] bash script --- scripts/caldera.sh | 156 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100755 scripts/caldera.sh diff --git a/scripts/caldera.sh b/scripts/caldera.sh new file mode 100755 index 0000000..f0212ab --- /dev/null +++ b/scripts/caldera.sh @@ -0,0 +1,156 @@ +#!/bin/bash + +IP_CALDERA="" + +estado_caldera() { + RESP=$(curl -s ${IP_CALDERA}) + MODO=$(echo ${RESP} | cut -d',' -f 1) + ESTADO=$(echo ${RESP} | cut -d',' -f 2) + HR_ON1=$(echo ${RESP} | cut -d',' -f 3) + HR_OFF1=$(echo ${RESP} | cut -d',' -f 4) + HR_ON2=$(echo ${RESP} | cut -d',' -f 5) + HR_OFF2=$(echo ${RESP} | cut -d',' -f 6) + POS_ON1=$(echo ${RESP} | cut -d',' -f 7) + POS_ON2=$(echo ${RESP} | cut -d',' -f 8) + POS_OFF1=$(echo ${RESP} | cut -d',' -f 9) + POS_OFF2=$(echo ${RESP} | cut -d',' -f 10) + HRA=$(echo ${RESP} | cut -d',' -f 11) + MIN=$(echo ${RESP} | cut -d',' -f 12) + SEG=$(echo ${RESP} | cut -d',' -f 13) + DIA=$(echo ${RESP} | cut -d',' -f 14) + MES=$(echo ${RESP} | cut -d',' -f 15) + ANO=$(echo ${RESP} | cut -d',' -f 16) + echo "=============================" + echo " Estado Termo" + [[ ${ESTADO} = "1" ]] && echo " - ENCENDIDO -" + [[ ${ESTADO} = "0" ]] && echo " - APAGADO -" + echo -e "-----------------------------" + case $MODO in + '1') + echo " Modo Automático" + ;; + '5') + echo " Modo Manual (esperando orden)" + ;; + '6') + echo " Modo Libre" + ;; + *) + echo " verificar conexión!" + ;; + esac + echo " Hora : ${HRA}:${MIN}:${SEG}" + echo " Fecha: ${DIA}/${MES}/${ANO}" + echo -e "-------------------------------" + echo " 1ra Hora de encend. : ${HR_ON1} hrs" + echo " 1ra Hora de apagado : ${HR_OFF1} hrs" + echo " 2ra Hora de encend. : ${HR_ON2} hrs" + echo " 2ra Hora de apagado : ${HR_OFF2} hrs" + echo -e "-------------------------------" + echo " 1ra Posición encendido: ${POS_ON1}" + echo " 2da Posición encendido: ${POS_ON2}" + echo " 1ra Posición apagado : ${POS_OFF1}" + echo " 2da Posición apagado : ${POS_OFF2}" + #echo -e "-----------------------------\n" + echo -e "=============================\n" +} + +ejec_orden() { + ORD="" + case $1 in + 2) + ORD="/sethora?1=2&2=${2}&3=${3}&4=${4}&5=${5}&6=${6}&7=${7}" + ;; + 3) + ORD="/horasAcc?1=3&2=${2}&3=${3}&4=${4}&5=${5}" + ;; + 4) + ORD="/setservo?1=4&2=${2}&3=${3}&4=${4}&5=${5}" + ;; + 5) + if [ ${2} = "on" ] + then + ORD="/accion?1=5&2=on" + elif [ ${2} = "off" ] + then + ORD="/accion?1=5&2=off" + fi + ;; + 6) + ORD="/setlibre?1=6&2=${1}" + ;; + *) + ORD="" + ;; + esac + curl -s "${IP_CALDERA}${ORD}" +} + +principal() { + clear + estado_caldera + echo " 1) Funcionamiento Autonomo" + echo " 2) Configurar hora y fecha" + echo " 3) Conf. hrs. de funcionamiento" + echo " 4) Conf. posiciones de func." + echo " 5) Modo manual" + echo " 6) Modo libre" + echo " 0) Salir" + echo + read -p " Ingresa Opcion :" OPC + case ${OPC} in + "1") + curl -s "${IP_CALDERA}/auto" + ;; + "2") + echo "______________________________" + echo " Configuracion de fecha y hora" + read -p "ingresa el DIA: " DIA + read -p "ingresa el MES: " MES + read -p "ingresa el AÑO: " ANO + read -p "ingresa la HORA: " HRA + read -p "ingresa los MINUTOS: " MIN + read -p "ingresa los SEGUNDOS: " SEG + ejec_orden 2 ${DIA} ${MES} ${ANO} ${HRA} ${MIN} ${SEG} + ;; + "3") + echo "______________________________" + echo " Conf. horas de funcionamiento" + read -p " 1ra hora de encendido: " HR_ON1 + read -p " 1ra hora de apagado : " HR_OFF1 + echo " opcional" + read -p " 2da hora de encendido: " HR_ON2 + read -p " 2da hora de apagado : " HR_OFF2 + ejec_orden 3 ${HR_ON1} ${HR_OFF1} ${HR_ON2} ${HR_OFF2} + ;; + "4") + echo "______________________________" + echo " Conf. posiciones del servo" + read -p " 1ra posición encendido: " POS_ON1 + read -p " 2ra posición encendido: " POS_ON2 + read -p " 1ra posición apagado: " POS_OFF1 + read -p " 2ra posición apagado: " POS_OFF2 + ejec_orden 4 ${POS_ON1} ${POS_ON2} ${POS_OFF1} ${POS_OFF2} + ;; + "5") + echo "_______________________" + echo " Funcionamiento Manual " + read -p " Encender o apagar (on/off) :" MANUAL + ejec_orden 5 ${MANUAL} + ;; + "6") + echo "__________________" + echo " Movimiento libre " + read -p " ingresa posición (15<165):" MANUAL + ejec_orden 6 ${MANUAL} + ;; + "0") + exit + ;; + esac +sleep 8 +principal +} + +principal +exit From d71e26ae64ab690a586e5230c9ee98de7619a4f1 Mon Sep 17 00:00:00 2001 From: "jp.av.dev" Date: Wed, 14 Jul 2021 20:35:38 -0400 Subject: [PATCH 8/8] descripcion func. handler --- caldera_esp/README.md | 4 ++-- caldera_esp/caldera_esp.ino | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/caldera_esp/README.md b/caldera_esp/README.md index 582eb79..e61cba6 100644 --- a/caldera_esp/README.md +++ b/caldera_esp/README.md @@ -17,9 +17,9 @@ const char* password = "password"; * '**/horasAcc**' : configurar horas de funcionamiento. - ej. http://192.168.65.10/horasAcc?mod=3&hrOn1=5&hrOff1=7&hrOn2=16&hrOff2=18 * '**/setservo**' : configurar posiciones de encendido y apagado. - - ej. http://192.168.65.10/setservo?mod=4 + - ej. http://192.168.65.10/setservo?mod=4&posOn1=110&posOn2=85&posOff1=45&posOff2=62 * '**/setlibre**' : Mover servo libremente (15 < posicion > 165). - - ej. http://192.168.65.10/setlibre?mod=6&posServ=125 + - ej. http://192.168.65.10/setlibre?mod=6&pos=125 * '**/auto**' : Modo autonomo. - ej. http://192.168.65.10/auto diff --git a/caldera_esp/caldera_esp.ino b/caldera_esp/caldera_esp.ino index 9f7fbd1..037a8c5 100755 --- a/caldera_esp/caldera_esp.ino +++ b/caldera_esp/caldera_esp.ino @@ -23,7 +23,7 @@ void handleACCmanual() { mensaje = "Apagando Caldera"; Serial.println("5,0"); } else { - mensaje = "Opcion no valida, 5,?"; + mensaje = "Opcion no valida\n"; } } else { mensaje = "Opcion no valida ?,?";