After a number of hours trying to work out what I am doing wrong with this unit; I am stumped.
I have copied the code from github. The links below are as taken direct out of the ESP8266
The only difference being that I am using a fixed IP but that seems to work ok as I get the message in Thonny Shell:
Connected to 192.168.0.127 MQTT broker, subscribed to b’output’ topic
Found DS devices: [bytearray(b'(0\xff\x07\xd6\x01<\xad’)]
Temperatures:
17.5625 Valid temperature.
BUT
I am not seeing the (b’output, b’on) message in the Shell neither is the LED connected to D4 (pin 4*) switching on/off as I would expect – except at the outset
(* changed from pin2 to see if it made any difference)
Help please
regards
Steve
Code link:
https://www.dropbox.com/s/ajjrsmrm3b6wuva/Myboot.py?dl=0
https://www.dropbox.com/s/m9wk4wou9d598e6/Mymain.py?dl=0
Hello Steve, does your Node-RED MQTT topics in/out are with lower case letters?
- Is the MQTT out node publishing to the exact topic: output
- MQTT in node subscribed to: temp
According to that information, your MQTT broker is running fine and your ESP board is connected to it, I can only think it’s some configuration missing in Node-RED
Hello Rui
Thank you for responding.
Although my knowledge, I also have been thinking it could be something to do with a problem with Node-red. I jus don’t know enough to trouble-shoot this.
Last night I went back to the previous unit :
MQTT – Establishing a Two-way Communication – p231
And reloaded the code into the twi ESP8266’s
the Mosquitto broker works fine – publishing and subscribing the messages.
Next I thought I would try and get Node-red to respond to the published message.
BUT
I have not learnt enough about how set up an Node-red MQTTin
I know this is (or should be) very simple –
1/. drag ‘mgtt in’ into a flow.
2/. edit the settings for the node
And it should work –
but – what should those settings be?
Thanks
Steve
Hello Steve,
- Do you have Mosquitto MQTT broker installed in your Raspberry Pi, right?
- Did you import my exact flow to your Node-RED?
- Can you double-check that you’ve typed the correct IP address from your broker in MicroPython code?
Page 269: MQTT output node
You can see the default settings. If your MQTT broker is installed in your Raspberry Pi, you can have the server set as localhost and port 1883
Then you just need to definite the MQTT topic (in this case output), please note that topics are case-sensitive output is different from Output.
Hi Rui -see below:
- Do you have Mosquitto MQTT broker installed in your Raspberry Pi, right?
yes- it worked OK for the previous unit –
MQTT – Establishing a Two-way Communication- page 231 - Did you import my exact flow to your Node-RED?
Yes – No changes made - Can you double-check that you’ve typed the correct IP address from your broker in MicroPython code?
Yes – its the same IP as a for the previous unit.
MQTT – Establishing a Two-way Communication- page 231 - I am running Node-Red and Mosquitto in a Docker container.
Does this have any bearing on the IP address(s)?
The IP address for the Pi4 is 192.168.0.127 – this worked fine when I established communication.
BUT is there something I should be doing because both apps are communicating within that Docker Container.
Thanks
Steve
Thanks to
https://gist.github.com/Paraphraser/c9db25d131dd4c09848ffb353b69038f
I have found the answer. About 3 clicks down the page.
And
Yes the set-up IS different when one is using a both Node_Red and Mosquitto in the same Docker container.
Can I suggest you cover this in the book.
Regards
Steve