Page 1 of 1

Windows fail to recognize Pi Pico when running this code

Posted: Sun Apr 11, 2021 5:00 pm
by hwiguna

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 7459 times
Thonny message.jpg
Thonny message.jpg (54.28 KiB) Viewed 7459 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?

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

Posted: Sun Apr 11, 2021 6:12 pm
by Roberthh
Which firmware version is installed on the Pico?

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

Posted: Sun Apr 11, 2021 6:52 pm
by hwiguna
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?

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

Posted: Sun Apr 11, 2021 7:35 pm
by Roberthh
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.

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

Posted: Mon Apr 12, 2021 12:40 am
by hwiguna
Latest MicroPython release "rp2-pico-20210411-unstable-v1.14-152-g6f06dcaee.uf2 (latest)" still has trouble finding the Pi Pico with that main.py. :-(

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

Posted: Fri May 07, 2021 7:23 am
by JAndersM
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.

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

Posted: Fri May 07, 2021 3:17 pm
by russ_h
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.

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

Posted: Tue May 25, 2021 3:33 am
by Jackli
Yes, I am Win10, I also restarted my computer to solve the problem.