main.py isn't running when Pico connected to external power

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
ssfel
Posts: 3
Joined: Wed Mar 03, 2021 3:53 pm

main.py isn't running when Pico connected to external power

Post by ssfel » Wed Mar 03, 2021 4:03 pm

I think I'm missing a step somewhere. Can't get Pico to run when it isn't being powered by the micro-USB.

Have a main.py to blink the on board LED. Trying to power it by connected 5 VDC to VSYS. I'm using Thonny with the Micropython interpreter to save the program onto the Pico. Program just doesn't seem to be running at all.

Is there a guide somewhere or a simple tutorial that anybody can link me where the Pico isn't being powered through the USB port? I think I must be missing something

Thanks in advance

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: main.py isn't running when Pico connected to external power

Post by dhylands » Wed Mar 03, 2021 6:51 pm

That seems to work fine for me.

I created main.py with the following:

Code: Select all

import blinky
and blinky.py with

Code: Select all

from machine import Pin, Timer
led = Pin(25, Pin.OUT)
tim = Timer()
def tick(timer):
    global led
    led.toggle()

tim.init(freq=2.5, mode=Timer.PERIODIC, callback=tick)
I verified that powering up via USB worked. Then I disconnected the USB cable and connected VSYS and GND to a 5V source and the blinky program is running.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: main.py isn't running when Pico connected to external power

Post by Roberthh » Wed Mar 03, 2021 8:58 pm

Since you are using Thonny: Are you sure that you really copied the main.py file to the board? Just running the files with Thonny dos nto copy it permanently to the boards file system.

HermannSW
Posts: 197
Joined: Wed Nov 01, 2017 7:46 am
Contact:

Re: main.py isn't running when Pico connected to external power

Post by HermannSW » Wed Mar 03, 2021 10:08 pm

I used rshell to copy files onto Pico MicroPython flash filesystem (cp main.py /pyboard).
Today I copied boot.py and main.py, and both get executed, on powering as well as on soft reboot:
https://www.raspberrypi.org/forums/view ... 3#p1830113
Image
Pico-W Access Point static file webserver:
https://github.com/Hermann-SW/pico-w

Tiny MicroPython robots (the PCB IS the robot platform)
viewtopic.php?f=5&t=11454

webrepl_client.py
https://github.com/Hermann-SW/webrepl#webrepl-shell

ssfel
Posts: 3
Joined: Wed Mar 03, 2021 3:53 pm

Re: main.py isn't running when Pico connected to external power

Post by ssfel » Mon Mar 08, 2021 10:25 am

Roberthh wrote:
Wed Mar 03, 2021 8:58 pm
Since you are using Thonny: Are you sure that you really copied the main.py file to the board? Just running the files with Thonny dos nto copy it permanently to the boards file system.
At the moment I'm doing;
Save As --> Raspberry Pi Pico --> "main.py", save

Is that correct?

User avatar
aivarannamaa
Posts: 171
Joined: Fri Sep 22, 2017 3:19 pm
Location: Estonia
Contact:

Re: main.py isn't running when Pico connected to external power

Post by aivarannamaa » Thu Mar 11, 2021 8:09 am

ssfel wrote:
Mon Mar 08, 2021 10:25 am
At the moment I'm doing;
Save As --> Raspberry Pi Pico --> "main.py", save
This should do.

Does it start running again when you reconnect USB? Can it be powering issue?
Aivar Annamaa
https://thonny.org

fdufnews
Posts: 76
Joined: Mon Jul 25, 2016 11:31 am

Re: main.py isn't running when Pico connected to external power

Post by fdufnews » Thu Mar 11, 2021 6:37 pm

Can you post your main.py?
Are you sure, you are not missing any import or pin setting in your software?

reiska
Posts: 1
Joined: Fri Mar 18, 2022 2:52 pm

Re: main.py isn't running when Pico connected to external power

Post by reiska » Fri Mar 18, 2022 3:17 pm

Hi,
i have faced the same problem as ssfel. Unfortunately none of the suggestions has been helpful.
At least for my application I found a workaround:
I start main.py as usual having the pico connected via an USB cable. Then connect an external 5V source to VSYS. Now I can unplug the USB connection and the pico continues to run.

Any better solution is still welcome.

User avatar
karfas
Posts: 193
Joined: Sat Jan 16, 2021 12:53 pm
Location: Vienna, Austria

Re: main.py isn't running when Pico connected to external power

Post by karfas » Fri Mar 18, 2022 3:43 pm

As @roberthh did suggest:

Don't trust thonny or any fancy, colorful gui.
Verify that main.py is really on the device using pyshell or the like. You can also check with a small uPy program whether main.py is really where it belongs (next to boot.py).
A few hours of debugging might save you from minutes of reading the documentation! :D
My repositories: https://github.com/karfas

Post Reply