ITCooky Recetas

Vamos a cocinar it cositas

IoT a lo grande: Dispositivos propios en esp8266 controlados a través de Node-Red!

дата noviembre 12, 2019

Un artículo sobre Node-Red no fue suficiente para mí, sentí que el podría hacer más cosas… pero cómo. Su simplicidad molesta y ayuda. La velocidad de implementación definitivamente ayuda especialmente para probar scripts para esp8266. Así que establecí la tarea de hacer un módulo de clima banal: calidad del aire, humedad, temperatura y llevarlo a la calle, y un enchufe inteligente controlado, también trivial pero complicado, por ejemplo, para guardar la configuración, tuve que convertir el verde a redondo y escribirlo en la memoria de esp8266, que no existe!!!


No escribiré en detalle sobre Node-Red, se describió anteriormente aqui: http://IoT a tope: En ESP8266 con MQTT tras Mosquitto a través de Node-RED!

Está instalado, también tiene un módulo adicional y un tablero de instrumentos.

NR también debe tener ladrillos que establezcan una fecha variable para la hora, aquí está. Se necesita para escribir los datos del sensor en un archivo, es necesario en todos los circuitos.

[{"id":"d1f915cf.6b6728","type":"inject","z":"e60c0f81.64c18","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":1300,"wires":[["3292d870.1e3dd8"]]},{"id":"3292d870.1e3dd8","type":"moment","z":"e60c0f81.64c18","name":"","topic":"","input":"","inputType":"msg","inTz":"Europe/Moscow","adjAmount":"3","adjType":"hours","adjDir":"add","format":"","locale":"en_US","output":"time","outputType":"flow","outTz":"Europe/Moscow","x":400,"y":1300,"wires":[[]]}]

Por cierto, Node-Red es facil de matar, solo hay que hacer un envío de datos MQQT con esp8266 en un bucle sin frenos, trata de evitar eso.

Módulo meteorológico
Para este módulo, tomé de un artículo anterior NodeMcu V3 LoLin, sensor de temperatura DHT22 y MQ-135
Diagrama de conexión

Hice un sandwich asi

El DHT22 tiene patas delgadas, tuve que pegarlo con una pistola de pegamento, el MQ135 es diferente, pero también se lo he pegado

El sensor mq135 vive su propia vida, las lecturas dependen de qué demonios sabe qué. Está conectado a 5v en el ESP8266, muestra 17 , si esta conecta un sensor de temperatura a 5v, mq135 comienza a mostrar 500, si conecta el sensor de temperatura a 3.3v, muestra 61. Se debe a que es analógico.

También es importante comprender que el sensor necesita calentarse. Cuando se enciende por primera vez se calienta durante 48 horas , luego con una pérdida de energía a corto plazo durante unos 10 minutos, despues de eso cobra vida. ¡Y puede que no regrese a los mismos datos, en mi caso cayo de 480 a 200 y no regreso!

En realidad, se llama sensor de calidad del aire, y solo puede decir si es bueno o malo a gran escala sin precision alguna. Y esto se refiere al aire de la calle, no atrapa el aire malo en el apartamento, ya lo intenté produciendo varios aires malos… (solo lo puse en mi boca) Pero en la calle hay humo, tal vez gasolina, alcohol (depende de la gente del barrio en que vive)!

Si usa los sensores para esta biblioteca y calibra, puede obtener un valor similar a ppm: el contenido de dióxido de carbono en el aire. No es exactamente importante para nosotros, ya que ese sensor no sirve para eso, lo principal es que hasta 350 ppm es excelente para la calle, hasta 800 en interiores: aquí lo explican https://habr.com/company/tion/blog/389097/

Es necesario calibrar en el ensamblaje final, y la adición de otros sensores afecta los resultados de la salida analógica (por alguna razón)
Haciendo en esta herramienta https://hackaday.io/project/3475-sniffing-trinket/log/12363-mq135-arduino-library
En mq135.h que, que aprace después de instalar la biblioteca, en mi /home/myusername/snap/arduino-mhall119/5/Arduino/collections/MQ135-master en Ubuntu necesito cambiar el valor de la resistencia, decidí que Lo tengo 1, por defoult es 10 aquí lo explican https://mysku.ru/blog/aliexpress/41409.html

/// The load resistance on the board
#define RLOAD 1.0

subo ese scetch y miro el resultado

#include <MQ135.h> 
#define analogPin A0
MQ135 gasSensor = MQ135(analogPin);

void setup() {

  Serial.begin(9600); 
  delay(1000); 

}

void loop() {

 float rzero = gasSensor.getRZero(); // чтение калибровочных данных
 Serial.println(rzero); // выдача в последовательный порт

 delay(5000);
}

Lo sacamos a la calle durante media hora, la temperatura de la calle debe estar a 20 grados, dicen que la humedad no es tan importante.

La supervisión del puerto se escribe al seriqal port, hay que escribirla en el mismo archivo, es es la linea

#define RZERO 567.63

Después de eso, el sensor me da 682 ppm en la habitación, parece un valor real. Y los valores cambian en grandes incrementos de inmediato por cientos …

El sensor dht22, bueno, todo está claro al respecto y se conoce desde hace mucho tiempo: solo la precisión que evalúo en condiciones reales con más o menos 1, y no 0.5 como en datasheet.

El scetch para esp8266: simplemente envía humedad, temperatura, calidad del aire, estado de alimentación y conexión al servidor MQQT, parpadea una vez en el momento de enviar datos por el LED, y durante un tiempo prolongado cuando no hay conexión, y permite cambiar el intervalo de envío de datos a través de Node-Red.

aqui esta

#include <PubSubClient.h>
#include <DHT_U.h>
#include <DHT.h>
#include <ESP8266WiFi.h>
#include <MQ135.h>
#include <EEPROM.h>
 

// Uncomment one of the lines bellow for whatever DHT sensor type you're using!
//#define DHTTYPE DHT11   // DHT 11
//#define DHTTYPE DHT21   // DHT 21 (AM2301)
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
#define LED_BUILTIN 2


// Change the credentials below, so your ESP8266 connects to your router
const char* ssid = "imyawifitochki";
const char* password = "parolevoyniy";
const char* mqttUser = "name";
const char* mqttPassword = "passworda";
const char* mqttTopicHumidity = "room0/humidity";
const char* mqttTopicTemperature = "room0/temperature";
const char* mqttTopicGas = "room0/gas";
const char* mqttTopicWifi = "room0/wifistatus";
const char* mqttTopicPower = "room0/powerstatus";


const char* mqttTopicResendTime = "room0/resendtime";
const char* mqttTopicResendTimeStatus = "room0/resendtimestatus";
unsigned long resendtime; 
long resendtimetemp; 

// Change the variable to your MQQT IP address, so it connects to your MQTT broker
const char* mqtt_server = "192.168.1.209";

// DHT Sensor - GPIO 5 = D1 on NodeMCU board
const int DHTPin = 5;

MQ135 gasSensor = MQ135(A0);


// Timers auxiliar variables
unsigned long now = millis();
unsigned long lastMeasure = 0;
float ppm;
boolean wifistatus = false;
boolean powerstatus = false;

// Initializes the espClient. You should change the espClient name if you have multiple ESPs running in your home automation system
WiFiClient espClient;
PubSubClient client(espClient);

// Initialize DHT sensor.
DHT dht(DHTPin, DHTTYPE);


void EEPROMWritelong(int address, long value)
      {
      //Decomposition from a long to 4 bytes by using bitshift.
      //One = Most significant -> Four = Least significant byte
      byte four = (value & 0xFF);
      byte three = ((value >> 8) & 0xFF);
      byte two = ((value >> 16) & 0xFF);
      byte one = ((value >> 24) & 0xFF);

      //Write the 4 bytes into the eeprom memory.
      EEPROM.write(address, four);
      EEPROM.commit();
      EEPROM.write(address + 1, three);
      EEPROM.commit();
      EEPROM.write(address + 2, two);
      EEPROM.commit();
      EEPROM.write(address + 3, one);
      EEPROM.commit();
      }

