personas:johnny:proyectos:indoor_diy_autosostenible
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previaPróxima revisiónAmbos lados, revisión siguiente | ||
personas:johnny:proyectos:indoor_diy_autosostenible [2019/06/19 07:36] – [primer prototipo de control automatico] kz | personas:johnny:proyectos:indoor_diy_autosostenible [2019/11/13 03:15] – kz | ||
---|---|---|---|
Línea 48: | Línea 48: | ||
dht.begin(); | dht.begin(); | ||
// nombre del wifi y clave del wifi al cual se va a conectar el esp | // nombre del wifi y clave del wifi al cual se va a conectar el esp | ||
- | WiFi.begin(" | + | WiFi.begin(" |
while (WiFi.status() != WL_CONNECTED) { | while (WiFi.status() != WL_CONNECTED) { | ||
Línea 208: | Línea 208: | ||
Se intenta manipular relays, mosttar datos en pantallay enviar datos a una base de datos influxdb | Se intenta manipular relays, mosttar datos en pantallay enviar datos a una base de datos influxdb | ||
- | // A ESTE CÖDIGO FALTA IMPLEMENTAR ENVIO DE DATOS AL INFLUX CON WEBSOCKETS | + | A ESTE CÖDIGO FALTA IMPLEMENTAR ENVIO DE DATOS AL INFLUX CON WEBSOCKETS. |
+ | |||
+ | [[https:// | ||
+ | |||
+ | |||
+ | ==== Construcción física del indoor ==== | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | ====== Código para la ventilación usando timeAlarms ====== | ||
<code c++> | <code c++> | ||
- | #include < | + | // https:// |
- | #include < | + | // Librerias |
- | #include <WebSocketsServer.h> | + | #include <Time.h> |
- | #include <Hash.h> | + | #include <TimeAlarms.h> |
- | #include < | + | |
- | #include < | + | |
- | #include < | + | |
- | #include < | + | |
- | #include < | + | |
- | #include < | + | |
- | //#include < | + | |
- | #include " | + | |
- | #define DHTPIN D6 // Pin que va conectado al sensor | + | // pin que controla |
- | #define DHTTYPE DHT11 // Tipo de sensor que estamos usando | + | int pin = 13; |
- | #define HTTP_TIMEOUT 1000 * 60 // cada minuto | + | |
- | DHT dht(DHTPIN, DHTTYPE); | + | |
- | // If using software SPI (the default case): | + | int alarma = 900; // cada 15 min |
- | #define OLED_MOSI | + | |
- | #define OLED_CLK | + | |
- | #define OLED_DC | + | |
- | #define OLED_CS | + | |
- | #define OLED_RESET D0 | + | |
- | Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); | + | void setup() { |
- | + | ||
- | static const char ssid[] = "d(O_O)b"; | + | |
- | static const char password[] = " | + | // |
- | MDNSResponder mdns; | + | // |
- | + | | |
- | static void writeLED(bool); | + | |
- | + | //Creamos las alarmas | |
- | ESP8266WiFiMulti WiFiMulti; | + | //Alarm.alarmRepeat(8, |
- | + | | |
- | ESP8266WebServer server(80); | + | |
- | WebSocketsServer webSocket = WebSocketsServer(81); | + | |
- | + | ||
- | static const char PROGMEM INDEX_HTML[] = R" | + | // |
- | < | + | // |
- | < | + | // |
- | < | + | // |
- | <meta name = " | + | |
- | < | + | |
- | < | + | |
- | "body { background-color: | + | |
- | </ | + | |
- | < | + | |
- | var websock; | + | |
- | var webSockInflux; | + | |
- | function start() { | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | var e = document.getElementById(' | + | |
- | var f = document.getElementById(' | + | |
- | + | ||
- | if (evt.data === ' | + | |
- | e.style.color = ' | + | |
- | } | + | |
- | else if (evt.data === ' | + | |
- | e.style.color = ' | + | |
- | } | + | |
- | else if (evt.data === ' | + | |
- | f.style.color = ' | + | |
- | } | + | |
- | else if (evt.data === ' | + | |
- | f.style.color = ' | + | |
- | } | + | |
- | else { | + | |
- | console.log(' | + | |
- | } | + | |
- | }; | + | |
} | } | ||
- | function buttonclick(e) { | + | void loop() { |
- | | + | |
+ | Alarm.delay(1000); | ||
} | } | ||
- | </script> | + | // encender ventilador |
- | </head> | + | void prenderVentilador(){ |
- | <body onload=" | + | |
- | <img src=" | + | |
- | < | + | } |
- | <div id=" | + | |
- | <button id=" | + | |
- | <button id=" | + | |
- | <br /> | + | |
- | <br /> | + | |
- | <div id=" | ||
- | <button id=" | ||
- | <button id=" | ||
- | </body> | + | // encender ventilador |
- | </html> | + | void apagarVentilador(){ |
- | )rawliteral"; | + | |
- | + | | |
- | // GPIO#0 is for Adafruit ESP8266 HUZZAH board. Your board LED might be on 13. | + | } |
- | const int LEDPIN = D1; | + | |
- | const int LEDPIN1 = D3; | + | |
- | // Current LED status | + | |
- | bool LEDStatus; | + | |
- | bool LEDStatus1; | + | |
- | + | ||
- | // Commands sent through Web Socket | + | |
- | const char LEDON[] = "ledon"; | + | |
- | const char LEDOFF[] = " | + | |
- | // Commands sent through Web Socket | + | // función que enciende el riego |
- | const char LEDON1[] = " | + | void prenderSensorRiegoManana(){ |
- | const char LEDOFF1[] = " | + | Serial.println(" |
- | + | | |
- | void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) | + | |
- | { | + | |
- | | + | |
- | switch(type) { | + | |
- | case WStype_DISCONNECTED: | + | |
- | Serial.printf(" | + | |
- | break; | + | |
- | case WStype_CONNECTED: | + | |
- | { | + | |
- | IPAddress ip = webSocket.remoteIP(num); | + | |
- | Serial.printf(" | + | |
- | // Send the current LED status | + | |
- | if (LEDStatus) { | + | |
- | webSocket.sendTXT(num, | + | |
- | } | + | |
- | else { | + | |
- | webSocket.sendTXT(num, | + | |
- | } | + | |
- | + | ||
- | // Send the current LED status | + | |
- | if (LEDStatus1) { | + | |
- | webSocket.sendTXT(num, | + | |
- | } | + | |
- | else { | + | |
- | webSocket.sendTXT(num, | + | |
- | } | + | |
- | } | + | |
- | break; | + | |
- | case WStype_TEXT: | + | |
- | Serial.printf(" | + | |
- | + | ||
- | if (strcmp(LEDON, | + | |
- | writeLED(true); | + | |
- | } | + | |
- | else if (strcmp(LEDOFF, | + | |
- | writeLED(false); | + | |
- | } | + | |
- | else if (strcmp(LEDON1, | + | |
- | writeLED1(true); | + | |
- | } | + | |
- | else if (strcmp(LEDOFF1, | + | |
- | writeLED1(false); | + | |
- | } | + | |
- | else { | + | |
- | | + | |
- | } | + | |
- | // send data to all connected clients | + | |
- | webSocket.broadcastTXT(payload, | + | |
- | break; | + | |
- | case WStype_BIN: | + | |
- | Serial.printf("[%u] get binary length: %u\r\n", | + | |
- | | + | |
- | + | ||
- | // echo data back to browser | + | |
- | webSocket.sendBIN(num, | + | |
- | break; | + | |
- | default: | + | |
- | Serial.printf(" | + | |
- | break; | + | |
- | } | + | |
} | } | ||
- | + | ||
- | void handleRoot() | + | // función que apaga el riego |
+ | void apagarSensorRiegoManana(){ | ||
+ | Serial.println(" | ||
+ | digitalWrite(pin, | ||
+ | } | ||
+ | |||
+ | void EveningAlarm(){ | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | void WeeklyAlarm(){ | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | void ExplicitAlarm(){ | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | void Repeats(){ | ||
+ | digitalWrite(pin, | ||
+ | Alarm.delay(60000); | ||
+ | Serial.println(" | ||
+ | digitalWrite(pin, | ||
+ | Alarm.delay(1000); | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | void OnceOnly(){ | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | void digitalClockDisplay() | ||
{ | { | ||
- | | + | |
+ | Serial.print(hour()); | ||
+ | printDigits(minute()); | ||
+ | printDigits(second()); | ||
+ | Serial.println(); | ||
} | } | ||
- | + | ||
- | void handleNotFound() | + | void printDigits(int digits) |
{ | { | ||
- | | + | |
- | | + | |
- | | + | Serial.print(' |
- | | + | |
- | | + | } |
- | | + | </ |
- | | + | |
- | | + | |
- | | + | ====== Código para el control automatizado de las luces ====== |
- | | + | |
+ | Este código posee dos funciones que segun el estado se la planta se pueden cambiar para vegetativo o floración. Es un proyecto en platformio | ||
+ | |||
+ | <code c++> | ||
+ | /* | ||
+ | | ||
+ | enciende algo. Tomadpo de aqui https:// | ||
+ | |||
+ | !!! importante | ||
+ | You need to adjust the UTC offset for your timezone in milliseconds. | ||
+ | Refer the list of UTC time offsets. | ||
+ | https:// | ||
+ | |||
+ | For UTC -5.00 : -5 * 60 * 60 : -18000 | ||
+ | For UTC +1.00 : 1 * 60 * 60 : 3600 | ||
+ | | ||
+ | |||
+ | here -> const long utcOffsetInSeconds | ||
+ | */ | ||
+ | #include <Arduino.h> | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | const char *ssid = "el nombre de la red"; | ||
+ | const char *password = "el password de la red"; | ||
+ | const long utcOffsetInSeconds | ||
+ | char daysOfTheWeek[7][12] = { | ||
+ | | ||
+ | }; | ||
+ | // Define NTP client to get time | ||
+ | WiFiUDP ntpUDP; | ||
+ | NTPClient timeClient(ntpUDP, | ||
+ | int ledTrigger | ||
+ | |||
+ | void setup() { | ||
+ | | ||
+ | WiFi.begin(ssid, password); | ||
+ | while(WiFi.status() != WL_CONNECTED) { | ||
+ | | ||
+ | Serial.print("."); | ||
} | } | ||
- | | + | |
+ | Serial.println(" | ||
+ | Serial.println(WiFi.localIP()); | ||
+ | timeClient.begin(); | ||
+ | pinMode(LED_BUILTIN, | ||
+ | pinMode(ledTrigger, OUTPUT); | ||
} | } | ||
- | + | ||
- | static | + | void statusWIFI() { |
- | { | + | // cuando esta pegado a internet el status es 3 |
- | | + | // la idea de esto es que mande un color u otro si tiene internet o no |
- | // Note inverted logic for Adafruit HUZZAH board | + | Serial.print(" |
- | if (LEDon) { | + | Serial.println(WiFi.status()); |
- | digitalWrite(LEDPIN, 1); | + | } |
+ | |||
+ | void lucesVegetativo() | ||
+ | | ||
+ | int hours = timeClient.getHours(); | ||
+ | // se prenden a las 6 de la mañana y se apagan a las 12 de la noche | ||
+ | if ( hours < 6 ) { | ||
+ | digitalWrite(ledTrigger, LOW); | ||
+ | Serial.println(" | ||
+ | } else { | ||
+ | digitalWrite(ledTrigger, | ||
+ | Serial.println(" | ||
} | } | ||
- | | + | } |
- | digitalWrite(LEDPIN, 0); | + | |
+ | void lucesFloracion() { | ||
+ | // 12 horas luz, 12 horas oscuridad | ||
+ | int hours = timeClient.getHours(); | ||
+ | // a las 6 de la mañana se prenden y a las 6 de la tarde se apagan | ||
+ | if ( (hours >= 6) && (hours < 18) ) { | ||
+ | digitalWrite(ledTrigger, | ||
+ | Serial.println(" | ||
+ | } else { | ||
+ | digitalWrite(ledTrigger, LOW); | ||
+ | Serial.println(" | ||
} | } | ||
} | } | ||
- | static | + | // the loop function runs over and over again forever |
- | { | + | void loop() { |
- | | + | |
- | // Note inverted logic for Adafruit HUZZAH board | + | Serial.print(daysOfTheWeek[timeClient.getDay()]); |
- | | + | Serial.print(", |
- | digitalWrite(LEDPIN1, 1); | + | Serial.print(timeClient.getHours()); |
+ | Serial.print(":" | ||
+ | Serial.print(timeClient.getMinutes()); | ||
+ | Serial.print(":" | ||
+ | Serial.print(timeClient.getSeconds()); | ||
+ | Serial.println("" | ||
+ | statusWIFI(); | ||
+ | //lucesVegetativo(); | ||
+ | lucesFloracion(); | ||
+ | delay(1000); | ||
+ | |||
+ | /* | ||
+ | digitalWrite(LED_BUILTIN, | ||
+ | digitalWrite(ledTrigger, | ||
+ | delay(1000); | ||
+ | | ||
+ | digitalWrite(ledTrigger, | ||
+ | delay(1000); | ||
+ | */ | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | el platformio.ini | ||
+ | <code json> | ||
+ | ;PlatformIO Project Configuration File | ||
+ | ; | ||
+ | ; Build options: build flags, source filter | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; Please visit documentation for the other options and examples | ||
+ | ; https:// | ||
+ | |||
+ | [env: | ||
+ | platform = espressif8266 | ||
+ | board = d1_mini_lite | ||
+ | framework = arduino | ||
+ | lib_deps = NTPClient | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====== control de humedad y temperatura ====== | ||
+ | |||
+ | Se inicia de aqui [[https:// | ||
+ | |||
+ | {{: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | <code c++> | ||
+ | #include < | ||
+ | |||
+ | int sensorPin = A0; // select the input pin for the potentiometer | ||
+ | int ledPin = D4; // select the pin for the LED | ||
+ | int sensorValue = 0; // variable to store the value coming from the sensor | ||
+ | |||
+ | void setup() { | ||
+ | // declare the ledPin as an OUTPUT: | ||
+ | pinMode(ledPin, | ||
+ | Serial.begin(115200); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // read the value from the sensor: | ||
+ | sensorValue = analogRead(sensorPin); | ||
+ | Serial.println(sensorValue); | ||
+ | // turn the ledPin on | ||
+ | | ||
+ | // stop the program for < | ||
+ | delay(sensorValue); | ||
+ | // turn the ledPin off: | ||
+ | digitalWrite(ledPin, | ||
+ | // stop the program for for < | ||
+ | delay(sensorValue); | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | Sensor totalmente seco: 833 | ||
+ | Sensor totalmente humedo: 482 | ||
+ | </ | ||
+ | |||
+ | ====== actualizacion nov 3 2019 ====== | ||
+ | |||
+ | He creado una nueva versión del modulo que contiene un **capacitive moisture sensor** para medir la humedad en la tierra, un **module relay x 4** para controlar las luces y la ventilación. Para el ciclo solar de las luces estoy usando la libreria **time.h**, me di cuenta que es mejor usar sin el **timeAlarms.h** porque se pueden customizar mejor los ciclos de la luz y es mejor, o hasta ahora me funciona a mi asi. | ||
+ | |||
+ | |||
+ | ---- | ||
+ | {{: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Mi abuelo me ha ayudado en la creación del indoor, una estructura de 90cm x 90cm x 1.5m. En su interior he añadido el DHT11 para " | ||
+ | |||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | |||
+ | <code c++> | ||
+ | /* Librerias usadas | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * | ||
+ | * Recursos | ||
+ | * https:// | ||
+ | */ | ||
+ | |||
+ | // import libraries | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | // defines and variables globals sensors | ||
+ | // dth11 | ||
+ | #define DHTPIN 4 // D2 | ||
+ | #define DHTTYPE DHT11 | ||
+ | #define HTTP_TIMEOUT 4000 | ||
+ | |||
+ | // screen oled | ||
+ | #define OLED_MOSI 14 // D5 | ||
+ | #define OLED_CLK 16 // D0 | ||
+ | #define OLED_DC 13 // D7 | ||
+ | #define OLED_RESET 12 // D6 | ||
+ | #define OLED_CS 15 // D8 | ||
+ | |||
+ | // lights- relay IN4 | ||
+ | int lights = 2; | ||
+ | |||
+ | // ventilador - relay IN3 | ||
+ | int air = 0; | ||
+ | |||
+ | // capacitive sensor | ||
+ | const int waterValue = 464; | ||
+ | int soilMoistureValue = 0; | ||
+ | |||
+ | Adafruit_SSD1306 display(OLED_MOSI, | ||
+ | DHT dht(DHTPIN, DHTTYPE); | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(115200); | ||
+ | display.begin(SSD1306_SWITCHCAPVCC); | ||
+ | display.clearDisplay(); | ||
+ | display.setTextSize(0.5); | ||
+ | display.setTextColor(WHITE); | ||
+ | display.setCursor(0, | ||
+ | Serial.println(); | ||
+ | Serial.println(); | ||
+ | // | ||
+ | for(uint8_t t = 4; t > 0; t--) { | ||
+ | Serial.printf(" | ||
+ | Serial.flush(); | ||
+ | delay(1000); | ||
} | } | ||
- | | + | |
- | | + | display.setTextColor(WHITE); |
+ | display.setCursor(0, | ||
+ | |||
+ | // casa del negro | ||
+ | // WiFi.begin(" | ||
+ | |||
+ | while (WiFi.status() != WL_CONNECTED) | ||
+ | | ||
+ | display.println(" | ||
+ | display.print(" | ||
} | } | ||
+ | |||
+ | display.display(); | ||
+ | delay(3000); | ||
+ | // H, M, S, D, M, A | ||
+ | setTime(14, | ||
+ | pinMode(lights, | ||
+ | pinMode(air, | ||
+ | dht.begin(); | ||
} | } | ||
- | // función que prepara la trama de datos para hacer un POST a endpoint del influx | + | void loop() { |
- | String | + | display.clearDisplay(); |
- | // este es el nombre del sensor | + | display.setTextSize(0.5); |
- | // Siempre que se quema la primera vez, se debe de cambiar el nombre del sensor | + | display.setTextColor(WHITE); |
- | const String SENSOR_ID = " | + | display.setCursor(0, |
- | + | display.print(" | |
+ | display.print(hour()); | ||
+ | display.print(":" | ||
+ | display.print(minute()); | ||
+ | display.print(":" | ||
+ | display.print(second()); | ||
+ | display.print(" | ||
+ | display.setCursor(0, | ||
+ | | ||
+ | | ||
+ | // display capacitive himudity | ||
+ | display.setCursor(0, | ||
+ | soilMoistureValue = analogRead(A0); | ||
+ | display.print(" | ||
+ | display.println(soilMoistureValue); | ||
+ | delay(500); | ||
+ | // display dht sensor | ||
+ | display.setCursor(0, | ||
+ | int h = dht.readHumidity(); | ||
+ | int t = dht.readTemperature(); | ||
+ | if (isnan(h) || isnan(t)) { | ||
+ | display.println(F(" | ||
+ | return; | ||
+ | } | ||
+ | display.print(F(" | ||
+ | display.print(h); | ||
+ | display.print(F(" | ||
+ | display.print(t); | ||
+ | display.print(F(" | ||
+ | display.println("" | ||
+ | // run air at inddor | ||
+ | ventilacion(); | ||
+ | display.display(); | ||
+ | sendDataInflux(String(h), String(t), String(soilMoistureValue)); | ||
+ | } | ||
+ | |||
+ | void lucesVegetativo() { | ||
+ | // 18 horas luz, 6 horas oscuridad | ||
+ | // se prenden a las 6 de la mañana y se apagan a las 12 de la noche | ||
+ | if ( hour() < 6 ) { | ||
+ | digitalWrite(lights, LOW); | ||
+ | display.println(" | ||
+ | } else { | ||
+ | digitalWrite(lights, | ||
+ | display.println(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void lucesFloracion() { | ||
+ | // 12 horas luz, 12 horas oscuridad | ||
+ | // a las 6 de la mañana | ||
+ | if ( (hour() >= 6) && (hour() < 18) ) { | ||
+ | digitalWrite(lights, | ||
+ | display.println(" | ||
+ | } else { | ||
+ | digitalWrite(lights, | ||
+ | display.println(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void ventilacion() { | ||
+ | // se prende cada 15 min 1 min | ||
+ | if ( (minute() == 1) || (minute() == 16) || (minute() == 46) || (minute() == 31) ) { | ||
+ | digitalWrite(air, | ||
+ | } else { | ||
+ | digitalWrite(air, | ||
+ | } | ||
+ | } | ||
+ | |||
+ | String influxFrame( String dht11_humidity, | ||
+ | const String SENSOR_ID = " | ||
const String STR_COMMA = ","; | const String STR_COMMA = ","; | ||
const String STR_SLASH = "/"; | const String STR_SLASH = "/"; | ||
Línea 474: | Línea 716: | ||
// frame += " | // frame += " | ||
// } | // } | ||
- | + | ||
+ | // ADD capacitive sensor data | ||
+ | frame += " | ||
+ | frame += soilCapacitiveSensor + STR_COMMA; | ||
+ | | ||
// Add Plantower data | // Add Plantower data | ||
// if | // if | ||
Línea 491: | Línea 737: | ||
// función que envía la trama de datos | // función que envía la trama de datos | ||
- | void sendDataInflux ( String humidity, String temperature ) { | + | void sendDataInflux ( String humidity, String temperature, String _soilCapacitiveSensor |
- | /* | + | // El post a la base de datos tiene una trama siguiente: |
- | | + | |
// volker0001, | // volker0001, | ||
- | Para nuestro caso que SOLO es el envío de datos del dht_11 que es humedad y temperatura la trama es la siguiente | + | |
- | // DHT11_llanadas, | + | // DHT11_llanadas, |
- | | + | if(WiFi.status() == 3) { |
- | HTTPClient http; | + | HTTPClient http; |
- | // _testsensorhumedad es el nombre de la DB donde se almacenan estos datos | + | // _testsensorhumedad es el nombre de la DB donde se almacenan estos datos |
- | http.begin(" | + | http.begin(" |
- | http.setTimeout(HTTP_TIMEOUT); | + | http.setTimeout(HTTP_TIMEOUT); |
- | http.addHeader(" | + | http.addHeader(" |
- | + | ||
- | String frame = influxFrame(humidity, | + | // esto se debe de integrar con el soil capacitive sensor |
- | + | // String frame = influxFrame(humidity, | |
- | int httpCode = http.POST(frame); | + | |
- | + | ||
- | if(httpCode > 0) { | + | |
- | String payload = http.getString(); | + | |
- | Serial.println(payload); | + | if(httpCode > 0) { |
- | Serial.println(" | + | String payload = http.getString(); |
- | } else { | + | Serial.println(payload); |
- | Serial.print(" | + | Serial.println(" |
- | Serial.println(http.errorToString(httpCode).c_str()); | + | } else { |
+ | Serial.print(" | ||
+ | Serial.println(http.errorToString(httpCode).c_str()); | ||
+ | } | ||
+ | | ||
} | } | ||
- | + | | |
- | http.end(); | + | |
- | | + | |
} | } | ||
- | + | </ | |
- | void setup() | + | |
- | { | + | |
- | pinMode(LEDPIN, | + | |
- | pinMode(LEDPIN1, | + | |
- | writeLED(false); | + | |
- | writeLED1(false); | + | |
- | + | ||
- | Serial.begin(115200); | + | |
- | // init pantalla | ||
- | display.begin(SSD1306_SWITCHCAPVCC); | ||
- | display.display(); | ||
- | delay(1000); | ||
- | display.clearDisplay(); | ||
- | display.setTextSize(1); | ||
- | display.setTextColor(WHITE); | ||
- | Serial.println(F(" | + | ====== Actualización nov 9 2019 ====== |
- | dht.begin(); | + | |
- | + | ||
- | // | + | |
- | + | ||
- | Serial.println(); | + | |
- | Serial.println(); | + | |
- | Serial.println(); | + | |
- | + | ||
- | for(uint8_t t = 4; t > 0; t--) { | + | |
- | Serial.printf(" | + | |
- | Serial.flush(); | + | |
- | delay(1000); | + | |
- | } | + | |
- | + | Hasta ahora la libreria time.h a funcionado muy bien, reemplazandome por completo un rtc. | |
- | + | ||
- | WiFiMulti.addAP(ssid, password); | + | |
- | + | ||
- | while(WiFiMulti.run() != WL_CONNECTED) { | + | |
- | Serial.print(" | + | |
- | delay(100); | + | |
- | } | + | |
- | + | ||
- | Serial.println("" | + | |
- | Serial.print(" | + | |
- | Serial.println(ssid); | + | |
- | Serial.print(" | + | |
- | Serial.println(WiFi.localIP()); | + | |
- | + | ||
- | if (mdns.begin(" | + | |
- | Serial.println(" | + | |
- | mdns.addService(" | + | |
- | mdns.addService(" | + | |
- | } | + | |
- | else { | + | |
- | Serial.println(" | + | |
- | } | + | |
- | Serial.print(" | + | |
- | Serial.println(WiFi.localIP()); | + | |
- | + | ||
- | server.on("/", | + | |
- | server.onNotFound(handleNotFound); | + | |
- | + | ||
- | server.begin(); | + | |
- | + | ||
- | webSocket.begin(); | + | |
- | webSocket.onEvent(webSocketEvent); | + | |
- | } | + | |
- | + | ||
- | void loop() | + | |
- | { | + | |
- | webSocket.loop(); | + | |
- | server.handleClient(); | + | |
- | // dht11 y pantall | + | === Los datos se puede ver en:=== |
- | static unsigned int h = 0; | + | |
- | static unsigned int t = 0; | + | |
- | h = dht.readHumidity(); | + | [[http:// |
- | t = dht.readTemperature(); | + | |
- | | + | |
- | | + | |
- | if (isnan(h) | + | |
- | Serial.println(F(" | + | |
- | return; | + | |
- | } | + | |
- | */ | + | |
- | display.clearDisplay(); | + | ====== Actualización nov 12 2019 ====== |
- | display.setCursor(0, | + | |
- | display.print(" | + | |
- | display.print(" | + | |
- | display.print(h); | + | |
- | display.print(" | + | |
- | display.print(" | + | |
- | display.print(t); | + | |
- | display.print(" | + | |
- | display.print(" | + | |
- | display.print(WiFi.localIP()); | + | |
- | display.display(); | + | |
- | // sendDataInflux(String(h), | + | Logro adjuntar a la trama de datos la humedad en la tierra de un sensor de humedad capacitivo. |
- | } | + | |
- | </ | + | Tareas que faltan por hacer!!! |
+ | <WRAP center round alert 60%> | ||
+ | En esta imlementación de POST hacia una base de datos, se cae el esp y hace que reinice | ||
+ | </ | ||
+ | - integrar una web en la flash para programar la fecha del rtc digital time.h, | ||
+ | - pensar en una interfaz para pedir al usuario la programacion de la luz sea floración o vegetación o esquejes. | ||
+ | - sacar una tarjetica en fritzing y pasarsela al brol o a uber, con el convertidor de la luz | ||
+ | - actualizar el firmware por medio de ota | ||
+ | |||
+ | |||
+ | |||
personas/johnny/proyectos/indoor_diy_autosostenible.txt · Última modificación: 2020/08/13 06:00 por kz