5. Recibe los datos del ESP en NodeRED con MQTT
La cosa ya se empieza a complicar...
TODO
- Explica MQTT
- Instalar plugin NodeRED dashboard
Tipo |
Descripción | Unidades | Topic MQTT |
Sensor | Lectura sensor temperatura DHT11 | ºC | taller/tXX/sens/DHT11/temp |
Sensor | Lectura sensor humedad relativa DHT11 | %rh | taller/tXX/sens/DHT11/hum |
Sensor | Lectura sensor luminosidad LDR | Volts | taller/tXX/sens/LDR |
Actuador LED | Indicador LED Verde | taller/tXX/leds/verde | |
Actuador LED | Indicador LED Rojo | taller/tXX/leds/rojo |
NOTA: tXX será tu número de equipo. Es decir, en caso de que sea es el equipo número uno (equipo 1) deberás publicar los datos de temperatura en el topic taller/t01/sens/DHT11/temp
Solución [No abrir, no seas tramposo]
[
{
"id": "5778ea97cd1ed074",
"type": "tab",
"label": "ESP8266",
"disabled": false,
"info": "Solución ejercicio visualización sensores y actuadores ESP8266",
"env": []
},
{
"id": "02973140566ef55c",
"type": "mqtt in",
"z": "5778ea97cd1ed074",
"name": "DHT11 Temperatura",
"topic": "taller/t00/sens/DHT11/temp",
"qos": "2",
"datatype": "auto-detect",
"broker": "b5bdeb4155381a5d",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 450,
"y": 160,
"wires": [
[
"7aa944fea3c07822"
]
]
},
{
"id": "609bc96d69db82e8",
"type": "mqtt in",
"z": "5778ea97cd1ed074",
"name": "DHT11 Humedad",
"topic": "taller/t00/sens/DHT11/hum",
"qos": "2",
"datatype": "auto-detect",
"broker": "b5bdeb4155381a5d",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 440,
"y": 220,
"wires": [
[
"9e44099297dcc3a5"
]
]
},
{
"id": "e0f0357e049277d2",
"type": "mqtt in",
"z": "5778ea97cd1ed074",
"name": "LDR Luminosidad",
"topic": "taller/t00/sens/LDR",
"qos": "2",
"datatype": "auto-detect",
"broker": "b5bdeb4155381a5d",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 450,
"y": 280,
"wires": [
[
"280c63846cb13519"
]
]
},
{
"id": "d34f1d5a1ba21375",
"type": "mqtt out",
"z": "5778ea97cd1ed074",
"name": "LED Verde",
"topic": "taller/t00/leds/verde",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "b5bdeb4155381a5d",
"x": 830,
"y": 400,
"wires": []
},
{
"id": "971b18f52f42468f",
"type": "mqtt out",
"z": "5778ea97cd1ed074",
"name": "LED Rojo",
"topic": "taller/t00/leds/rojo",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "b5bdeb4155381a5d",
"x": 820,
"y": 460,
"wires": []
},
{
"id": "7aa944fea3c07822",
"type": "ui_gauge",
"z": "5778ea97cd1ed074",
"name": "Temperatura",
"group": "3de4d1022cadb73f",
"order": 0,
"width": "6",
"height": "3",
"gtype": "gage",
"title": "Temperatura",
"label": "ºC",
"format": "{{value}}",
"min": "-10",
"max": "40",
"colors": [
"#00b3b0",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 930,
"y": 160,
"wires": []
},
{
"id": "9e44099297dcc3a5",
"type": "ui_gauge",
"z": "5778ea97cd1ed074",
"name": "Humedad",
"group": "3de4d1022cadb73f",
"order": 1,
"width": "6",
"height": "3",
"gtype": "gage",
"title": "Humedad",
"label": "%RH",
"format": "{{value}}",
"min": 0,
"max": "100",
"colors": [
"#1500b3",
"#cbe600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 920,
"y": 220,
"wires": []
},
{
"id": "280c63846cb13519",
"type": "ui_gauge",
"z": "5778ea97cd1ed074",
"name": "Luminosidad",
"group": "3de4d1022cadb73f",
"order": 2,
"width": "6",
"height": "3",
"gtype": "gage",
"title": "Luminosidad",
"label": "units",
"format": "{{value}}",
"min": 0,
"max": "1000",
"colors": [
"#000000",
"#e6e600",
"#ffffff"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 930,
"y": 280,
"wires": []
},
{
"id": "34e6bf482f2f4e81",
"type": "ui_switch",
"z": "5778ea97cd1ed074",
"name": "LED Verde",
"label": "LED Verde",
"tooltip": "",
"group": "71d9266564131fe1",
"order": 0,
"width": "4",
"height": "2",
"passthru": false,
"decouple": "false",
"topic": "topic",
"topicType": "msg",
"style": "",
"onvalue": "1",
"onvalueType": "num",
"onicon": "",
"oncolor": "",
"offvalue": "0",
"offvalueType": "num",
"officon": "",
"offcolor": "",
"animate": true,
"className": "",
"x": 510,
"y": 400,
"wires": [
[
"d34f1d5a1ba21375"
]
]
},
{
"id": "6a9f570b1bcbf20c",
"type": "ui_switch",
"z": "5778ea97cd1ed074",
"name": "LED Rojo",
"label": "LED Rojo",
"tooltip": "",
"group": "71d9266564131fe1",
"order": 1,
"width": "4",
"height": "2",
"passthru": true,
"decouple": "false",
"topic": "topic",
"topicType": "msg",
"style": "",
"onvalue": "1",
"onvalueType": "num",
"onicon": "",
"oncolor": "",
"offvalue": "0",
"offvalueType": "num",
"officon": "",
"offcolor": "",
"animate": false,
"className": "",
"x": 500,
"y": 460,
"wires": [
[
"971b18f52f42468f"
]
]
},
{
"id": "b5bdeb4155381a5d",
"type": "mqtt-broker",
"name": "Broker MakersUPV",
"broker": "mqtt.makersupv.com",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "3de4d1022cadb73f",
"type": "ui_group",
"name": "Sensores",
"tab": "be3445ce783f56f1",
"order": 1,
"disp": true,
"width": "12",
"collapse": false,
"className": ""
},
{
"id": "71d9266564131fe1",
"type": "ui_group",
"name": "Actuadores",
"tab": "be3445ce783f56f1",
"order": 2,
"disp": true,
"width": "12",
"collapse": false,
"className": ""
},
{
"id": "be3445ce783f56f1",
"type": "ui_tab",
"name": "ESP8266",
"icon": "fa-thermometer-half",
"disabled": false,
"hidden": false
}
]
X. Ejercicio extra para los más valientes [OPCIONAL]
¿Te através a cambiar la luminosidad de los leds mediante el nodo Slider de la UI?
Esta vez sin pistas... y sin solución!