long EEPROMReadlong(long address)
      {
      //Read the 4 bytes from the eeprom memory.
      long four = EEPROM.read(address);
      long three = EEPROM.read(address + 1);
      long two = EEPROM.read(address + 2);
      long one = EEPROM.read(address + 3);

      //Return the recomposed long by using bitshift.
      return ((four << 0) & 0xFF) + ((three << 8) & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
      }
      

void setup() {
  EEPROM.begin(8); 
  dht.begin();
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  pinMode(LED_BUILTIN, OUTPUT); 
  resendtimetemp = EEPROMReadlong(1);
  resendtime = 1000 * resendtimetemp + 500;
  client.setCallback(callback);
}

void callback(String topic, byte* message, unsigned int length) {
  String messageTemp; 
  for (int i = 0; i < length; i++) {
   messageTemp += (char)message[i];
  };
  

 if(topic==mqttTopicResendTime){
resendtimetemp = messageTemp.toInt();
static char TimeResend[7];
    dtostrf(resendtimetemp, 6, 0, TimeResend);
client.publish(mqttTopicResendTimeStatus, TimeResend);
EEPROMWritelong(1, resendtimetemp);
resendtime = 1000 * resendtimetemp; 
delay(500);
 };
 

      
}
// DThis functions connects your ESP8266 to your router
void setup_wifi() {
  delay(10);  
  WiFi.begin(ssid, password);
}


// This functions reconnects your ESP8266 to your MQTT broker 
void reconnect() {
if (client.connect(WiFi.hostname().c_str(), mqttUser, mqttPassword)) {
 
  client.subscribe(mqttTopicResendTime);
  } else {
      // Wait 5 seconds before retrying
      delay(500);
    }
}


void loop() {

now = millis();

  //dont know what this string does, but without it all does not work
 if(!client.loop()) 
     client.connect("blabla");

   if (!client.connected()) {
   digitalWrite(LED_BUILTIN, LOW); 
    reconnect(); 
   digitalWrite(LED_BUILTIN, HIGH);   
     };
       
if (now - lastMeasure > resendtime) {
lastMeasure = now;
if (client.connected()) { 
    
    // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
    float h = dht.readHumidity();
    // Read temperature as Celsius (the default)
    float t = dht.readTemperature();
    // Computes temperature values in Celsius
    float hic = dht.computeHeatIndex(t, h, false);
    static char temperatureTemp[7];
    dtostrf(hic, 6, 1, temperatureTemp);   
    static char humidityTemp[7];
    dtostrf(h, 6, 1, humidityTemp);
    //mq135
    //SensorGas = analogRead(0);
    float ppm = gasSensor.getPPM();
    static char GasTemp[7];
    dtostrf(ppm, 6, 0, GasTemp);
    
    // Publishes values
   digitalWrite(LED_BUILTIN, LOW);
    if (!wifistatus)
        {
            client.publish(mqttTopicWifi, "0");
            wifistatus = true;
        } else {
            client.publish(mqttTopicWifi, "1"); 
     };
     if (!powerstatus)
        {
            client.publish(mqttTopicPower, "0");
            powerstatus = true;
        } else {
            client.publish(mqttTopicPower, "1"); 
     };
   client.publish(mqttTopicTemperature, temperatureTemp);
   client.publish(mqttTopicHumidity, humidityTemp);
   client.publish(mqttTopicGas, GasTemp);

static char TimeResend[7];
    dtostrf(resendtimetemp, 6, 0, TimeResend);
client.publish(mqttTopicResendTimeStatus, TimeResend);

   digitalWrite(LED_BUILTIN, HIGH);
    } else {
  wifistatus = false;
      };
  };
}

Las bibliotecas al comienzo del script son estándar y del artículo anterior recuerdo:

Descargue la biblioteca para el sensor de temperatura y humedad dht22 https://github.com/adafruit/DHT-sensor-library/archive/master.zip y esa tmbn https://github.com/adafruit/Adafruit_Sensor/archive/master.zip Agréguelo al programa a través del menú Scretch > Include Library > Add .ZIP Library

Ahora, sobre Node-Red, los siguientes ladrillos son responsables de este módulo.

foto

Y el texto con todas las configuraciones, puede agregar inmediatamente a su Nodo-Rojo a través del import

[{"id":"66632934.7d2108","type":"ui_chart","z":"e60c0f81.64c18","name":"Temperature","group":"bc9278be.b3a778","order":2,"width":"0","height":"0","label":"Temperature","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#8e0911","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":610,"y":1440,"wires":[[],[]]},{"id":"dd1d964c.587a48","type":"mqtt in","z":"e60c0f81.64c18","name":"Temperature","topic":"room0/temperature","qos":"2","broker":"572eed08.5bb714","x":410,"y":1400,"wires":[["66632934.7d2108","e4fe9e7e.ad3bd","2642c360.3f098c"]]},{"id":"59b169c0.45d7c8","type":"file","z":"e60c0f81.64c18","name":"Write temp_room0.log","filename":"/root/iot_data/temp_room0.log","appendNewline":true,"createDir":false,"overwriteFile":"false","x":840,"y":1400,"wires":[[]]},{"id":"e4fe9e7e.ad3bd","type":"function","z":"e60c0f81.64c18","name":"Add time to data","func":"var timenow=flow.get('time');\nmsg.payload = timenow + ' '+ msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":620,"y":1400,"wires":[["59b169c0.45d7c8"]]},{"id":"55dd3d19.1cb534","type":"mqtt in","z":"e60c0f81.64c18","name":"Humidity","topic":"room0/humidity","qos":"2","broker":"572eed08.5bb714","x":400,"y":1540,"wires":[["2204294a.0fe706","6601b62f.9280f8","5c8f1bbc.113754"]]},{"id":"5b4fb0e2.0fe7c","type":"file","z":"e60c0f81.64c18","name":"Write humi_room0.log","filename":"/root/iot_data/humi_room0.log","appendNewline":true,"createDir":false,"overwriteFile":"false","x":840,"y":1540,"wires":[[]]},{"id":"2204294a.0fe706","type":"function","z":"e60c0f81.64c18","name":"Add time to data","func":"var timenow=flow.get('time');\nmsg.payload = timenow + ' '+ msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":620,"y":1540,"wires":[["5b4fb0e2.0fe7c"]]},{"id":"7f21c47e.cd05ec","type":"mqtt in","z":"e60c0f81.64c18","name":"MQQT 0 status","topic":"room0/wifistatus","qos":"2","broker":"572eed08.5bb714","x":420,"y":1780,"wires":[["64b4189d.f8b998"]]},{"id":"64b4189d.f8b998","type":"ui_chart","z":"e60c0f81.64c18","name":"MQQT status","group":"ee36947a.ec2f48","order":1,"width":0,"height":0,"label":"MQQT was lost at","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"1","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":true,"colors":["#000000","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#77090a","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":590,"y":1780,"wires":[[],[]]},{"id":"4e04c12d.74d74","type":"mqtt in","z":"e60c0f81.64c18","name":"Power","topic":"room0/powerstatus","qos":"2","broker":"572eed08.5bb714","x":390,"y":1840,"wires":[["da433eb8.d0b53"]]},{"id":"da433eb8.d0b53","type":"ui_chart","z":"e60c0f81.64c18","name":"Power","group":"ee36947a.ec2f48","order":2,"width":0,"height":0,"label":"Power was lost at","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"1","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":true,"colors":["#000000","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#680808","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":570,"y":1840,"wires":[[],[]]},{"id":"de1fc131.312c1","type":"mqtt in","z":"e60c0f81.64c18","name":"Air Quality","topic":"room0/gas","qos":"2","broker":"572eed08.5bb714","x":400,"y":1660,"wires":[["74651f53.e4a4","466ebb3f.6f3764","3cb75aee.0a3c16"]]},{"id":"74651f53.e4a4","type":"ui_chart","z":"e60c0f81.64c18","name":"Gas","group":"bc9278be.b3a778","order":6,"width":0,"height":0,"label":"Air Quality","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#24a516","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":570,"y":1700,"wires":[[],[]]},{"id":"6601b62f.9280f8","type":"ui_chart","z":"e60c0f81.64c18","name":"Humidity","group":"bc9278be.b3a778","order":4,"width":"0","height":"0","label":"Humidity","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#0971c1","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":600,"y":1580,"wires":[[],[]]},{"id":"f15544ba.4e3c58","type":"ui_slider","z":"e60c0f81.64c18","name":"","label":"slider","group":"1022d713.859ec9","order":2,"width":0,"height":0,"passthru":true,"outs":"end","topic":"room0/resendtime","min":"15","max":"600","step":"5","x":390,"y":1900,"wires":[["eb3a4359.710b3"]]},{"id":"eb3a4359.710b3","type":"mqtt out","z":"e60c0f81.64c18","name":"","topic":"room0/resendtime","qos":"","retain":"","broker":"572eed08.5bb714","x":590,"y":1900,"wires":[]},{"id":"aa44d360.ad6e4","type":"mqtt in","z":"e60c0f81.64c18","name":"resend time","topic":"room0/resendtimestatus","qos":"2","broker":"572eed08.5bb714","x":410,"y":1960,"wires":[["20197ac3.af7b56"]]},{"id":"20197ac3.af7b56","type":"ui_text","z":"e60c0f81.64c18","group":"1022d713.859ec9","order":1,"width":0,"height":0,"name":"","label":"Weather sensors - send and check  data  every (seconds):","format":"{{msg.payload}}","layout":"col-center","x":750,"y":1960,"wires":[]},{"id":"2642c360.3f098c","type":"ui_text","z":"e60c0f81.64c18","group":"bc9278be.b3a778","order":1,"width":0,"height":0,"name":"","label":"Temperature now is","format":"{{msg.payload}}","layout":"row-center","x":630,"y":1480,"wires":[]},{"id":"5c8f1bbc.113754","type":"ui_text","z":"e60c0f81.64c18","group":"bc9278be.b3a778","order":3,"width":0,"height":0,"name":"","label":"Humidity now is ","format":"{{msg.payload}}","layout":"row-center","x":620,"y":1620,"wires":[]},{"id":"466ebb3f.6f3764","type":"ui_text","z":"e60c0f81.64c18","group":"bc9278be.b3a778","order":5,"width":0,"height":0,"name":"","label":"Air quality now is","format":"{{msg.payload}}","layout":"row-center","x":610,"y":1740,"wires":[]},{"id":"4571b392.d9b66c","type":"file","z":"e60c0f81.64c18","name":"Write air_room0.log","filename":"/root/iot_data/air_room0.log","appendNewline":true,"createDir":false,"overwriteFile":"false","x":830,"y":1660,"wires":[[]]},{"id":"3cb75aee.0a3c16","type":"function","z":"e60c0f81.64c18","name":"Add time to data","func":"var timenow=flow.get('time');\nmsg.payload = timenow + ' '+ msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":620,"y":1660,"wires":[["4571b392.d9b66c"]]},{"id":"bc9278be.b3a778","type":"ui_group","z":"","name":"Weather Data","tab":"c5ac561a.7e8ef8","order":1,"disp":true,"width":"10","collapse":false},{"id":"572eed08.5bb714","type":"mqtt-broker","z":"","name":"Mosquitto Orange","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"ee36947a.ec2f48","type":"ui_group","z":"","name":"Weather Status","tab":"c5ac561a.7e8ef8","order":3,"disp":true,"width":"10","collapse":false},{"id":"1022d713.859ec9","type":"ui_group","z":"","name":"Weather Send/Check interval Settings","tab":"5d7f916a.3be03","order":4,"disp":true,"width":"6","collapse":false},{"id":"c5ac561a.7e8ef8","type":"ui_tab","z":"","name":"Weather","icon":"dashboard","order":2},{"id":"5d7f916a.3be03","type":"ui_tab","z":"","name":"Settings","icon":"dashboard","order":4}]

Después de importar algo, no olvide hacer clic en Deploy en NR

Estos ladrillos nos dan estadísticas de 24 horas en la pestaña Weather en la interfaz de usuario Node-Red

El gráfico de energía muestra cuándo se apagó o reinició el módulo; después de encenderlo, el gráfico mostrara caida de linea. MQQT monitorea el estado de las conexiones WiFi.
Además, en la pestaña Settings en la IU Nodo-Rojo, aparece el cuadro de Weather Send/Check interval Settings eso permite configurar el intervalo de actualización, que se almacena en la memoria de esp8266

IMPORTANTE: en el primer inicio después de subir scetch a esp8266, es necesario establecer el intervalo de actualización en el cuadro Weather Send/Check interval Settings en la pestaña Configuración en la interfaz de usuario Node-Red, de lo contrario puede haber cualquier numero, se toma desde un lugar vacío de la memoria, pero puede no estar vacío

Ahora sobre power. Quería alimentar de forma inalámbrica a través del vidrio, desafortunadamente esta tecnología no es tan fuerte, en realidad solo se transmiten 8 mm desde la base de la electricidad.
Compré este 18650 Battery shield V3 para Raspberry Pi WEMOS para Arduino Micro Type usb-USB; no dare un enlace porque no vale la pena comprarlo. Esto debería funcionar como un UPS; la alimentación se apaga; la batería se enciende; el power se enciende; la batería se carga directamente. En la vida real, no siempre se enciende incluso desde la batería: los chinos no copiaron completamente, o el original era el mismo … La potencia es soldaba a 3v, tambien prove 5v: no importa como es conectaod, no actua como UPS! En fintengo una hamburguesa asi


Lo tiramos afuera, funciona durante 22-24 horas, la potencia real de la batería Samsung 18650 trucha es de 1000 mAh lo he medido con USB power tester. El principal consumidor es el sensor de aire.


Módulo de enchufe inteligente con sensor de temperatura y humedad

Así es como se ve, hecho con lo que había en Leroy Merlin

Como base, se seleccionaron dos palos de parquet, pegados con pegamento de carpintería. Cables de 2.5 mm, terminales Terminal de Wago 5 conectores para cables de 26.6 × 14 × 5 × 20.5 mm, poliamida, 5 piezas: los cables duran con un esfuerzo. Todo apenas entró en la caja de distribución de 120x80x50 mm, IP5: los cables ocupan mucho espacio. Perfore un agujero, lo selle con cinta aislante en un lado y lo llene con una pistola de pegamento, resultó ser una excelente ventana para el LED. Enchufe Schneider Electric puesto a masa, IP44 gris es un excelente enchufe y está fabricado en Rusia, se pueden ensamblar varios en una fila, hay dónde poner los cables, es una pena que no se pueda girar la cubierta, solo en una posición, por lo que interfiere cuando los dos están cerca.

Aquí hay un diagrama. Los relés ya no se venden, pero creo que son todos iguales (tengo vcc-gnd): solo necesito conectar 5v a una buena fuente, no funcionó para mí desde Lolin (aunque hay un 5v), lo conecté directamente a la cargador – Esta es una carga USB Auchan rota por 120 rublos.

Si todo se calcula al precio con los tableros, será de 1500 rublos – es el valor de un enchufe Wi-Fi chino, ¡pero no puede programarlo para lo que necesita! El montaje lleva mucho tiempo y, por alguna razón, los dedos empiezan a sangran…

Aqui esta el scketch LoLin

#include "PubSubClient.h";
#include "DHT_U.h";
#include "DHT.h";
#include "ESP8266WiFi.h";
#include "EEPROM.h";

// Uncomment one of the lines bellow for whatever DHT sensor type you&#039;re using!
//#define DHTTYPE DHT11   // DHT 11
//#define DHTTYPE DHT21   // DHT 21 (AM2301)
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
#define LED_BUILTIN 2

// Change the credentials below, so your ESP8266 connects to your router
const char* ssid = "mYwIfI";
const char* password = "PASSword";
const char* mqttUser = "IOTman";
const char* mqttPassword = "PASSiot";

const char* mqttTopicHumidity = "room1/humidity";
const char* mqttTopicTemperature = "room1/temperature";
const char* mqttTopicWifi = "room1/wifistatus";
const char* mqttTopicPower = "room1/powerstatus";
// power 1 settings start
const char* mqttTopicButtonPower1 = "power/buttonunit1";
const char* mqttTopicButtonStatusPower1 = "power/buttonstatusunit1";
const char* mqttTopicPower1status = "power/unit1status";
int buttonpower1;
const char* mqttTopicButtonPower1auto = "power/buttonunit1auto";
const char* mqttTopicButtonStatusPower1auto = "power/buttonstatusunit1auto";
int buttonpower1auto;
const char* mqttTopicButtonPower1case = "power/buttonunit1case";
const char* mqttTopicButtonStatusPower1case = "power/buttonstatusunit1case";
int buttonpower1case;
const char* mqttTopicButtonPower1temp = "power/buttonunit1temp";
const char* mqttTopicButtonStatusPower1temp = "power/buttonstatusunit1temp";
int8_t buttonpower1temp;
const char* mqttTopicButtonPower1time = "power/buttonunit1time";
const char* mqttTopicButtonStatusPower1time = "power/buttonstatusunit1time";
unsigned long buttonpower1time;
unsigned long lastMeasure21 = 0;
unsigned long reruntime; 
// power 1 settings end

// power 2 settings start
const char* mqttTopicButtonPower2 = "power/buttonunit2";
const char* mqttTopicButtonStatusPower2 = "power/buttonstatusunit2";
const char* mqttTopicPower2status = "power/unit2status";
int buttonpower2;
const char* mqttTopicButtonPower2auto = "power/buttonunit2auto";
const char* mqttTopicButtonStatusPower2auto = "power/buttonstatusunit2auto";
int buttonpower2auto;
const char* mqttTopicButtonPower2case = "power/buttonunit2case";
const char* mqttTopicButtonStatusPower2case = "power/buttonstatusunit2case";
int buttonpower2case;
const char* mqttTopicButtonPower2temp = "power/buttonunit2temp";
const char* mqttTopicButtonStatusPower2temp = "power/buttonstatusunit2temp";
int8_t buttonpower2temp;
const char* mqttTopicButtonPower2time = "power/buttonunit2time";
const char* mqttTopicButtonStatusPower2time = "power/buttonstatusunit2time";
unsigned long buttonpower2time;
unsigned long lastMeasure22 = 0;
unsigned long reruntime2; 
// power 2 settings end


// Change the variable to your Raspberry Pi IP address, so it connects to your MQTT broker
const char* mqtt_server = "192.168.1.209";


const int DHTPin = 1;
const int power1 = 4;
const int power2 = 5;
int tempwarning = 3;
int Nt = 0;
int Nh = 0;
boolean wifistatus = false;
boolean powerstatus = false;


// Timers auxiliar variables
unsigned long now = millis();
unsigned long lastMeasure = 0;

const char* mqttTopicResendTime = "room1/resendtime";
const char* mqttTopicResendTimeStatus = "room1/resendtimestatus";
unsigned long resendtime = 30000; 
long resendtimetemp; 

//eeprom memory use
//power1 settings
// 1,2,3,4,5-8,
//power2 settings
// 9,10,11,12,13-16,
//data resend time
// 17-20

// Initializes the espClient.
WiFiClient espClient;
PubSubClient client(espClient);

// Initialize DHT sensor.
DHT dht(DHTPin, DHTTYPE);


void setup() {
  EEPROM.begin(32);
  dht.begin();
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  pinMode(power2, OUTPUT); 
  pinMode(power1, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  // power 1 settings start
 buttonpower1 = EEPROM.read(1);
 buttonpower1auto = EEPROM.read(2);
 buttonpower1case = EEPROM.read(3);
 buttonpower1temp = (int8_t)EEPROM.read(4);
 buttonpower1time = EEPROMReadlong(5);
 reruntime = 60000 * buttonpower1time;
 // power 1 settings end

   // power 2 settings start
 buttonpower2 = EEPROM.read(9);
 buttonpower2auto = EEPROM.read(10);
 buttonpower2case = EEPROM.read(11);
 buttonpower2temp = (int8_t)EEPROM.read(12);
 buttonpower2time = EEPROMReadlong(13);
 reruntime2 = 60000 * buttonpower2time;
 // power 2 settings end

 resendtimetemp = EEPROMReadlong(17);
 resendtime = 1000 * resendtimetemp + 500;
 
digitalWrite(power2, HIGH);
digitalWrite(power1, HIGH);
  client.setCallback(callback);
  //Serial.begin(9600);
}


//This function will write a 4 byte (32bit) long to the eeprom at
//the specified address to address + 3.
void EEPROMWritelong(int address, long value)
      {
      //Decomposition from a long to 4 bytes by using bitshift.
      //One = Most significant -> Four = Least significant byte
      byte four = (value & 0xFF);
      byte three = ((value >> 8) & 0xFF);
      byte two = ((value >> 16) & 0xFF);
      byte one = ((value >> 24) & 0xFF);

      //Write the 4 bytes into the eeprom memory.
      EEPROM.write(address, four);
      EEPROM.commit();
      EEPROM.write(address + 1, three);
      EEPROM.commit();
      EEPROM.write(address + 2, two);
      EEPROM.commit();
      EEPROM.write(address + 3, one);
      EEPROM.commit();
      }

long EEPROMReadlong(long address)
      {
      //Read the 4 bytes from the eeprom memory.
      long four = EEPROM.read(address);
      long three = EEPROM.read(address + 1);
      long two = EEPROM.read(address + 2);
      long one = EEPROM.read(address + 3);

      //Return the recomposed long by using bitshift.
      return ((four << 0) & 0xFF) + ((three << 8) & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
      }
      
// Don't change the function below. This functions connects your ESP8266 to your router
void setup_wifi() {
  delay(10);
  // We start by connecting to a WiFi network
  WiFi.begin(ssid, password);

}

// This functions is executed when some device publishes a message to a topic that your ESP8266 is subscribed to
// Change the function below to add logic to your program, so when a device publishes a message to a topic that 
// your ESP8266 is subscribed you can actually do something
void callback(String topic, byte* message, unsigned int length) {
  String messageTemp; 
  for (int i = 0; i < length; i++) {
   messageTemp += (char)message[i];
  };
  
// power 1 settings start 
  if(topic==mqttTopicButtonPower1){
     if(messageTemp == "do"){       
if (buttonpower1 == 1)
{
client.publish(mqttTopicButtonStatusPower1, "off");
client.publish(mqttTopicPower1status, "0");
buttonpower1 = 0;
EEPROM.write(1, buttonpower1);
EEPROM.commit();
digitalWrite(power1, HIGH);
}else {
client.publish(mqttTopicButtonStatusPower1, "on");
client.publish(mqttTopicPower1status, "1");
buttonpower1 = 1;
EEPROM.write(1, buttonpower1);
EEPROM.commit();
digitalWrite(power1, LOW);
};
delay(500);
 };
 };  
 if(topic==mqttTopicButtonPower1auto){
     if(messageTemp == "do"){       
if (buttonpower1auto == 1)
{
client.publish(mqttTopicButtonStatusPower1auto, "off");

buttonpower1auto = 0;
EEPROM.write(2, buttonpower1auto);
EEPROM.commit();

}else {
client.publish(mqttTopicButtonStatusPower1auto, "on");

buttonpower1auto = 1;
EEPROM.write(2, buttonpower1auto);
EEPROM.commit();
};
delay(500);
 };
 };

 if(topic==mqttTopicButtonPower1case){
     if(messageTemp == "do"){       
if (buttonpower1case == 1)
{
client.publish(mqttTopicButtonStatusPower1case, "less");
buttonpower1case = 0;
EEPROM.write(3, buttonpower1case);
EEPROM.commit();

}else {
client.publish(mqttTopicButtonStatusPower1case, "more");
buttonpower1case = 1;
EEPROM.write(3, buttonpower1case);
EEPROM.commit();
};
delay(500);
 };
 };
 if(topic==mqttTopicButtonPower1temp){
buttonpower1temp = messageTemp.toInt();
static char TempTemp[7];
    dtostrf(buttonpower1temp, 6, 0, TempTemp);
client.publish(mqttTopicButtonStatusPower1temp, TempTemp);
EEPROM.write(4, buttonpower1temp);
EEPROM.commit();
delay(500);
 };
 if(topic==mqttTopicButtonPower1time){
buttonpower1time = messageTemp.toInt();
static char TimeTemp[7];
    dtostrf(buttonpower1time, 6, 0, TimeTemp);
client.publish(mqttTopicButtonStatusPower1time, TimeTemp);
//EEPROM.write(5, buttonpower1time);
EEPROMWritelong(5, buttonpower1time);
reruntime = 60000 * buttonpower1time;
delay(500);
 };


// power 1 settings end

  if(topic==mqttTopicResendTime){
resendtimetemp = messageTemp.toInt();
static char TimeResend[7];
    dtostrf(resendtimetemp, 6, 0, TimeResend);
client.publish(mqttTopicResendTimeStatus, TimeResend);
EEPROMWritelong(17, resendtimetemp);
resendtime = 1000 * resendtimetemp; 
delay(500);
 };
 
// power 2 settings start 
  if(topic==mqttTopicButtonPower2){
     if(messageTemp == "do"){       
if (buttonpower2 == 1)
{
client.publish(mqttTopicButtonStatusPower2, "off");
client.publish(mqttTopicPower2status, "0");
buttonpower2 = 0;
EEPROM.write(9, buttonpower2);
EEPROM.commit();
digitalWrite(power2, HIGH);
}else {
client.publish(mqttTopicButtonStatusPower2, "on");
client.publish(mqttTopicPower2status, "1");
buttonpower2 = 1;
EEPROM.write(9, buttonpower2);
EEPROM.commit();
digitalWrite(power2, LOW);
};
delay(500);
 };
 };  
 if(topic==mqttTopicButtonPower2auto){
     if(messageTemp == "do"){       
if (buttonpower2auto == 1)
{
client.publish(mqttTopicButtonStatusPower2auto, "off");

buttonpower2auto = 0;
EEPROM.write(10, buttonpower2auto);
EEPROM.commit();

}else {
client.publish(mqttTopicButtonStatusPower2auto, "on");

buttonpower2auto = 1;
EEPROM.write(10, buttonpower2auto);
EEPROM.commit();
};
delay(500);
 };
 };

 if(topic==mqttTopicButtonPower2case){
     if(messageTemp == "do"){       
if (buttonpower2case == 1)
{
client.publish(mqttTopicButtonStatusPower2case, "less");
buttonpower2case = 0;
EEPROM.write(11, buttonpower2case);
EEPROM.commit();

}else {
client.publish(mqttTopicButtonStatusPower2case, "more");
buttonpower2case = 1;
EEPROM.write(11, buttonpower2case);
EEPROM.commit();
};
delay(500);
 };
 };
 if(topic==mqttTopicButtonPower2temp){
buttonpower2temp = messageTemp.toInt();
static char TempTemp[7];
    dtostrf(buttonpower2temp, 6, 0, TempTemp);
client.publish(mqttTopicButtonStatusPower2temp, TempTemp);
EEPROM.write(12, buttonpower2temp);
EEPROM.commit();
delay(500);
 };
 if(topic==mqttTopicButtonPower2time){
buttonpower2time = messageTemp.toInt();
static char TimeTemp[7];
    dtostrf(buttonpower2time, 6, 0, TimeTemp);
client.publish(mqttTopicButtonStatusPower2time, TimeTemp);
//EEPROM.write(5, buttonpower1time);
EEPROMWritelong(13, buttonpower2time);
reruntime2 = 60000 * buttonpower2time;
delay(500);
 };
// power 1 settings end
      
}

// This functions reconnects your ESP8266 to your MQTT broker
// Change the function below if you want to subscribe to more topics with your ESP8266 
void reconnect() {

    if (client.connect(WiFi.hostname().c_str(), mqttUser, mqttPassword)) {
      // Subscribe or resubscribe to a topic
      // You can subscribe to more topics (to control more LEDs in this example)
   
   // power 1 settings start
   client.subscribe(mqttTopicButtonPower1);
   client.subscribe(mqttTopicButtonPower1auto);
   client.subscribe(mqttTopicButtonPower1case);
   client.subscribe(mqttTopicButtonPower1temp);
   client.subscribe(mqttTopicButtonPower1time);
   // power 1 settings end

   // power 2 settings start
   client.subscribe(mqttTopicButtonPower2);
   client.subscribe(mqttTopicButtonPower2auto);
   client.subscribe(mqttTopicButtonPower2case);
   client.subscribe(mqttTopicButtonPower2temp);
   client.subscribe(mqttTopicButtonPower2time);
   // power 2 settings end
   client.subscribe(mqttTopicResendTime);
    } else {
      // Wait 5 seconds before retrying
      delay(500);
    }

}


void loop() {

  now = millis();

  //dont know what this string does, but without it all does not work
 if(!client.loop()) 
     client.connect("blabla");

  if (!client.connected()) {
   digitalWrite(LED_BUILTIN, LOW); 
    reconnect(); 
   digitalWrite(LED_BUILTIN, HIGH);   
     };


if (now - lastMeasure21 > reruntime) {
    lastMeasure21 = now;  
if (buttonpower1auto == 1) 
{ client.publish(mqttTopicPower1status, "0");
  client.publish(mqttTopicButtonStatusPower1, "off");
  digitalWrite(power1, HIGH);
  buttonpower1 = 0;
};

}; 

 if (now - lastMeasure22 > reruntime2) {
    lastMeasure22 = now;  
if (buttonpower2auto == 1) 
{ client.publish(mqttTopicPower2status, "0");
  client.publish(mqttTopicButtonStatusPower2, "off");
  digitalWrite(power2, HIGH);
  buttonpower2 = 0;
};

};        
    
if (now - lastMeasure > resendtime) {
    lastMeasure = now;  

    float hf = dht.readHumidity();
    static char humidityTemp[7];
    dtostrf(hf, 6, 1, humidityTemp);
    int8_t h = (int) hf;
    float tf = dht.readTemperature();
    static char temperatureTemp[7];
    dtostrf(tf, 6, 1, temperatureTemp);
    int8_t t = (int) tf;
    
    
// power 1 settings start
if (buttonpower1auto == 1) 
{ 

  
if (buttonpower1case == 1 )
{
if ( t >= buttonpower1temp)
{ 

 Nt = Nt + 1;
 lastMeasure21 = now; 
 if (Nt == 2 )
{ 
  client.publish(mqttTopicPower1status, "1");
  client.publish(mqttTopicButtonStatusPower1, "on");
  digitalWrite(power1, LOW);
  buttonpower1 = 1;
 
  Nt = 0;
};

  
} else {
Nt = 0;  
};




};
if (buttonpower1case == 0 ) {
  if ( t <= buttonpower1temp)
{ 

  Nt = Nt + 1;
 lastMeasure21 = now;
 if (Nt == 2 )
{ 
  client.publish(mqttTopicPower1status, "1");
  client.publish(mqttTopicButtonStatusPower1, "on");
 digitalWrite(power1, LOW);
 buttonpower1 = 1;
  
  Nt = 0;
};

  
} else {
Nt = 0;  
};

};
};
// power 1  settings end


// power 2 settings start
if (buttonpower2auto == 1) 
{
if (buttonpower2case == 1 )
{
if ( h >= buttonpower2temp)
{ 
  
   Nh = Nh + 1;
 lastMeasure22 = now; 
 if (Nh == 2 )
{ 
  client.publish(mqttTopicPower2status, "1");
  client.publish(mqttTopicButtonStatusPower2, "on");
  digitalWrite(power2, LOW);
  buttonpower2 = 1;
 
  Nh = 0; 
 }; 
} else {
Nh = 0;  
};

};
if (buttonpower2case == 0 ) {
  if ( h <= buttonpower2temp)
{ 

  Nh = Nh + 1;
  lastMeasure22 = now;
 if (Nh == 2 )
{ 
  client.publish(mqttTopicPower2status, "1");
  client.publish(mqttTopicButtonStatusPower2, "on");
 digitalWrite(power2, LOW);
 buttonpower2 = 1;
 
 Nh = 0; 
 }; 
} else {
Nh = 0;  
};
};
};
// power 2 settings end

if (client.connected()) {


    // Publishes 
digitalWrite(LED_BUILTIN, LOW);   digitalWrite(LED_BUILTIN, LOW);

    
    client.publish(mqttTopicTemperature, temperatureTemp);
    client.publish(mqttTopicHumidity, humidityTemp);

    static char TimeResend[7];
    dtostrf(resendtimetemp, 6, 0, TimeResend);
client.publish(mqttTopicResendTimeStatus, TimeResend);

    // power 1 settings start
    static char TempTemp[7];
    dtostrf(buttonpower1temp, 6, 0, TempTemp);
client.publish(mqttTopicButtonStatusPower1temp, TempTemp);
static char TimeTemp[7];
    dtostrf(buttonpower1time, 6, 0, TimeTemp);
client.publish(mqttTopicButtonStatusPower1time, TimeTemp);
  if (digitalRead(power1) == LOW)
 {
  if (buttonpower1 == 1)
{
  client.publish(mqttTopicPower1status, "1");
  client.publish(mqttTopicButtonStatusPower1, "on");
} else {
  client.publish(mqttTopicPower1status, "0");
  client.publish(mqttTopicButtonStatusPower1, "off");
  digitalWrite(power1, HIGH);
  buttonpower1 = 0;
};
 } else {
  if (buttonpower1 == 0)
{
  client.publish(mqttTopicPower1status, "0");
  client.publish(mqttTopicButtonStatusPower1, "off");
} else {
  client.publish(mqttTopicPower1status, "1");
  client.publish(mqttTopicButtonStatusPower1, "on");
  digitalWrite(power1, LOW);
  buttonpower1 = 1;
};

 };
 if (buttonpower1auto == 1)
{
  client.publish(mqttTopicButtonStatusPower1auto, "on");
} else {
  client.publish(mqttTopicButtonStatusPower1auto, "off");

}; 
 if (buttonpower1case == 1)
{
  client.publish(mqttTopicButtonStatusPower1case, "more");
} else {
  client.publish(mqttTopicButtonStatusPower1case, "less");

}; 
// power 1 settings end


 // power 2 settings start
    static char TempTemp2[7];
    dtostrf(buttonpower2temp, 6, 0, TempTemp2);
    client.publish(mqttTopicButtonStatusPower2temp, TempTemp2);
    static char TimeTemp2[7];
    dtostrf(buttonpower2time, 6, 0, TimeTemp2);
    client.publish(mqttTopicButtonStatusPower2time, TimeTemp2);
    
  if (digitalRead(power2) == LOW)
 {
  if (buttonpower2 == 1)
{
  client.publish(mqttTopicPower2status, "1");
  client.publish(mqttTopicButtonStatusPower2, "on");
} else {
  client.publish(mqttTopicPower2status, "0");
  client.publish(mqttTopicButtonStatusPower2, "off");
  digitalWrite(power2, HIGH);
  buttonpower2 = 0;
};
 } else {
  if (buttonpower2 == 0)
{
  client.publish(mqttTopicPower2status, "0");
  client.publish(mqttTopicButtonStatusPower2, "off");
} else {
  client.publish(mqttTopicPower2status, "1");
  client.publish(mqttTopicButtonStatusPower2, "on");
  digitalWrite(power2, LOW);
  buttonpower2 = 1;
};

 };
 if (buttonpower2auto == 1)
{
  client.publish(mqttTopicButtonStatusPower2auto, "on");
} else {
  client.publish(mqttTopicButtonStatusPower2auto, "off");

}; 
 if (buttonpower2case == 1)
{
  client.publish(mqttTopicButtonStatusPower2case, "more");
} else {
  client.publish(mqttTopicButtonStatusPower2case, "less");

}; 
// power 2 settings end

 if (!wifistatus)
 {
client.publish(mqttTopicWifi, "0");
wifistatus = true;
  
 } else {
 client.publish(mqttTopicWifi, "1"); 
 };
if (!powerstatus)
        {
            client.publish(mqttTopicPower, "0");
            powerstatus = true;
        } else {
            client.publish(mqttTopicPower, "1"); 
     };

  digitalWrite(LED_BUILTIN, HIGH);
  };
 
};

}



IMPORTANTE: en el primer inicio después de subit scketch a esp8266, es necesario establecer el intervalo de actualización en el cuadro Storage Room Send/Check interval Settings en la interfaz de usuario Node-Red, de lo contrario puede haber basura, se lee desde un lugar vacío en la memoria, pero puede no estar vacío. Lo mismo es cierto para otras configuraciones, pero no tan crítico

Al enviar datos, hace lo mismo que el módulo meteorológico, solo que no hay sensor aérea. También hay una configuración de intervalo en la pestaña Settings en la IU Node-Red, pero también aparecen configuraciones para encender los enchufes en la condición dada, funcionan incluso si no hay conexión a Node-Red.

Aquí están los ladrillos responsables del enchufe inteligente en Node-Red

Y texto que puedes importar tú mismo

[{"id":"5fb16ee4.f988e","type":"ui_chart","z":"e60c0f81.64c18","name":"Temperature","group":"91158576.4f6178","order":2,"width":0,"height":0,"label":"Temperature graph","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#8e0911","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#910304","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":610,"y":1040,"wires":[[],[]]},{"id":"f8830669.9e10c8","type":"mqtt in","z":"e60c0f81.64c18","name":"Temperature","topic":"room1/temperature","qos":"2","broker":"572eed08.5bb714","x":410,"y":920,"wires":[["5fb16ee4.f988e","b77ce775.ac0f98","8a1fb374.d6b14","692ab0d4.84698"]]},{"id":"7c990247.71a3cc","type":"file","z":"e60c0f81.64c18","name":"Write temp_room1.log","filename":"/root/iot_data/temp_room1.log","appendNewline":true,"createDir":false,"overwriteFile":"false","x":840,"y":920,"wires":[[]]},{"id":"b77ce775.ac0f98","type":"function","z":"e60c0f81.64c18","name":"Add time to data","func":"var timenow=flow.get('time');\nmsg.payload = timenow + ' '+ msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":620,"y":920,"wires":[["7c990247.71a3cc"]]},{"id":"4293b7d1.57e368","type":"ui_chart","z":"e60c0f81.64c18","name":"Humidity","group":"91158576.4f6178","order":4,"width":0,"height":0,"label":"Humidity graph","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#0971c1","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":600,"y":1220,"wires":[[],[]]},{"id":"c5e2d074.7634","type":"mqtt in","z":"e60c0f81.64c18","name":"Humidity","topic":"room1/humidity","qos":"2","broker":"572eed08.5bb714","x":400,"y":1100,"wires":[["4293b7d1.57e368","6d8e3a37.c02eb4","7d33c3bc.f07a7c","c49d559f.8ef4c8"]]},{"id":"6d7903e5.1fdeac","type":"file","z":"e60c0f81.64c18","name":"Write humi_room1.log","filename":"/root/iot_data/humi_room1.log","appendNewline":true,"createDir":false,"overwriteFile":"false","x":840,"y":1100,"wires":[[]]},{"id":"6d8e3a37.c02eb4","type":"function","z":"e60c0f81.64c18","name":"Add time to data","func":"var timenow=flow.get('time');\nmsg.payload = timenow + ' '+ msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":620,"y":1100,"wires":[["6d7903e5.1fdeac"]]},{"id":"75b1ee83.fb8dc","type":"ui_chart","z":"e60c0f81.64c18","name":"Power 1","group":"fba9a7a9.8c5418","order":3,"width":0,"height":0,"label":"Power 1 use","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"1","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":true,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#680808","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":680,"y":140,"wires":[[],[]]},{"id":"6bb7ff0c.048ea","type":"mqtt in","z":"e60c0f81.64c18","name":"","topic":"power/unit1status","qos":"2","broker":"572eed08.5bb714","x":420,"y":140,"wires":[["75b1ee83.fb8dc"]]},{"id":"f7a70f9f.25cec","type":"mqtt in","z":"e60c0f81.64c18","name":"MQQT status","topic":"room1/wifistatus","qos":"2","broker":"572eed08.5bb714","x":410,"y":800,"wires":[["e586b3bf.742ce"]]},{"id":"e586b3bf.742ce","type":"ui_chart","z":"e60c0f81.64c18","name":"MQQT status","group":"c8aa5b51.ed6ff8","order":1,"width":0,"height":0,"label":"MQQT was lost at","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"1","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":true,"colors":["#000000","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#77090a","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":570,"y":800,"wires":[[],[]]},{"id":"83fc107.a5b6ef","type":"ui_button","z":"e60c0f81.64c18","name":"","group":"fba9a7a9.8c5418","order":2,"width":0,"height":0,"passthru":false,"label":"press to change","color":"","bgcolor":"","icon":"","payload":"do","payloadType":"str","topic":"power/buttonunit1","x":420,"y":20,"wires":[["1d72bb8f.7aa464"]]},{"id":"1d72bb8f.7aa464","type":"mqtt out","z":"e60c0f81.64c18","name":"","topic":"power/buttonunit1","qos":"","retain":"","broker":"572eed08.5bb714","x":650,"y":20,"wires":[]},{"id":"c1ce83be.d59b6","type":"mqtt in","z":"e60c0f81.64c18","name":"Power1 Button status","topic":"power/buttonstatusunit1","qos":"2","broker":"572eed08.5bb714","x":440,"y":80,"wires":[["44e98139.d58"]]},{"id":"44e98139.d58","type":"ui_text","z":"e60c0f81.64c18","group":"fba9a7a9.8c5418","order":1,"width":0,"height":0,"name":"","label":"Power 1 (override by auto control):","format":"{{msg.payload}}","layout":"row-spread","x":720,"y":80,"wires":[]},{"id":"e8a32ad3.656188","type":"ui_button","z":"e60c0f81.64c18","name":"","group":"fba9a7a9.8c5418","order":5,"width":0,"height":0,"passthru":false,"label":"press to change","color":"","bgcolor":"","icon":"","payload":"do","payloadType":"str","topic":"power/buttonunit1auto","x":420,"y":200,"wires":[["a947e584.e98788"]]},{"id":"a947e584.e98788","type":"mqtt out","z":"e60c0f81.64c18","name":"","topic":"power/buttonunit1auto","qos":"","retain":"","broker":"572eed08.5bb714","x":660,"y":200,"wires":[]},{"id":"d30d9525.ffe7b8","type":"mqtt in","z":"e60c0f81.64c18","name":"power1 Auto  Button status","topic":"power/buttonstatusunit1auto","qos":"2","broker":"572eed08.5bb714","x":450,"y":260,"wires":[["6c440e2c.b0432"]]},{"id":"6c440e2c.b0432","type":"ui_text","z":"e60c0f81.64c18","group":"fba9a7a9.8c5418","order":4,"width":0,"height":0,"name":"","label":"Power 1 Temprutare Auto Control:","format":"{{msg.payload}}","layout":"row-spread","x":720,"y":260,"wires":[]},{"id":"7dad518e.e0f73","type":"ui_button","z":"e60c0f81.64c18","name":"","group":"fba9a7a9.8c5418","order":7,"width":0,"height":0,"passthru":false,"label":"press to change","color":"","bgcolor":"","icon":"","payload":"do","payloadType":"str","topic":"power/buttonunit1case","x":420,"y":320,"wires":[["f83f2f6b.a2178"]]},{"id":"f83f2f6b.a2178","type":"mqtt out","z":"e60c0f81.64c18","name":"","topic":"power/buttonunit1case","qos":"","retain":"","broker":"572eed08.5bb714","x":660,"y":320,"wires":[]},{"id":"aefd6457.2fb318","type":"mqtt in","z":"e60c0f81.64c18","name":"power1 Auto  Button Case","topic":"power/buttonstatusunit1case","qos":"2","broker":"572eed08.5bb714","x":450,"y":380,"wires":[["5f62a213.e2221c"]]},{"id":"5f62a213.e2221c","type":"ui_text","z":"e60c0f81.64c18","group":"fba9a7a9.8c5418","order":6,"width":0,"height":0,"name":"","label":"When the temperature is...:","format":"{{msg.payload}}","layout":"col-center","x":740,"y":380,"wires":[]},{"id":"2023e629.f7fcda","type":"ui_slider","z":"e60c0f81.64c18","name":"","label":"slider","group":"fba9a7a9.8c5418","order":9,"width":0,"height":0,"passthru":true,"outs":"end","topic":"power/buttonunit1temp","min":"-35","max":"65","step":1,"x":390,"y":440,"wires":[["81263bde.91ff88"]]},{"id":"81263bde.91ff88","type":"mqtt out","z":"e60c0f81.64c18","name":"","topic":"power/buttonunit1temp","qos":"","retain":"","broker":"572eed08.5bb714","x":600,"y":440,"wires":[]},{"id":"ea28795a.ea98c8","type":"mqtt in","z":"e60c0f81.64c18","name":"power1 Auto  Button Temp","topic":"power/buttonstatusunit1temp","qos":"2","broker":"572eed08.5bb714","x":450,"y":500,"wires":[["cda707f3.409308"]]},{"id":"cda707f3.409308","type":"ui_text","z":"e60c0f81.64c18","group":"fba9a7a9.8c5418","order":8,"width":0,"height":0,"name":"","label":"than...:","format":"{{msg.payload}}","layout":"col-center","x":670,"y":500,"wires":[]},{"id":"518c1721.0ef2f8","type":"ui_slider","z":"e60c0f81.64c18","name":"","label":"slider","group":"fba9a7a9.8c5418","order":12,"width":0,"height":0,"passthru":true,"outs":"end","topic":"power/buttonunit1time","min":"1","max":"1000","step":"5","x":390,"y":560,"wires":[["769e0778.e2f7a8"]]},{"id":"769e0778.e2f7a8","type":"mqtt out","z":"e60c0f81.64c18","name":"","topic":"power/buttonunit1time","qos":"","retain":"","broker":"572eed08.5bb714","x":600,"y":560,"wires":[]},{"id":"8e77c553.3d1568","type":"mqtt in","z":"e60c0f81.64c18","name":"power1 Auto  Button Time","topic":"power/buttonstatusunit1time","qos":"2","broker":"572eed08.5bb714","x":450,"y":620,"wires":[["b368c669.6da6d8"]]},{"id":"b368c669.6da6d8","type":"ui_text","z":"e60c0f81.64c18","group":"fba9a7a9.8c5418","order":11,"width":0,"height":0,"name":"","label":"turn on power for (min)...:","format":"{{msg.payload}}","layout":"col-center","x":730,"y":620,"wires":[]},{"id":"81acd203.1a222","type":"mqtt in","z":"e60c0f81.64c18","name":"Power status","topic":"room1/powerstatus","qos":"2","broker":"572eed08.5bb714","x":410,"y":860,"wires":[["ab1a1085.b7e91"]]},{"id":"ab1a1085.b7e91","type":"ui_chart","z":"e60c0f81.64c18","name":"Power status","group":"c8aa5b51.ed6ff8","order":2,"width":0,"height":0,"label":"Power was lost at","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"1","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":true,"colors":["#000000","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#77090a","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":570,"y":860,"wires":[[],[]]},{"id":"311965fc.bcde5a","type":"ui_chart","z":"e60c0f81.64c18","name":"Power 2","group":"5d3c2f30.e95b4","order":3,"width":0,"height":0,"label":"Power 2 use","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"1","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":true,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#680808","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1260,"y":140,"wires":[[],[]]},{"id":"b9e207d5.faf328","type":"mqtt in","z":"e60c0f81.64c18","name":"","topic":"power/unit2status","qos":"2","broker":"572eed08.5bb714","x":1000,"y":140,"wires":[["311965fc.bcde5a"]]},{"id":"c0f3e890.50a9e8","type":"ui_button","z":"e60c0f81.64c18","name":"","group":"5d3c2f30.e95b4","order":2,"width":0,"height":0,"passthru":false,"label":"press to change","color":"","bgcolor":"","icon":"","payload":"do","payloadType":"str","topic":"power/buttonunit2","x":1000,"y":20,"wires":[["9947f5c1.130478"]]},{"id":"9947f5c1.130478","type":"mqtt out","z":"e60c0f81.64c18","name":"","topic":"power/buttonunit2","qos":"","retain":"","broker":"572eed08.5bb714","x":1230,"y":20,"wires":[]},{"id":"25644cfa.7b9654","type":"mqtt in","z":"e60c0f81.64c18","name":"Power2 Button status","topic":"power/buttonstatusunit2","qos":"2","broker":"572eed08.5bb714","x":1020,"y":80,"wires":[["63e87dc0.334cb4"]]},{"id":"63e87dc0.334cb4","type":"ui_text","z":"e60c0f81.64c18","group":"5d3c2f30.e95b4","order":1,"width":0,"height":0,"name":"","label":"Power 2 (override by auto control):","format":"{{msg.payload}}","layout":"row-spread","x":1300,"y":80,"wires":[]},{"id":"6c3e3c55.f81e54","type":"ui_button","z":"e60c0f81.64c18","name":"","group":"5d3c2f30.e95b4","order":5,"width":0,"height":0,"passthru":false,"label":"press to change","color":"","bgcolor":"","icon":"","payload":"do","payloadType":"str","topic":"power/buttonunit2auto","x":1000,"y":200,"wires":[["f5da73f4.22916"]]},{"id":"f5da73f4.22916","type":"mqtt out","z":"e60c0f81.64c18","name":"","topic":"power/buttonunit2auto","qos":"","retain":"","broker":"572eed08.5bb714","x":1240,"y":200,"wires":[]},{"id":"1700d32.26aca2d","type":"mqtt in","z":"e60c0f81.64c18","name":"power2 Auto  Button status","topic":"power/buttonstatusunit2auto","qos":"2","broker":"572eed08.5bb714","x":1030,"y":260,"wires":[["baba5a9c.6601b8"]]},{"id":"baba5a9c.6601b8","type":"ui_text","z":"e60c0f81.64c18","group":"5d3c2f30.e95b4","order":4,"width":0,"height":0,"name":"","label":"Power 2 Humidity Auto Control:","format":"{{msg.payload}}","layout":"row-spread","x":1290,"y":260,"wires":[]},{"id":"dc8fc8ce.aef588","type":"ui_button","z":"e60c0f81.64c18","name":"","group":"5d3c2f30.e95b4","order":7,"width":0,"height":0,"passthru":false,"label":"press to change","color":"","bgcolor":"","icon":"","payload":"do","payloadType":"str","topic":"power/buttonunit2case","x":1000,"y":320,"wires":[["ec4c9b15.062838"]]},{"id":"ec4c9b15.062838","type":"mqtt out","z":"e60c0f81.64c18","name":"","topic":"power/buttonunit2case","qos":"","retain":"","broker":"572eed08.5bb714","x":1240,"y":320,"wires":[]},{"id":"39c84012.dc4ee","type":"mqtt in","z":"e60c0f81.64c18","name":"power2 Auto  Button Case","topic":"power/buttonstatusunit2case","qos":"2","broker":"572eed08.5bb714","x":1030,"y":380,"wires":[["94a9fa82.c5ec98"]]},{"id":"94a9fa82.c5ec98","type":"ui_text","z":"e60c0f81.64c18","group":"5d3c2f30.e95b4","order":6,"width":0,"height":0,"name":"","label":"When the humidity is...:","format":"{{msg.payload}}","layout":"col-center","x":1310,"y":380,"wires":[]},{"id":"d8b512eb.d148c","type":"ui_slider","z":"e60c0f81.64c18","name":"","label":"slider","group":"5d3c2f30.e95b4","order":9,"width":0,"height":0,"passthru":true,"outs":"end","topic":"power/buttonunit2temp","min":"0","max":"100","step":1,"x":970,"y":440,"wires":[["ae0c8dc4.727a9"]]},{"id":"ae0c8dc4.727a9","type":"mqtt out","z":"e60c0f81.64c18","name":"","topic":"power/buttonunit2temp","qos":"","retain":"","broker":"572eed08.5bb714","x":1180,"y":440,"wires":[]},{"id":"20495eae.c1ac82","type":"mqtt in","z":"e60c0f81.64c18","name":"power2 Auto  Button Hum","topic":"power/buttonstatusunit2temp","qos":"2","broker":"572eed08.5bb714","x":1030,"y":500,"wires":[["96679630.ad9d48"]]},{"id":"96679630.ad9d48","type":"ui_text","z":"e60c0f81.64c18","group":"5d3c2f30.e95b4","order":8,"width":0,"height":0,"name":"","label":"than...:","format":"{{msg.payload}}","layout":"col-center","x":1250,"y":500,"wires":[]},{"id":"af1a3232.ba29","type":"ui_slider","z":"e60c0f81.64c18","name":"","label":"slider","group":"5d3c2f30.e95b4","order":12,"width":0,"height":0,"passthru":true,"outs":"end","topic":"power/buttonunit2time","min":"1","max":"1000","step":"5","x":970,"y":560,"wires":[["401038f3.9af088"]]},{"id":"401038f3.9af088","type":"mqtt out","z":"e60c0f81.64c18","name":"","topic":"power/buttonunit2time","qos":"","retain":"","broker":"572eed08.5bb714","x":1180,"y":560,"wires":[]},{"id":"87874ed1.92dfb","type":"mqtt in","z":"e60c0f81.64c18","name":"power1 Auto  Button Time","topic":"power/buttonstatusunit2time","qos":"2","broker":"572eed08.5bb714","x":1030,"y":620,"wires":[["ba6bd99.57a9e28"]]},{"id":"ba6bd99.57a9e28","type":"ui_text","z":"e60c0f81.64c18","group":"5d3c2f30.e95b4","order":11,"width":0,"height":0,"name":"","label":"turn on power for (min)...:","format":"{{msg.payload}}","layout":"col-center","x":1310,"y":620,"wires":[]},{"id":"4bea9f97.478f6","type":"ui_slider","z":"e60c0f81.64c18","name":"","label":"slider","group":"5b5e436d.06525c","order":2,"width":0,"height":0,"passthru":true,"outs":"end","topic":"room1/resendtime","min":"15","max":"600","step":"5","x":390,"y":680,"wires":[["c9cf61b2.27fc8"]]},{"id":"c9cf61b2.27fc8","type":"mqtt out","z":"e60c0f81.64c18","name":"","topic":"room1/resendtime","qos":"","retain":"","broker":"572eed08.5bb714","x":590,"y":680,"wires":[]},{"id":"98b50a35.88b558","type":"mqtt in","z":"e60c0f81.64c18","name":"resend time","topic":"room1/resendtimestatus","qos":"2","broker":"572eed08.5bb714","x":410,"y":740,"wires":[["e763f56c.4c08e8"]]},{"id":"e763f56c.4c08e8","type":"ui_text","z":"e60c0f81.64c18","group":"5b5e436d.06525c","order":1,"width":0,"height":0,"name":"","label":"Storage Room sensors - send and check  data  every (seconds):","format":"{{msg.payload}}","layout":"col-center","x":770,"y":740,"wires":[]},{"id":"8a1fb374.d6b14","type":"ui_text","z":"e60c0f81.64c18","group":"91158576.4f6178","order":1,"width":0,"height":0,"name":"","label":"Temperature now is","format":"{{msg.payload}}","layout":"row-center","x":630,"y":1000,"wires":[]},{"id":"7d33c3bc.f07a7c","type":"ui_text","z":"e60c0f81.64c18","group":"91158576.4f6178","order":3,"width":0,"height":0,"name":"","label":"Humidity now is","format":"{{msg.payload}}","layout":"row-center","x":620,"y":1140,"wires":[]},{"id":"692ab0d4.84698","type":"ui_text","z":"e60c0f81.64c18","group":"fba9a7a9.8c5418","order":10,"width":0,"height":0,"name":"","label":"(Temperature now is","format":"{{msg.payload}})","layout":"row-left","x":640,"y":960,"wires":[]},{"id":"c49d559f.8ef4c8","type":"ui_text","z":"e60c0f81.64c18","group":"5d3c2f30.e95b4","order":10,"width":0,"height":0,"name":"","label":"(Humidity now is","format":"{{msg.payload}})","layout":"row-left","x":620,"y":1180,"wires":[]},{"id":"91158576.4f6178","type":"ui_group","z":"","name":"Storage Room Data","tab":"274c10df.50bbd","order":1,"disp":true,"width":"10","collapse":false},{"id":"572eed08.5bb714","type":"mqtt-broker","z":"","name":"Mosquitto Orange","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"fba9a7a9.8c5418","type":"ui_group","z":"","name":"Storage Room Power 1 Settings","tab":"5d7f916a.3be03","order":3,"disp":true,"width":"6","collapse":false},{"id":"c8aa5b51.ed6ff8","type":"ui_group","z":"","name":"Storage Room Status","tab":"274c10df.50bbd","order":2,"disp":true,"width":"10","collapse":false},{"id":"5d3c2f30.e95b4","type":"ui_group","z":"","name":"Storage Room Power 2 Settings","tab":"5d7f916a.3be03","order":3,"disp":true,"width":"6","collapse":false},{"id":"5b5e436d.06525c","type":"ui_group","z":"","name":"Storage Room Send/Check interval Settings","tab":"5d7f916a.3be03","order":4,"disp":true,"width":"6","collapse":false},{"id":"274c10df.50bbd","type":"ui_tab","z":"","name":"Storage Room","icon":"dashboard","order":1},{"id":"5d7f916a.3be03","type":"ui_tab","z":"","name":"Settings","icon":"dashboard","order":4}]

Ni siquiera mostraré una captura de pantalla con los datos, no es nada interesante. Aquí hay una captura de pantalla con la configuración.

Configuraciones para cada enchife va en columnas. El primero responde a la temperatura, el segundo a la humedad. Puede encender o apagar el enchufe de inmediato en la configuración; esto cambiará si se activa la automatización. Puede ver el gráfico del funcionamiento del enchufe durante 24 horas, 1 significa que está encendido, los valores se muestran al instante. Hay configuraciones para activar la automatización, seleccione si es más o menos que el valor establecido (muestra inmediatamente qué valor es ahora) y luego encienda el zócalo (de lo contrario, apáguelo), durante un intervalo determinado.
Verifiqué que funciona, pero, por supuesto, los errores pueden permanecer. Resultó muchas características, por ejemplo, no puede escribir valores booleanos en la memoria, los cambió a 0 y 1, aunque es lo mismo. Para estimar la temperatura, traduje los dígitos decimales de los sensores a enteros, ya que (como muchas personas notan) la comparación de los dígitos decimales pode dar un resultado inespirado. Muchas, muchas horas de entretenimiento todo esto me trajo ehhh.

PRECAUCIÓN: Hubo un error incomprensible, la automatización funcionó sola, o algo mas. Por lo tanto, ahora, para que se active la automatización, espera dos actividades predeterminadas de los sensores.

Simplemente recoja la temperatura de los procesadores de todas las computadoras
Bueno, como que de todos … con Windows, probablemente, también se puede, de alguna manera, probablemente … bueno, no están adaptados para IoT, incluso a través de Bash para Windows es poco probalble.

Tengo unos computadoras que realmente funcionan las 24 horas, hay otras que se encienden durante un par de horas. Ponemos el cliente MQQT en ellos y enviamos los datos de temperatura del CPU.

Pero comenzando con Node-Communista, aquí están los ladrillos que son responsables de esto.

Lo mismo pero en texto para importar

[{"id":"b05b819f.c4ea5","type":"mqtt in","z":"e60c0f81.64c18","name":"Cpu Temp","topic":"pccpu/retropi","qos":"2","broker":"572eed08.5bb714","x":380,"y":2160,"wires":[["34365a5f.ca6216","d07f2055.bc239"]]},{"id":"34365a5f.ca6216","type":"ui_chart","z":"e60c0f81.64c18","name":"RetroPi Cpu Temp","group":"51bdd67d.76b488","order":2,"width":"0","height":"0","label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"0","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#7c0202","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":550,"y":2160,"wires":[[],[]]},{"id":"d07f2055.bc239","type":"ui_text","z":"e60c0f81.64c18","group":"51bdd67d.76b488","order":1,"width":0,"height":0,"name":"","label":"CPU (Broadcom BCM2836) Temperature","format":"{{msg.payload}}","layout":"col-center","x":650,"y":2120,"wires":[]},{"id":"fdbdadbe.75049","type":"mqtt in","z":"e60c0f81.64c18","name":"Cpu Temp","topic":"pccpu/orangepiplus","qos":"2","broker":"572eed08.5bb714","x":380,"y":2240,"wires":[["f8715fd8.f4c4e","7ac58efe.9836f"]]},{"id":"f8715fd8.f4c4e","type":"ui_chart","z":"e60c0f81.64c18","name":"Orange Pi Pc plus Cpu Temp","group":"c2baeca.d963e1","order":2,"width":0,"height":0,"label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"0","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#7c0202","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":580,"y":2240,"wires":[[],[]]},{"id":"7ac58efe.9836f","type":"ui_text","z":"e60c0f81.64c18","group":"c2baeca.d963e1","order":1,"width":0,"height":0,"name":"","label":"CPU (H3 Quad-core) Temperature","format":"{{msg.payload}}","layout":"col-center","x":630,"y":2200,"wires":[]},{"id":"6eee9129.5375a","type":"mqtt in","z":"e60c0f81.64c18","name":"Cpu Temp1","topic":"pccpu/inteli5c1","qos":"2","broker":"572eed08.5bb714","x":390,"y":2320,"wires":[["2facad3f.7a4302","ee017615.d82cb8"]]},{"id":"2facad3f.7a4302","type":"ui_chart","z":"e60c0f81.64c18","name":"Intel Core Cpu Temp","group":"8007d5e0.fc68a8","order":5,"width":0,"height":0,"label":"Intel Core i5-3470 CPU Temperature","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"0","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#7c0202","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":660,"y":2480,"wires":[[],[]]},{"id":"984b8237.787a6","type":"mqtt in","z":"e60c0f81.64c18","name":"Cpu Temp2","topic":"pccpu/inteli5c2","qos":"2","broker":"572eed08.5bb714","x":390,"y":2380,"wires":[["2facad3f.7a4302","b1d1dca0.453be"]]},{"id":"466f0788.50fb68","type":"mqtt in","z":"e60c0f81.64c18","name":"Cpu Temp3","topic":"pccpu/inteli5c3","qos":"2","broker":"572eed08.5bb714","x":390,"y":2440,"wires":[["2facad3f.7a4302","dd72b678.7599e8"]]},{"id":"75af7157.a1885","type":"mqtt in","z":"e60c0f81.64c18","name":"Cpu Temp4","topic":"pccpu/inteli5c4","qos":"2","broker":"572eed08.5bb714","x":390,"y":2500,"wires":[["2facad3f.7a4302","39fcaaab.85efa6"]]},{"id":"ee017615.d82cb8","type":"ui_text","z":"e60c0f81.64c18","group":"8007d5e0.fc68a8","order":1,"width":0,"height":0,"name":"","label":"Core 1 Temperature","format":"{{msg.payload}}","layout":"row-center","x":660,"y":2320,"wires":[]},{"id":"b1d1dca0.453be","type":"ui_text","z":"e60c0f81.64c18","group":"8007d5e0.fc68a8","order":2,"width":0,"height":0,"name":"","label":"Core 2 Temperature","format":"{{msg.payload}}","layout":"row-center","x":660,"y":2360,"wires":[]},{"id":"dd72b678.7599e8","type":"ui_text","z":"e60c0f81.64c18","group":"8007d5e0.fc68a8","order":3,"width":0,"height":0,"name":"","label":"Core 3 Temperature","format":"{{msg.payload}}","layout":"row-center","x":660,"y":2400,"wires":[]},{"id":"39fcaaab.85efa6","type":"ui_text","z":"e60c0f81.64c18","group":"8007d5e0.fc68a8","order":4,"width":0,"height":0,"name":"","label":"Core 4 Temperature","format":"{{msg.payload}}","layout":"row-center","x":660,"y":2440,"wires":[]},{"id":"572eed08.5bb714","type":"mqtt-broker","z":"","name":"Mosquitto Orange","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"51bdd67d.76b488","type":"ui_group","z":"","name":"RetroPi","tab":"69d311f6.b104c","order":1,"disp":true,"width":"12","collapse":false},{"id":"c2baeca.d963e1","type":"ui_group","z":"","name":"Orange Pi PC PLUS","tab":"69d311f6.b104c","order":2,"disp":true,"width":"12","collapse":false},{"id":"8007d5e0.fc68a8","type":"ui_group","z":"","name":"Intel PC","tab":"69d311f6.b104c","order":3,"disp":true,"width":"12","collapse":false},{"id":"69d311f6.b104c","type":"ui_tab","z":"","name":"CPU Temperature","icon":"dashboard","order":3}]

Estos gráficos se muestran en 24 horas.

Las pasos para RaspberryPi 3 en RetroPi y Orange Pi PC PLUS en Armbian difieren solo en el nombre del topic en el que enviaremos el valor de temperatura

instlamos en minipc
sudo apt-get install mosquitto-clients
vamos a
cd /home/pi
creamos file
vi sendtemp.sh
con code

#!/bin/bash
a=`cat /sys/class/thermal/thermal_zone0/temp`
d=$(( ${a}/1000 ))
/usr/bin/mosquitto_pub -h "192.168.1.209" -u Login -P MyPassword -t "pccpu/retropi" -m "${d}"

lo hacemos ejecutivo
chmod +x sendtemp.sh
y añdimos al cron
crontab -e
linea

* * * * * sh /home/pi/sendtemp.sh

Los comandos para Orangepi son las mismas, pero en lugar de pccpu/retropi, debe poner pccpu/orangepiplus y la ruta al script

Ahora, para la PC Intel en Ubuntu, no es tan fácil obtener la temperatura, es diferente para cada núcleo
hay que instalar
sudo apt-get install mosquitto-clients
y para los sensores
sudo apt-get install lm-sensors
sudo sensors-detect

I vemos que sensores hay
sudo sensors -u
vamos al folder del usario
cd /home/user
creamos el file
sudo vi sendtemp.sh
añdimos

#!/bin/bash
c1=`sensors -u *-isa-* | grep "temp2_input:" | awk '{printf "%.0f", $2}'`
/usr/bin/mosquitto_pub -h "192.168.1.209" -u Login -P MyPassword -t "pccpu/inteli5c1" -m "${c1}"
c1=`sensors -u *-isa-* | grep "temp3_input:" | awk '{printf "%.0f", $2}'`
/usr/bin/mosquitto_pub -h "192.168.1.209" -u Login -P MyPassword -t "pccpu/inteli5c2" -m "${c1}"
c1=`sensors -u *-isa-* | grep "temp4_input:" | awk '{printf "%.0f", $2}'`
/usr/bin/mosquitto_pub -h "192.168.1.209" -u Login -P MyPassword -t "pccpu/inteli5c3" -m "${c1}"
c1=`sensors -u *-isa-* | grep "temp5_input:" | awk '{printf "%.0f", $2}'`
/usr/bin/mosquitto_pub -h "192.168.1.209" -u Login -P MyPassword -t "pccpu/inteli5c4" -m "${c1}"

lo hacemos ejecutivo
sudo chmod +x sendtemp.sh
y añdimos al cron
sudo crontab -e
linea

* * * * * sh /home/user/sendtemp.sh

Y funciona!


Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *