Additional info – the mqtt in and out on the node-red flow edit only show connecting – I initially created my own flow, but when it did not work I copied your flow and when it didn’t work either I made some minor (I hope) changes.
BUT I have something broken somewhere – please give me some debug ideas.
It does not help that I have had many interruptions for other work, but I have only gotten as far as module 5.2 and can not get past this section.
I have tried both an ESP8266 and an ESP32-CAM, but either I do not understand what I am supposed to see or I have broken something.
The problem is two fold:
1. The Ui shows what appears to be a working switch – on/off works visually. But both the text and counter only show the labels – no text or counts.
2. The serial monitor shows the counter code working – I get continuous periodic count events – so I commented out that code in the sketch temporarily so I could better debug the LED.
The LED code does not seem to work – I thought it was my 8266 so I switched to an ESP32-CAM I have, it still does not switch, I loaded Rui’s ESP32 Blink code and it worked fine, so I moved that code snip to the ESP32-CAM sketch, but nothing changed.
Switching the LED in the UI does not do anything on the serial monitor.
I could use some suggestions. I have cut and pasted the serial output (counter code commented out in the Sketch) – NOTE that this output is all I get even with repeated LED switches in the UI.
The JSON code is below the output.
Let me know if you need more info
07:45:52.810 -> Connecting to Wi-Fi...
07:45:52.844 -> [WiFi-event] event: 0
07:45:52.924 -> [WiFi-event] event: 2
07:45:53.006 -> [WiFi-event] event: 4
07:45:54.244 -> [WiFi-event] event: 7
07:45:54.244 -> WiFi connected
07:45:54.244 -> IP address:
07:45:54.244 -> 192.168.1.133
07:45:54.278 -> Connecting to MQTT...
07:45:54.309 -> Connected to MQTT.
07:45:54.309 -> Session present: 0
07:45:54.309 -> Subscribing at QoS 2, packetId: 1
07:45:54.309 -> Publishing at QoS 0
07:45:54.309 -> Publishing at QoS 1, packetId: 2
07:45:54.309 -> Publishing at QoS 2, packetId: 3
07:45:54.309 -> Subscribe acknowledged.
07:45:54.309 -> packetId: 1
07:45:54.309 -> qos: 2
07:45:54.309 -> f
07:45:54.309 -> a
07:45:54.309 -> l
07:45:54.309 -> s
07:45:54.309 -> e
07:45:54.309 -> Publish received.
07:45:54.309 -> topic: led
07:45:54.309 -> qos: 2
07:45:54.309 -> dup: 0
07:45:54.309 -> retain: 1
07:45:54.309 -> len: 5
07:45:54.309 -> index: 0
07:45:54.309 -> total: 5
07:45:54.309 -> Publish acknowledged.
07:45:54.309 -> packetId: 2
07:45:54.512 -> Publish acknowledged.
07:45:54.512 -> packetId: 3
———————————————–
[
{
“id”: “7f5ee1b0eb26a43f”,
“type”: “tab”,
“label”: “Flow 1”,
“disabled”: false,
“info”: “”,
“env”: []
},
{
“id”: “619570c737aca161”,
“type”: “ui_base”,
“theme”: {
“name”: “theme-light”,
“lightTheme”: {
“default”: “#0094CE”,
“baseColor”: “#008040”,
“baseFont”: “Arial Black,Arial Black,Gadget,sans-serif”,
“edited”: true,
“reset”: false
},
“darkTheme”: {
“default”: “#097479”,
“baseColor”: “#097479”,
“baseFont”: “-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif”,
“edited”: false
},
“customTheme”: {
“name”: “Untitled Theme 1”,
“default”: “#4B7930”,
“baseColor”: “#4B7930”,
“baseFont”: “-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif”
},
“themeState”: {
“base-color”: {
“default”: “#0094CE”,
“value”: “#008040”,
“edited”: true
},
“page-titlebar-backgroundColor”: {
“value”: “#008040”,
“edited”: false
},
“page-backgroundColor”: {
“value”: “#fafafa”,
“edited”: false
},
“page-sidebar-backgroundColor”: {
“value”: “#333333”,
“edited”: false
},
“group-textColor”: {
“value”: “#00cc66”,
“edited”: false
},
“group-borderColor”: {
“value”: “#ffffff”,
“edited”: false
},
“group-backgroundColor”: {
“value”: “#ffffff”,
“edited”: false
},
“widget-textColor”: {
“value”: “#111111”,
“edited”: false
},
“widget-backgroundColor”: {
“value”: “#008040”,
“edited”: false
},
“widget-borderColor”: {
“value”: “#ffffff”,
“edited”: false
},
“base-font”: {
“value”: “Arial Black,Arial Black,Gadget,sans-serif”
}
},
“angularTheme”: {
“primary”: “indigo”,
“accents”: “blue”,
“warn”: “red”,
“background”: “grey”,
“palette”: “light”
}
},
“site”: {
“name”: “Home Office”,
“hideToolbar”: “false”,
“allowSwipe”: “true”,
“lockMenu”: “true”,
“allowTempTheme”: “false”,
“dateFormat”: “DD/MM/YYYY”,
“sizes”: {
“sx”: 48,
“sy”: 48,
“gx”: 6,
“gy”: 6,
“cx”: 6,
“cy”: 6,
“px”: 0,
“py”: 0
}
}
},
{
“id”: “9f9e276987b2fb1f”,
“type”: “mqtt-broker”,
“name”: “”,
“broker”: “localhost”,
“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”: “c91a80502be32821”,
“type”: “ui_group”,
“name”: “test”,
“tab”: “f17256504e488d77”,
“order”: 1,
“disp”: true,
“width”: “6”,
“collapse”: false,
“className”: “”
},
{
“id”: “f17256504e488d77”,
“type”: “ui_tab”,
“name”: “Home”,
“icon”: “dashboard”,
“disabled”: false,
“hidden”: false
},
{
“id”: “e488625c59b3303a”,
“type”: “mqtt in”,
“z”: “7f5ee1b0eb26a43f”,
“name”: “”,
“topic”: “test”,
“qos”: “2”,
“datatype”: “auto-detect”,
“broker”: “9f9e276987b2fb1f”,
“nl”: false,
“rap”: true,
“rh”: 0,
“inputs”: 0,
“x”: 410,
“y”: 440,
“wires”: [
[
“b2812a4bb3096345”
]
]
},
{
“id”: “3d9e45e6a54996fe”,
“type”: “mqtt in”,
“z”: “7f5ee1b0eb26a43f”,
“name”: “”,
“topic”: “counter”,
“qos”: “2”,
“datatype”: “auto-detect”,
“broker”: “9f9e276987b2fb1f”,
“nl”: false,
“rap”: true,
“rh”: 0,
“inputs”: 0,
“x”: 410,
“y”: 520,
“wires”: [
[
“ee8d4ed12a03d957”
]
]
},
{
“id”: “18b095ed8d679104”,
“type”: “mqtt out”,
“z”: “7f5ee1b0eb26a43f”,
“name”: “LED flash on ESP32-CAM”,
“topic”: “led”,
“qos”: “2”,
“retain”: “true”,
“respTopic”: “”,
“contentType”: “”,
“userProps”: “”,
“correl”: “”,
“expiry”: “”,
“broker”: “9f9e276987b2fb1f”,
“x”: 730,
“y”: 600,
“wires”: []
},
{
“id”: “fbd620dbef3e5355”,
“type”: “ui_switch”,
“z”: “7f5ee1b0eb26a43f”,
“name”: “”,
“label”: “FLASH LED On/Off”,
“tooltip”: “Controls Builtin_LED”,
“group”: “c91a80502be32821”,
“order”: 1,
“width”: 0,
“height”: 0,
“passthru”: true,
“decouple”: “false”,
“topic”: “topic”,
“topicType”: “msg”,
“style”: “”,
“onvalue”: “true”,
“onvalueType”: “bool”,
“onicon”: “”,
“oncolor”: “”,
“offvalue”: “false”,
“offvalueType”: “bool”,
“officon”: “”,
“offcolor”: “”,
“animate”: false,
“className”: “”,
“x”: 450,
“y”: 600,
“wires”: [
[
“18b095ed8d679104”
]
]
},
{
“id”: “ee8d4ed12a03d957”,
“type”: “ui_chart”,
“z”: “7f5ee1b0eb26a43f”,
“name”: “”,
“group”: “c91a80502be32821”,
“order”: 3,
“width”: “6”,
“height”: “5”,
“label”: “Counter Chart”,
“chartType”: “line”,
“legend”: “true”,
“xformat”: “auto”,
“interpolate”: “linear”,
“nodata”: “”,
“dot”: false,
“ymin”: “”,
“ymax”: “”,
“removeOlder”: 1,
“removeOlderPoints”: “”,
“removeOlderUnit”: “3600”,
“cutout”: 0,
“useOneColor”: false,
“useUTC”: false,
“colors”: [
“#1f77b4”,
“#aec7e8”,
“#ff7f0e”,
“#2ca02c”,
“#98df8a”,
“#d62728”,
“#ff9896”,
“#9467bd”,
“#c5b0d5”
],
“outputs”: 1,
“useDifferentColor”: false,
“className”: “”,
“x”: 700,
“y”: 520,
“wires”: [
[]
]
},
{
“id”: “b2812a4bb3096345”,
“type”: “ui_text”,
“z”: “7f5ee1b0eb26a43f”,
“group”: “c91a80502be32821”,
“order”: 2,
“width”: 0,
“height”: 0,
“name”: “”,
“label”: “Text = “,
“format”: “{{msg.payload}}”,
“layout”: “row-spread”,
“className”: “”,
“x”: 670,
“y”: 440,
“wires”: []
}
]
I am thinking about going back to a fresh raspberry pi load and start over at that point.
There were some odd messages about mqtt being reloaded on my putty output.
Although they might have been the result of something I did in node-red.
I did restart the flow. I don’t know what that might have done.
Hi.
If the MQTT node shows connecting, it means there’s something wrong with the connection to the broker on Node-RED.
When you upload the code to your boards, and if everything was set correctly with the broker, you should get something as shown on page 167 on your Serial Monitor.
1. It doesn’t show anything because the connection to the broker is not properly established on Node-RED, so it won’t receive the data.
The ESP boards are properly connected to the broker, that’s why you see the counter increasing. The LED doesn’t work because Node-RED is not communicating with the broker, so the ESP won’t receive the MQTT packets.
So, in summary, there is something wrong with the MQTT connecting on Node-RED. Double-check your MQTT nodes and that you have inserted the right information about your broker.
Regards,
Sara
Thanks Sara,
It turns out I was having several problems,
It turned out I had 3 different versions of the IDE which might have been causing some problems. I removed all of them and re-installed the current version 2.01 – that immediately got rid of some of my non-nodered/mqtt problems.
Then I went back over my node-red flow and discovered that I had NOT entered the mqtt security user and password! Now it seems to be working. I can proceed with the next section.
Thanks again