Hi Sara,
Working with SmartHome v1.3 (version doesn’t matter) Module 5, the MQTT IPAddress format is (XXX, XXX, X, XXX). However my network IP address range is XXX, XXX, XX, XXX. If I use 192, 168, 50, XXX it defaults to 192, 168, 50, 153 according to the IDE monitor screen when I run the programmed ESP32 module. It keeps this address no matter what value of 50, XXX I use in the sketch.
How can I fix this; I assume it’s the way the address is parsed and not accounting for anything other than a single digit X.
Thanks,
Leo
Please ignore; further checking showed the monitor is howing the wifi address of the esp32 module, not the MQTT broker. Sorry.
Late addition;
The reason for winding up in this false path was that the test of the uploaded sketch showed the ESP was not connecting to the MQTT broker. I eventually suspected it was that perhaps the authorisation was not working.
After triple checking the broker uid/psw that it was correctly entered, on a hunch and in desperation I decided to delete the existing entry and retype it anew (even though it looked perfectly good). To my surprise after uploading the change the test sprung into life as it should. Don’t ask me why – but perhaps it’s a suggestion should anyone else find themself in this situation.
Yes thanks Sara. All good, all working as expected.
Just for others in case they wind up in a similar situation, here is a sample of what gets sent to the monitor when the connection fails;
Connecting to Wi-Fi...
[WiFi-event] event: 0
[WiFi-event] event: 2
[WiFi-event] event: 4
[WiFi-event] event: 7
WiFi connected
IP address:
192.168.50.153
Connecting to MQTT...
Publishing on topic counter at QoS 1, packetId: 0Publishing on topic counter at QoS 1, packetId: 0Publishing on topic counter at QoS 1, packetId: 0Disconnected from MQTT.
Connecting to MQTT...
Publishing on topic counter at QoS 1, packetId: 0Publishing on topic counter at QoS 1, packetId: 0Publishing on topic counter at QoS 1, packetId: 0Disconnected from MQTT.
Connecting to MQTT...
Publishing on topic counter at QoS 1, packetId: 0Publishing on topic counter at QoS 1, packetId: 0
They obvious key is it never says “Connected to MQTT”.
Thanks again and please close Sara.
PS: It’s a great course as all the others.
But, it seems it’s constantly connecting and disconnecting…
Do you receive the data via MQTT on the Node-RED application?
regards,
Sara
Hi Sara,
Just to make sure we’re on the same wavelength; the monitor printout above shows the failed condition prior to the re-entering of the Broker UID & PSW. As the monitor never indicates that it successfully connected by printing “connected to MQTT”. It was just spitting out “connecting to MQTT”. So I assumed it never did in fact connect to the MQTT Broker and was just continually trying to connect without success.
Once I applied the fix described above, the monitor showed the same flow as per the course documentation on page 194 including;
“Connecting to MQTT” followed imediately by “Connected to MQTT”.
I’ve not yet set up Node-Red to show MQTT data but the monitor is showing the Subscribed ACKs now indicating a successfull transfer. So I’m expecting once the Node-Red data view is set up it’ll be all go.
Regards,
Leo
Oh.
Great. I think I misunderstood.
I’m glad everything is working as expected now.
Regards,
Sara