ESP8266: instead of main.py start from REPL an script

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
BigMan
Posts: 22
Joined: Sat Oct 29, 2016 2:29 pm

ESP8266: instead of main.py start from REPL an script

Post by BigMan » Sat Jun 29, 2019 11:32 am

Hi,

I do a lot of try-and-error coding. Means I write a main.py and flash it on the ESP8266 with ampy. The issue is: after rebooting the ESP8266, the main.py may be started but I cannot see any error messages while main.py is executed.
It would be much better, if I access with picocom the REPL first and start from there the main.py.

My first attempt was to rename the main.py, so it doesn't get started automatically. Then I logged into the REPL with picocom, loaded os and tried os.system("main_new_name.py") ... well but os.system isn't available in µPython.

Anyhow: what is the correct approach to test µPyhton-Skripts on the ESP8266, in a way I can see in a terminal all the errors?

In advance: thanks for all your support

(Note: already searched the forum for similar issues, e.g. with the term "execute scripts" but found nothing appropriate)

User avatar
jimmo
Posts: 409
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: ESP8266: instead of main.py start from REPL an script

Post by jimmo » Sat Jun 29, 2019 11:47 am

Hi,

If you put your code in foo.py, then on the repl run "import foo", you should get what you want.

Also you can use Ctrl-D to soft-reset.

User avatar
Kip
Posts: 19
Joined: Sat Dec 26, 2015 7:23 am

Re: ESP8266: instead of main.py start from REPL an script

Post by Kip » Sat Jun 29, 2019 11:49 am

I recently got the ESP8266 and had a play around. I made a "note to self" of my workflow. Check it out: https://github.com/KipCrossing/ESP2866-MicroPython

I put my code in a different file just in case my main.py file got corrupted. It seems difficult to remove corrupted files.




Christian Walther
Posts: 52
Joined: Fri Aug 19, 2016 11:55 am

Re: ESP8266: instead of main.py start from REPL an script

Post by Christian Walther » Sat Jun 29, 2019 12:53 pm

BigMan wrote:
Sat Jun 29, 2019 11:32 am
the main.py may be started but I cannot see any error messages while main.py is executed.
There must be something wrong here. You should see error messages or anything else printed to stdout on the serial output while main.py is running.

BigMan
Posts: 22
Joined: Sat Oct 29, 2016 2:29 pm

Re: ESP8266: instead of main.py start from REPL an script

Post by BigMan » Sat Jun 29, 2019 2:24 pm

Christian Walther wrote:
Sat Jun 29, 2019 12:53 pm
BigMan wrote:
Sat Jun 29, 2019 11:32 am
the main.py may be started but I cannot see any error messages while main.py is executed.
There must be something wrong here. You should see error messages or anything else printed to stdout on the serial output while main.py is running.
main.py will be executed automatically when the ESP8266 is powered on. Many messages will be generated long before I am able to login with picocom.

BigMan
Posts: 22
Joined: Sat Oct 29, 2016 2:29 pm

Re: ESP8266: instead of main.py start from REPL an script

Post by BigMan » Sat Jun 29, 2019 2:24 pm

jimmo wrote:
Sat Jun 29, 2019 11:47 am
Hi,

If you put your code in foo.py, then on the repl run "import foo", you should get what you want.

Also you can use Ctrl-D to soft-reset.
import foo.py <- that the solution and works! Thanks!!!

Post Reply