Page 1 of 6

main.py does not appear to working after boot

Posted: Wed Jul 10, 2019 9:03 pm
by smith.randallscott
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?

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

Posted: Wed Jul 10, 2019 9:22 pm
by rpr
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?

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

Posted: Wed Jul 10, 2019 9:27 pm
by smith.randallscott
I have not tried that yet. I'm trying to work remotely, but will certainly try that soon

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

Posted: Thu Jul 11, 2019 10:52 am
by smith.randallscott
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.

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

Posted: Thu Jul 11, 2019 1:37 pm
by rpr
Have you tried a hard reboot when connected via rshell either pressing the button on the esp32 or doing a machine.reset()?

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

Posted: Thu Jul 11, 2019 3:22 pm
by pythoncoder
@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.

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

Posted: Thu Jul 11, 2019 5:14 pm
by smith.randallscott
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

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

Posted: Fri Jul 12, 2019 9:20 am
by Frida
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.

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

Posted: Fri Jul 12, 2019 12:31 pm
by Roberthh
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

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

Posted: Fri Jul 12, 2019 1:02 pm
by smith.randallscott
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.