main.py doesn't auto start #10591
Replies: 4 comments 3 replies
-
Delete main.py, save this script with a different name and import it on the REPL terminal. It can print error messages that could explain why it is not working. You can later create a main.py with the import script_name on it. |
Beta Was this translation helpful? Give feedback.
-
@cve2022 I copied the code to the REPL, wasn't sure if I imported it right as you mentioned, I copied the main.py code, renamed the file, then pasted the code into the REPL, it worked fine no errors. It was also printing out the block of comments in the def get_heading(hires): function but I put a # in front of each line and that stopped it from printing in the REPL. It does display a bold blue "1", I'm not sure where that's coming from but it doesn't seem to be an issue. I then copied that back to a main.py file, ran it then unplugged it, plugged it back in and it doesn't start until I press F5. I would think if there was a code problem I would get an error when pressing F5 as I have made some code errors and it did. I fairly new at using micropython. Thanks both for your comments |
Beta Was this translation helpful? Give feedback.
-
I have determined it has something to do with the "get_heading(hires)" function. I commented out line 48 "head = get_heading(True)" and had to comment out a couple of print lines that use "head" but then it works, both with removing and plugging the USB cable back in and with a battery I have connected to VSYS. Leaving the print statements commented if I just uncomment the call to get_heading, line 48, then it doesn't work. |
Beta Was this translation helpful? Give feedback.
-
Good point @robert-hh, I'll remember that for future projects. But I'm still having the autorun issue when I call get_heading. Thanks |
Beta Was this translation helpful? Give feedback.
-
I have a pico with a OLED display, a BME280 temp sensor and a CMPS12 compass module. The program name is main.py and I'm using Thonny. I have the temp, humidity, pressure and compass heading displaying on the display. I first had just the temp, humidity and pressure when I unplug the USB cable then plug it back in the code would run. After I added the code for the compass it does not auto start. I have to reconnect to the pico and press F5. It wouldn't start by pressing the reset on the pico either. I loaded the first program I had back in and that works. What is wrong with this program?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions