0

I was trying to set up MicroPython on PyCharm 2021.3.3, unfortunately I was not able to successfully connect my board to IDE. I'm getting trying to use tools>>MicroPython>>MicroPython REPL:

Found the device, but could not connect via port 'COM4': could not open port 'COM4': PermissionError(13, 'Odmowa dostępu.', None, 5)
I'm not sure what to suggest. :-(
Press ENTER to continue

Then I have tried to flush simple program to control despite previous error and it spits out:

Connecting to COM4
Traceback (most recent call last):
  File "C:\Users\reczul\AppData\Roaming\JetBrains\PyCharm2021.3\plugins\intellij-micropython\scripts\microupload.py", line 139, in <module>
    main(sys.argv[1:])
  File "C:\Users\reczul\AppData\Roaming\JetBrains\PyCharm2021.3\plugins\intellij-micropython\scripts\microupload.py", line 56, in main
    board = Pyboard(port)
  File "C:\Users\reczul\PycharmProjects\pythonProject1\venv\lib\site-packages\ampy\pyboard.py", line 147, in __init__
    raise PyboardError('failed to access ' + device)
ampy.pyboard.PyboardError: failed to access COM4

What can I do to fix this error?

The sample code I have used:

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)```
  • Are you sure the device is using COM4? Two ways to check, 1) windows > 'device manager' > Ports (COM & LPT) > unplug device > plug it back in > see which port disappeared and reappeared. 2) windows > 'cmd' > type the command 'mode'. Let me know how you go and we can go from there. – Stevo Aug 30 '22 at 07:04
  • How were you able to access Tools > MicroPython REPL? My PyCharm 2022 and 2021 do not have a 'Tools' menu, but IntelliJ does. – Drakes Sep 17 '22 at 03:39

1 Answers1

0

Assuming you are using a Pi Pico.

You are most likely getting this error because you pressed the 'BOOTSEL' button while plugging your device in.

Drag your UF2 file onto the device, it should reboot. Don't unplug the device and hold the 'BOOTSEL' this time.

It should be good to go now.

Stevo
  • 248
  • 4
  • 8