Autorun my main file

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
PedroJuan
Posts: 4
Joined: Mon Mar 22, 2021 2:36 pm

Autorun my main file

Post by PedroJuan » Mon Mar 22, 2021 2:44 pm

Hi everyone,

That's my first topic on the forum.

I've been looking everywhere on the web how to autorun my main file on my ESP32 board.
I can't do that and that's a problem for the project I'm trying to do.

I try to call my main file in my boot file but that never works...

That's why I'm looking for your help...
If you have a solution please help me...

Thanks in advance.

Have a nice day.

User avatar
CmdrDeLiver
Posts: 27
Joined: Thu Dec 05, 2019 6:30 pm

Re: Autorun my main file

Post by CmdrDeLiver » Tue Mar 23, 2021 1:49 pm

Hi PedroJuan.
PedroJuan wrote:
Mon Mar 22, 2021 2:44 pm
I try to call my main file in my boot file but that never works...
You don't need to call main.py. That will be done for you once boot.py finishes.
boot.py: runs when the device starts and sets up several configuration options;
main.py: this is the main script that contains your code. It is executed immediately after the boot.py.
You might try debugging your boot.py and main.py files.

Code: Select all

print("boot.py finished") #at the very end of boot.py
print("main.py started") #as the first line of main.py
The times when main.py hasn't loaded for me, I've found problems in boot.py. ;)

Best of luck,

Mike

PedroJuan
Posts: 4
Joined: Mon Mar 22, 2021 2:36 pm

Re: Autorun my main file

Post by PedroJuan » Tue Mar 23, 2021 2:09 pm

hi CmdrDeliver

First of all thanks a lot for your answer.
I'll try to do that and see what's comming. At least I'll know if there is a problem in my boot.py.

However sometimes when I run my programme even when there is nothing in my boot.py the main.py doesn't run automaticaly.
I'll tell you when I'll try again ;)

Have a nice day.

Pierre

PedroJuan
Posts: 4
Joined: Mon Mar 22, 2021 2:36 pm

Re: Autorun my main file

Post by PedroJuan » Thu Mar 25, 2021 9:34 am

Then I come back to you,

My problem is still the same. I'll explain my project :

I try to use an esp32 for a project (I'm using wipy3.0). And in this project I want that my esp32 run the program immediatly when it gets power. However, for now, when I put power on my esp32 nothing happens, I'm pretty sure that the file boot.py doesn't run and that's a big problem for me...

Can someone help me?

Thanks in advance

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Autorun my main file

Post by davef » Thu Mar 25, 2021 6:23 pm

Describe how you program the device and get to run properly before removing the programmer and power.

Maybe, the board is not in the correct boot mode.

If you apply power can you get it to run after hitting the boot button?

What are you powering the device with and how is the power applied? Mechanical switch, electronic switch or by manual connection?

PedroJuan
Posts: 4
Joined: Mon Mar 22, 2021 2:36 pm

Re: Autorun my main file

Post by PedroJuan » Tue Apr 06, 2021 2:33 pm

Hi,

I have no idea how it worked but my program finnaly autorun when I boot upload the project directly on my board.
I didn't really changed it but I think that's because only this project was open contrary to last week...

Thanks to the ones who tried to help me!

Pedro

Post Reply