Program works with Thonny but crashes when run on Pico independently #11137
Replies: 6 comments 1 reply
-
I think you have to use REPL to run the code after disconnecting the Pico from computer and powering it again with an external power supply: https://www.youtube.com/watch?v=yzsEr2QCGPw |
Beta Was this translation helpful? Give feedback.
-
The error message does not correspond to current |
Beta Was this translation helpful? Give feedback.
-
The class IOWrite(SysCall1) exists is the Pycom variant of uascnyio, but at a different line number. So you may be right that this is an old version. |
Beta Was this translation helpful? Give feedback.
-
The following is a variation that occurs sometimes:
lines 40-42 are: if line != None and len(line) > 3:
value_str = line[2:-2].decode()
return value_str |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
The tracebacks indicate that your plant monitor is occasionally returning invalid data. I suggest you trap exceptions def request_property(self, cmd):
self.uart.write(cmd)
line = self.uart.readline()
value_str = 0 # Assume failure
if line != None and len(line) > 3:
try:
value_str = line[2:-2].decode()
except Exception:
pass
if not value_str:
print('Communication Problem with Plant Monitor. Check your wiring.')
return value_str |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I apologize ahead of time if this is the wrong place to be posting this. I was hoping that micropython experts could tell me what I am doing wrong.
I have a program that works as it should while I use Thonny, but when I run the Pico independently by plugging it into the wall, the program crashes.
When running the program from Thonny, the display looks like this:

When running independently, the display looks like this:

The main.py program is:
Looking back at the second picture (Pico running independently), the light sensor is read once and the response is displayed, and the pupils are drawn in their initial position, though they do not move. Thus, tasks 1 and 2 in the following have begun, but the program crashes after that:
I have a sleep statement at the very beginning of the program which gives the plant monitor sensor time to get started, so that isn't the problem.
I used a try/except structure to help me find the problem.
It writes "Error!" when there is an exception, but more importantly, that error is written to a log file. This is the entry into the log file:
File "uasyncio/core.py", line 1, in run line 218
This is uasyncio/core.py, lines 218-219:
Beta Was this translation helpful? Give feedback.
All reactions