Strange behaviour with Thonny/standalone
Posted: Tue Sep 27, 2022 2:14 pm
Hi
I have some simple code running on a Pico W which does the following:
Establishes a Wifi connection to my network
Repeatedly takes temperatures from a sensor
Sends them to my MQTT broker
Flashes the onboard Pi Pico W LED each time it publishes.
I have a main.py programme, and several other libraries that are loaded (including umqtt.robust2)
If I plug the board into my USB port when Thonny is open, I can bring up the main.py file. If I then click the 'play' button, the code works perfectly:
I can see in my Mosquitto logs that a new connction has been made from the Pico. The pico connects to the broker, Temperatures are published and each time the LED flashes.
If however I close thonny, and then disconnect and reconnect the Pi Pico (i.e. in standalone mode), it still seems to boot, and flash the LED - implying it *thinks* it is publishing. If at this point I restart Thonny, I can see the publication message being printed over repl.
BUT nothing is actually published. There is no 'new connection' message in the Mosquitto log...
It *seems* as my code genuinely thinks it is connected, and is publishing, but it is not doing so...
The same thing happens if I just plug it into a battery pack (eliminating USB data connections entirely - just two power leads)
What could possibly account for this difference in behaviour in stand-alone mode?
Thanks!
I have some simple code running on a Pico W which does the following:
Establishes a Wifi connection to my network
Repeatedly takes temperatures from a sensor
Sends them to my MQTT broker
Flashes the onboard Pi Pico W LED each time it publishes.
I have a main.py programme, and several other libraries that are loaded (including umqtt.robust2)
If I plug the board into my USB port when Thonny is open, I can bring up the main.py file. If I then click the 'play' button, the code works perfectly:
I can see in my Mosquitto logs that a new connction has been made from the Pico. The pico connects to the broker, Temperatures are published and each time the LED flashes.
If however I close thonny, and then disconnect and reconnect the Pi Pico (i.e. in standalone mode), it still seems to boot, and flash the LED - implying it *thinks* it is publishing. If at this point I restart Thonny, I can see the publication message being printed over repl.
BUT nothing is actually published. There is no 'new connection' message in the Mosquitto log...
It *seems* as my code genuinely thinks it is connected, and is publishing, but it is not doing so...
The same thing happens if I just plug it into a battery pack (eliminating USB data connections entirely - just two power leads)
What could possibly account for this difference in behaviour in stand-alone mode?
Thanks!