Hi, I have a problam similar to a former question.
Raspberry has your flow an works well. The ESP8266 has your sketch. The connection to the broker is established, see below from the serial monitor:
Connected to Wi-Fi.Connecting to MQTT…
Connected to MQTT.
Session present: 0Subscribing at QoS 2, packetId: 1
Publishing at QoS 0Publishing at QoS 1,
packetId: 2Publishing at QoS 2,
packetId: 3Publishing on topic counter at QoS 1,
packetId: 4Subscribe acknowledged.packetId: 1qos: 2
Publish acknowledged.
packetId: 2
Publish acknowledged.
But the dashboard only shows:
Test
switch
text
chart
nothing else. Everything is empty, the switch does not work.
Regards, Hajo.
Hi.
It seems that Node-RED is not establishing a connection with the broker.
Open the debug window in Node-RED after deploying the flow and see if you get any error messages.
Did you edit the MQTT nodes with your own broker details? You need to insert the MQTT broker username and password and make sure that you set the right IP address (if you’ve followed the eBook as it is, it should be localhost).
Let me know if this helps.
Regards,
Sara
Hi Sara,
Node-Red establishes the connection to the broker very well, testet with former flows (led on/off from Windows Browser). No error messages in Node-Red. The broker details are correct, username, password, IP address as 192.168….
Regards, Hajo.
That’s weird because on the Serial Monitor results you showed, it seems that the board is successfully publishing to the broker.
And if the connection with the broker on Node-RED is successful, it should have received the messages.
Did you change anything on the code?
Are you sure you’re using the correct topics on both sides? Taking into account that the other things are working correctly, the only issue can be related to the topics….
Also, make sure you Deploy your Node-RED flow every time you make a change (it happened to me before forgetting to Deploy and then not having the expected results).
Regards,
Sara
Hi Sara, no, I haven't changed anything in the code. I have already compared the topics on both sites. Yes, I didn't forget to deploy and also looked at it in node-red debug afterwards - nothing. Do you have any tips for me?
Regards, Hajo.
Can you share a screenshot of your Node-RED MQTT nodes?
To share a picture, you’ll need to upload it to Imgur, Google Drive, or dropbox, for example, and then share a link to the file.
Regards,
Sara
Hi Sara,
I think that’s not necessary.
The picture is exactly that from page 172, all settings are as in the ebook (checked). The flow is deployed.
On the other side of the ESP, your Arduino sketch is unchanged. Tested with an ESP8266 and a D1mini. In the result from page 175 there is only the switch, no value for “text” and no graphics.
The debug field in Node-Red shows no errors. The communication between Node-Red and broker works, the test on page 119 ran flawlessly from an external browser.
What can I do, where are my mistakes, what can I test, what information do you need?
Regards, Hajo.
Hi.
Everything seems to be working as expected. So, it’s very difficult to find where the problem is.
First, reboot your Raspberry Pi.
sudo reboot
Then, try to subscribe to the topics the ESP32 is publishing in via the Raspberry Pi terminal, as explained on page 109.
I also recommend running the following command to subscribe to all topics and see if you get the ESP32 board messages:
mosquitto_sub -d -t "#" -u YOUR_USERNAME -P YOUR_PASSWORD
Let me know the results.
Regards,
Sara
Hi Sara,
$ mosquitto_sub -d -t ‘#’ -u user -P pass
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending SUBSCRIBE (Mid: 1, Topic: #, QoS: 0, Options: 0x00)
Client (null) received SUBACK
Subscribed (mid: 1): 0
Client (null) received PUBLISH (d0, q0, r1, m0, ‘test’, … (6 bytes))
test 3
Client (null) received PUBLISH (d0, q0, r1, m0, ‘counter’, … (2 bytes))
15
Client (null) received PUBLISH (d0, q0, r0, m0, ‘test’, … (6 bytes))
test 1
Client (null) received PUBLISH (d0, q0, r0, m0, ‘test’, … (6 bytes))
test 2
Client (null) received PUBLISH (d0, q0, r0, m0, ‘test’, … (6 bytes))
test 3
Client (null) received PUBLISH (d0, q0, r0, m0, ‘counter’, … (2 bytes))
10
Client (null) received PUBLISH (d0, q0, r0, m0, ‘counter’, … (2 bytes))
12
^CClient (null) sending DISCONNECT
Does this help? Thank you really much for your help.
Regards, Hajo.
As you can see the broker is receiving the ESP32 messages.
So, Node-RED should have received them too.
Now, on Node-RED click the switch to control the LED and see what you get on the Terminal, after running the same command (this is to make sure that the broker is receiving Node-RED messages):
mosquitto_sub -d -t ‘#’ -u user -P pass
Regards,
Sara
Hi Sara,
the result is the same as in the above log. No new message, when I use the switch
Regards, Hajo.
Hi.
So, it seems there is a problem on the Node-RED side.
The messages are not reaching the broker.
Again, can you show me a printscreen of your Node-RED MQTT nodes? Maybe you’re missing something there…
Regards,
Sara
Hi Sara,
ok, I’m a difficult customer… 🙂
For the Raspberry I downloaded your code from the link on page 169 in the ebook and didn’t change anything. The result is exactly the image on page 172.
For the ESP8266 I used the code from your link on page 149, no changes. The Arduino IDE 1.8.13 runs on another Raspberry under Buster.
I don’t think it’s necessary to upload the screenshot as it looks exactly like yours in the ebook. By the way: I don’t want to use services like Google Drive, Imgur or Dropbox. I get trashed with emails from dropbox since the first try. I don’t like any of these services. I can email everything to you, if needed.
But I don’t get the result you described on page 175. I only see “Test”, “switch” with the switch icon, “text” with no value and “chart” but no chart.
What can I do now? If you don’t have any advice for me, I’ll have to give up the whole project, unfortunately. 🙁
Thank you for your great help.
Regards, Hajo.
(All errors in this text are from Google Translator. English is not my first language and I didn’t want to make too many mistakes 🙂
Hi.
I’ll send you an email.
You have two registered emails with us. So, I’ll send a message to both of your emails.
Regards,
Sara
HI,
it doesn’t get better. Following your advice, I reinstalled the entire system. Completely reinstalled Raspian (buster), access via SSH and VNC. Installed on it line by line according to the SmartHome book: Node-Red, broker. All tests according to the book went flawlessly. The small flow with the LED worked perfectly.
Then downloaded your flow, checked every detail. Downloaded, compiled and uploaded the Arduino code for the 8266. The result in the browser: no text, no graphics, only headings. The switch does nothing at all. Tested with different raspberry-pi4, with different 8266, with different browsers from windows and from another raspberry 4b. The serial monitor in the arduino ide shows normal behavior, connection to the broker, sending the data. The data arrives at the broker, tested with your proposal.
What else can I do to solve the problem? What’s wrong – my Raspberry Pi 4B? my ESP8266? my arduino ide? your book? I compared all topics on the Raspi and in the arduino ide, everything is correct. I checked the IP addresses, username and password. Everything is ok. But the result is not what is shown in your book, it is unusable. What can I do besides dismantle everything, throw away the book and forget the whole thing? It’s really frustrating. Can you please help?
Regards, Hajo.
Hi.
What is the operating system you are running? Raspbian buster?
That’s not the operating system we recommend.
We recommend Raspberry Pi OS 64-bit. Everything was tested on that operating system.
As I mentioned in my last email, please follow all instructions step by step, including the installation of the operating system.
I don’t know if there are any incompatibilities with other systems,
Regards,
Sara