Windows fail to recognize Pi Pico when running this code

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
hwiguna
Posts: 7
Joined: Sat Aug 17, 2019 8:07 pm

Windows fail to recognize Pi Pico when running this code

Post by hwiguna » Sun Apr 11, 2021 5:00 pm

Code: Select all

def main():
    from machine import Pin, I2C
    from ssd1306 import SSD1306_I2C
    from utime import sleep

    i2c=I2C(1,sda=Pin(2), scl=Pin(3), freq=400000)
    oled = SSD1306_I2C(128, 64, i2c)

    points = [\
        (9,11),(10,11),(11,11),
        (12,12),\
        (13,13),(13,14),(13,15),\
        (14,16),\
        (15,17),(16,17),(17,17),\
        (18,16),\
        (19,15),(19,14),(19,13),\
        (20,12)]

    for snake in range(5):
            for p in points:
                oled.pixel(snake*(20-9)+p[0],p[1], 1)
                oled.show()
            sleep(.01)
    
    for snake in range(5):
            for p in points:
                oled.pixel(snake*(20-9)+p[0],p[1], 0)
                oled.show()
            sleep(.005)

main()
As you can see, there is nothing special about this code, but when I save this on my Pi Pico as main.py, it runs as it is supposed to, but...
if I unplug the pico and replug it in Windows shows this message: "USB device not recognized"
windows not recognizing pico.jpg
windows not recognizing pico.jpg (22.9 KiB) Viewed 7461 times
Thonny message.jpg
Thonny message.jpg (54.28 KiB) Viewed 7461 times
Device manager shows a device with the warning yellow triangle. Scanning devices, replugging the pico does not change the status.
Restarting the PC DOES fix it - Windows recognize the Pico again, and I was able to use Thonny to fix main.py so this no longer happen.

Interestingly, my Mac does NOT have this issue. Same Pico, same untouched main.py.
I suspect it has something to do with I2C being too busy to handle USB traffic.
Have you seen this behavior on your Pi Pico?

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

Re: Windows fail to recognize Pi Pico when running this code

Post by Roberthh » Sun Apr 11, 2021 6:12 pm

Which firmware version is installed on the Pico?

hwiguna
Posts: 7
Joined: Sat Aug 17, 2019 8:07 pm

Re: Windows fail to recognize Pi Pico when running this code

Post by hwiguna » Sun Apr 11, 2021 6:52 pm

Sorry, I should have thought of including that.
I'm running the latest stable release: "Micropython v1.14 on 2021-02-02; Raspberry Pi Pico with RP2400."

I have not tried the newer unstable versions. I presume replacing the uf2 would clobber all my py code, right?

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

Re: Windows fail to recognize Pi Pico when running this code

Post by Roberthh » Sun Apr 11, 2021 7:35 pm

Better save your code before updating, even when replacing the uf2 should not affect the file system.
There was a change in the USB handling recently, leading to more reliable registering of the device. So it might be worth trying the update.

hwiguna
Posts: 7
Joined: Sat Aug 17, 2019 8:07 pm

Re: Windows fail to recognize Pi Pico when running this code

Post by hwiguna » Mon Apr 12, 2021 12:40 am

Latest MicroPython release "rp2-pico-20210411-unstable-v1.14-152-g6f06dcaee.uf2 (latest)" still has trouble finding the Pi Pico with that main.py. :-(

JAndersM
Posts: 1
Joined: Fri May 07, 2021 7:13 am

Re: Windows fail to recognize Pi Pico when running this code

Post by JAndersM » Fri May 07, 2021 7:23 am

Thanks hwiguna
Restarting the PC DOES fix it - Windows recognize the Pico again
I hade the same problem, restarting the PC, Win 10, solved it.

User avatar
russ_h
Posts: 88
Joined: Thu Oct 03, 2019 2:26 am
Contact:

Re: Windows fail to recognize Pi Pico when running this code

Post by russ_h » Fri May 07, 2021 3:17 pm

I’ve seen this issue on Windows 10, a reboot seems to clear the problem for a while. I have not seen the problem while using a Mac or Linux.

Jackli
Posts: 80
Joined: Thu Apr 29, 2021 9:11 am

Re: Windows fail to recognize Pi Pico when running this code

Post by Jackli » Tue May 25, 2021 3:33 am

Yes, I am Win10, I also restarted my computer to solve the problem.

Post Reply