Hi everyone. Following the course here, I have a few ESP8266’s running micropython and MQTT to take sensor readings and turn a relay on/off. The sensor readings work great but I’m having an issue with the relay because the clients keep randomly losing connection with the broker (mosquitto on RPi).
When the client loses connection, it reconnects very quickly so doesn’t really impact the sensor readings but it switches the relay off. These disconnects happen frequently and seem to occur anywhere between a few seconds and several minutes after booting.
Apologies but this is a duplicate message but the original is showing as closed and I couldn’t reopen it.
Serial output below:
g... Failed to connect to MQTT broker. Reconnecting... ets Jan 8 2013,rst cause:2, boot mode:(3,6) load 0x40100000, len 31088, room 16 tail 0 chksum 0x44 load 0x3ffe8000, len 1028, room 8 tail 12 chksum 0x1e ho 0 tail 12 room 4 load 0x3ffe8410, len 824, room 12 tail 12 chksum 0x89 csum 0x89 ���Connection successful ('10.224.60.165', '255.255.255.0', '10.224.60.1', '10.224.100.1') Connected to 10.224.60.18 MQTT broker, subscribed to b'test1' topic machine ID is b'dd62cd00'
Hi.
What pin are you using to connect the relay? And what configuration? Normally-closed or normally-open?
Regards,
Sara
Hi Sara
Many thanks for your reply. I’m using relay shields on D1 mini’s which use pin 5. I have about a dozen of them which were previously running your micropython web server for about a year (flawlessly, thank you!). I’ve spent quiet a bit of time debugging this today and it seems to be pointing to some kind of corruption when re-flashing the boards. When I initially did the first one, I only tested it for a couple of minutes before flashing them all – lesson learnt! Today I’ve re-flashed 5 of the boards and they’ve all been stable for a few hours, so I’m hopeful that it’s sorted.
Thanks for all your work on this site – it’s great.
Jason