main.py does not appear to working after boot

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
smith.randallscott
Posts: 32
Joined: Mon May 13, 2019 12:42 pm

main.py does not appear to working after boot

Post by smith.randallscott » Wed Jul 10, 2019 9:03 pm

I am using a raspberry pi as a program platform, connecting to ESP32 using rshell. When I connect to the ESP and enter the REPL and perform a soft reboot, all seems to work properly. However if I exit the REPL and reboot the Pi (thinking that this should also reboot the ESP) main.py does not seem to execute. The way I am checking for operation is a counter in main.py that updates every 5 seconds and publishes to a MQTT topic. When I'm in the REPL I can see these updates, but not after I exit the REPL. --Any thoughts?

rpr
Posts: 99
Joined: Sat Oct 27, 2018 5:17 pm

Re: main.py does not appear to working after boot

Post by rpr » Wed Jul 10, 2019 9:22 pm

Have you tried 1) power cycling the ESP32 directly or 2) tried to power down the Pi and restart as opposed to reboot? Maybe the reboot of the Pi is not disconnecting the power to the USB?

smith.randallscott
Posts: 32
Joined: Mon May 13, 2019 12:42 pm

Re: main.py does not appear to working after boot

Post by smith.randallscott » Wed Jul 10, 2019 9:27 pm

I have not tried that yet. I'm trying to work remotely, but will certainly try that soon

smith.randallscott
Posts: 32
Joined: Mon May 13, 2019 12:42 pm

Re: main.py does not appear to working after boot

Post by smith.randallscott » Thu Jul 11, 2019 10:52 am

After a physical power cycle, main.py doesn't seem to be running. Can anyone offer troubleshooting tips? My normal process would be to establish a connection through rshell and perform a soft reboot in the REPL, but that wouldn't replicated the problem.

rpr
Posts: 99
Joined: Sat Oct 27, 2018 5:17 pm

Re: main.py does not appear to working after boot

Post by rpr » Thu Jul 11, 2019 1:37 pm

Have you tried a hard reboot when connected via rshell either pressing the button on the esp32 or doing a machine.reset()?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: main.py does not appear to working after boot

Post by pythoncoder » Thu Jul 11, 2019 3:22 pm

@smith.randallscott For your test to pass, several things have to happen correctly and in sequence.
  • main.py has to run
  • The ESP32 has to connect to the WiFi network, waiting until the connection is successful.
  • It then has to connect to the broker, again waiting for success.
  • Finally it has to make a successful publication
The fact that at least one of those steps has failed doesn't prove that the first has failed.

I would suggest a simpler test. Temporarily replace main.py with one which does something really simple, like print to the REPL or toggle a pin every few seconds. Then at least you'll know the status of item 1.
Peter Hinch
Index to my micropython libraries.

smith.randallscott
Posts: 32
Joined: Mon May 13, 2019 12:42 pm

Re: main.py does not appear to working after boot

Post by smith.randallscott » Thu Jul 11, 2019 5:14 pm

Looks like I will have to install some LEDs. When I enter the REPL from rshell and issue machine.reset() all seems to work, but if I simply cycle power it doesn't seem to work. very odd. Time for a few different colored LEDs

User avatar
Frida
Posts: 45
Joined: Sat Jan 30, 2016 2:20 pm
Location: Middelfart, Denmark

Re: main.py does not appear to working after boot

Post by Frida » Fri Jul 12, 2019 9:20 am

I have some ESP32 PICO and they always have a reset after power on, before I can communicate with them.
But my NODEMCU ESP8266 has no problems.
Yes Frida is my watchdog!

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: main.py does not appear to working after boot

Post by Roberthh » Fri Jul 12, 2019 12:31 pm

It may depend from the terminal emulator. Picocom switches by default the modem control lined in a way that is seen by the esressif kind if bott loader enabling as reset. You can disable that with calling options

smith.randallscott
Posts: 32
Joined: Mon May 13, 2019 12:42 pm

Re: main.py does not appear to working after boot

Post by smith.randallscott » Fri Jul 12, 2019 1:02 pm

No luck getting the led to energize, on boot. I am baffled because the code works each time I connect remotely from a windows 7 machine to the RaspberryPi using MobaXterm, then connect to the ESP32 using rshell everything works perfectly. When I initially connect I only have a blank RELP >>>, at this point I can either perform a soft reboot ctrl+d, or hard reboot machine.reboot(). All the print statements are executed as expected. I can also see data being sent to MQTT. However when I cycle power I see no change in the MQTT data (the only indication I have without viewing the REPL.

Post Reply