A couple weeks ago, I glanced through my ever-growing collection of Raspberry Pi RP2040-based boards—pictured above are three of the boards I've tested: a Cytron Maker Pi RP2040, a Raspberry Pi Pico, and a Seeed Studio Wio RP2040.
I'm not an expert in embedded programming by any means, but I've played with Arduinos, the ESP8266, and Raspberry Pi's RP2040—all of which are great for building little low-power home sensors to integrate into my Home Assistant Yellow...
But doing so requires a bit of programming work in MicroPython or C, and while it's not rocket science, the more I've seen of ESPHome and how you basically set up YAML files to flash your devices, the more I've been jealous of how easy ESP[8266/32] users have it.
So I was digging around, and I found there's actually a PR to add support for the RP2040 platform to ESPHome!
Naturally, I took it for a spin, and to my surprise—after working with the author to get some library versions updated so they'd run on my M1 Mac—basic functionality worked perfectly!
Hopefully the work is merged into ESPHome soon (along with WiFi support for boards like the WIORP2040 that support it), but for now, if you want to test out ESPHome on a Raspberry Pi Pico or another RP2040 device, here's how:
- Make sure you have Python 3 installed on your computer (check ESPHome's guide for instructions.
- If you already have ESPHome installed on your computer, uninstall it for now.
- Use
pip3
's source install feature to install from the pull request fork:pip3 install git+https://github.com/jesserockz/esphome.git@rp2040
- Make sure the install is working correctly with
esphome version
. That should return something like2022.7.0-dev
.
For my Pico, just to make sure everything was working end-to-end, I created the following ESPHome config and named it led-blink.yml
:
esphome:
name: rpi-pico
rp2040:
board: pico
output:
- platform: gpio
pin:
number: 25
mode: output
id: LED
interval:
- interval: 500ms
then:
- output.turn_on: LED
- delay: 250ms
- output.turn_off: LED
Hold down the BOOTSEL button on your Pico as you plug it into your computer using a USB cable, and it should mount on your computer with a volume label like "RPI-RP2".
Run the following command to compile the led-blink configuration and flash it to the Pico:
$ esphome run led-blink.yml --device /Volumes/RPI-RP2
(That was how I ran it on my Mac—if you're on Linux or Windows, the path for the USB volume will be different.)
After about 30 seconds, the firmware was uploaded, and my Pico began blinking—all built with a single YAML configuration with ESPHome!
Comments
Thanks for this simple but informative post. I've just got a Pico W to play with, and a Wemos D1 mini on its way.
Knowing that ESPHome is easy to get installed and compatible with the Raspi is exciting indeed!
Oh boy, I can't imagine how difficult it would be to port PIO to esphome
Thanks for this, I was really looking forward to trying it as I have a couple of ESPHome scripts running on ESP8266. All went well: ESPHome version returned 2022.7.0-dev as expected so I wrote out your script and tried to load it. Alas, it reported that it couldn't find Arduino.h, which I see is requested by core.h. I see core.h also needs pico.h which I don't have either. Am I missing an important RPI2040 component?
That patch has seen a few more commits I believe, read through the comments on the PR issue on GitHub, there might also be some other steps to get it to work (especially on Windows, I think?).
Thanks for the steer. I looked at the original GitHub and finally got mine to work from my Mac by adding the framework: lines in the original GitHub entry, so:
Thanks for your prompt reply
Looks like this was merged to dev in esphome, however there's a bit of extra hoopjumping sine platformio hasn't merged some pico support. Been poking at picow support which looks decent so far; there's an example in test6.yaml in their test directory
Not sure what im doing wrong, but after following the directions, I get "esphome not installed" in windows cmd
Ran into the following error when using esphome run...
Error: Could not find the package with 'earlephilhower/framework-arduinopico @ ~1.20400.0' requirements for your system 'windows_amd64'
Any ideas on a solution?
Same here, but then for Darwin. Any ideas?
thanks i lot for this manual, but i have the same Error with Mac /Win10 /Debian
Error: Could not find the package with 'earlephilhower/framework-arduinopico @ ~1.20400.0' requirements for your system 'darwin_arm64'
Mine fails with this:
Installing platformio/toolchain-gccarmnoneeabi @ ~1.90201.0
INFO Installing platformio/toolchain-gccarmnoneeabi @ ~1.90201.0
Error: Could not find the package with 'platformio/toolchain-gccarmnoneeabi @ ~1.90201.0' requirements for your system 'linux_aarch64'
Ideas?
Same error. Did you find a way around this?
I gave up on using my rpi to do it, and switched to windows. I followed the directions at /guides/installing_esphome.html#windows from esphome.io (except I already had python3 installed and in the path)
I then followed the process from koen.vervloesem.eu on his blog (the link was triggering spam detection?) you can search for
"Using ESPHome on the Raspberry Pi Pico W and other RP2040 microcontroller boards"
Koen Vervloesem 2023-08-06 20:32