Friday, 18 April 2025

Returning to the Unicorn

Building a Smooth Workflow for Raspberry Pi Pico W Projects with VS Code and mpremote

This morning I decided to tackle a nagging issue: my Raspberry Pi Pico W development workflow felt clunky. Uploading code manually, dealing with VS Code IntelliSense errors, and fiddling with board resets slowed me down.

I wanted a press one button, everything works experience.
Here’s exactly what I did to streamline my setup — and where I’m heading next.

The Hardware and Project

I’m working with a Pimoroni Galactic Unicorn — a Raspberry Pi Pico W-powered LED matrix display.
The project is simple at heart: connect to Wi-Fi, fetch text from a cloud API, and display it scrolling across the LEDs.

My starting point is some code I sort of got working a long time ago:

Flashing and Connecting to the Pico W

I began by ensuring my board had the latest MicroPython firmware.
Flashing was straightforward via BOOTSEL mode and drag-and-drop.

Installed mpremote:

pipx install mpremote

Connected easily:

mpremote connect auto

✅ First win of the day.

Improving the Deployment Workflow

Manually uploading files every time felt tedious, so I automated it with a deploy script:

#!/bin/bash
PORT="auto"

mpremote connect $PORT fs cp main.py :main.py
mpremote connect $PORT fs cp local_secrets.py :local_secrets.py
mpremote connect $PORT reset

Made it executable:

chmod +x deploy.sh

Now I can deploy everything with one command:

./deploy.sh

✅ One-click uploads.
✅ Automatic reboot.
✅ Huge time saver.

Making Deployment Pretty ✨

I added colours and emojis to the script for better terminal feedback:

echo -e "${GREEN}✅ Files uploaded.${NC}"
echo -e "${BLUE}🔄 Rebooting device...${NC}"
echo -e "${GREEN}🎉 Deploy complete! Your Unicorn is ready to fly! 🦄${NC}"

Resulting output:

🔍 Checking Pico-W connection...
✅ Pico-W connected.

📤 Uploading files...
✅ Files uploaded.

🔄 Rebooting device...

🎉 Deploy complete! Your Unicorn is ready to fly! 🦄

✅ Small touches that make daily dev life much more joyful.

Fixing VS Code IntelliSense and Import Errors

Even though everything worked on the board, VS Code kept underlining imports like network and urequests:

Import "network" could not be resolved

Here’s what fixed it:

  • Installed MicroPython stubs:
pip3 install -U micropython-rp2-pico_w-stubs --no-user --target ./typings
  • Updated VS Code settings:
{
  "python.analysis.extraPaths": [
    "./typings"
  ],
  "python.linting.enabled": true,
  "python.analysis.useLibraryCodeForTypes": true
}
  • Added dummy modules like network.py:
# Dummy network module for editor happiness

✅ No more red underlines.
✅ Full IntelliSense.
✅ Clean project feel.

Useful Resources and Links

What's Next?

Tomorrow I’m planning to focus on the cloud side:

  • Cleaning up the unicorn_text API
  • Reviewing API security
  • Maybe adding a simple web UI to update text remotely
  • Thinking about automated cloud deploys

Excited to keep the momentum going! 🚀

Closing Thoughts

Today was a great reminder that investing a few hours into your workflow can make coding much more fun, faster, and less error-prone.
Building a clean embedded dev environment that feels effortless? Absolutely worth it. 🦄💻

No comments:

Post a Comment

Sorry getting a lot of spam coming through at the moment. So I'm having to moderate comments.

Note: only a member of this blog may post a comment.