Video Tutorial (Optional)
Watch first if you want to see the full PyCharm + MicroPython setup on a Raspberry Pi Pico (or Pico W).
Project Overview
Raspberry Pi Pico (or Pico W) + MicroPython + PyCharm: In this tutorial, you set up PyCharm to code and flash MicroPython to a Raspberry Pi Pico or Raspberry Pi Pico W, so you can run MicroPython scripts from an IDE many programmers prefer.
- Time: 15 to 30 minutes
- Skill level: Beginner
- What you will build: A working PyCharm workflow that flashes and runs a MicroPython LED blink script on the Pico
Parts List
From ShillehTek
- None required for this setup.
External
- Raspberry Pi Pico or Raspberry Pi Pico W
- USB cable (data-capable) and a computer (Mac or Windows)
- PyCharm (Community Edition is fine)
- MicroPython UF2 firmware for Pico or Pico W
- MicroPython plugin for PyCharm (installed inside PyCharm)
Note: After flashing the MicroPython UF2, unplug and replug the Pico (without holding BOOTSEL) so PyCharm can find the device.
Step-by-Step Guide
Step 1 - Download PyCharm
Goal: Install the IDE you will use to write and flash MicroPython code.
What to do: Download and install PyCharm from this page:
https://www.jetbrains.com/pycharm/download/#section=mac
The Community version is fine for this work.
Expected result: PyCharm is installed and opens successfully.
Step 2 - Install MicroPython on the Pico (or Pico W)
Goal: Flash MicroPython firmware so your Pico can run MicroPython scripts.
What to do:
- Plug the device into the computer while holding the BOOTSEL button.
- Go to https://micropython.org/download/ and download the latest version for the Pico or Pico W.
- Drag the UF2 file onto your Pico once it is done downloading. It should show up on your Desktop as RP1-RP2.
- Once it is done, the RP1-RP2 drive will disappear.
- Unplug and replug the Pico (without holding BOOTSEL). You need to do this so PyCharm can find the device.
Expected result: The Pico reboots into MicroPython and is ready to connect over a serial device.
Step 3 - Install the MicroPython plugin in PyCharm
Goal: Add MicroPython support inside PyCharm.
What to do: Open PyCharm, go to Plugins, and download the MicroPython plugin. Then restart the IDE.
Expected result: After restarting PyCharm, MicroPython options are available in settings.
Step 4 - Create a project, select the Pico, and run a blink test
Goal: Configure PyCharm to flash code to the Pico and verify it runs by blinking the onboard LED.
What to do:
- Go to File > Create Project. Create an environment as shown in the screenshot.
- Go to Preferences and enable MicroPython as shown below.
Find the device path:
- On macOS, you can find the device path in Terminal with this command:
ls /dev/tty.*
- On Windows, this would be a COM port.
Flash and run: You can now run code on the device by right-clicking the file and selecting “Run ‘Flash <filename>’“.
Code: Add the following code to check if it works by blinking the LED.
import machine
import time
led_pin = machine.Pin("LED", machine.Pin.OUT) # GPIO pin 25 controls the onboard LED
while True:
led_pin.toggle() # Toggle the LED state
time.sleep(0.1) # Wait for 1 second
Expected result: The onboard LED starts blinking. If you see it blinking, you did everything correctly.
Conclusion
You set up PyCharm to develop MicroPython for a Raspberry Pi Pico or Pico W, then flashed a simple script to confirm the workflow by blinking the onboard LED.
Pros: Very easy to set up, and you get IntelliSense in PyCharm. Good for very simple projects.
Cons: You cannot edit files directly on the device with the IDE. You can only run code in the main.py file. You cannot run files if you are connected with another IDE like Thonny.
If you learned something here please subscribe to the channel. Want the exact parts used in your next MicroPython build? Grab them from ShillehTek.com. If you want help customizing this workflow for a product or building a MicroPython-based prototype, check out our IoT consulting services.