Onto a real Pico
Everything in the last lessons ran on a simulated board. The code was written for a real one, so here is how it gets there. First: which board? Raspberry Pi makes four Picos (as of October 2026):
| Board | Chip, RAM, flash | Radio | Onboard LED |
|---|---|---|---|
| Pico | RP2040, 264 kB, 2 MB | – | GP25 |
| Pico W | RP2040, 264 kB, 2 MB | CYW43439: Wi-Fi, Bluetooth | on the radio chip |
| Pico 2 | RP2350, 520 kB, 4 MB | – | GP25 |
| Pico 2 W | RP2350, 520 kB, 4 MB | CYW43439 | on the radio chip |
PicoRuby's firmware R2P2 comes as two files. Which one goes on which board, and what works with it:
R2P2-FEMTORUBY-…-PICO- Pico: pins, PWM, ADC, I2C, SPI. Pico W: the same file, without the radio – pins; Wi-Fi only in a build of your own, never BLE.
R2P2-PICORUBY-…-PICO2_W- Pico 2 W: everything – Wi-Fi, HTTPS, BLE, dRuby. Pico 2: pins, PWM, ADC, I2C, SPI.
FemtoRuby is PicoRuby built on the smaller VM of mruby/c, PicoRuby proper is built on mruby's VM – the one this course runs in the browser. The Pico 2 W is the only board with an official file that has everything these lessons used, so get that one.
A shopping list
| Part | What for |
|---|---|
| Raspberry Pi Pico 2 WH (the H: pin headers already soldered on) | the board; fits into a breadboard |
| a micro-USB cable that carries data | power, the terminal, copying the firmware; a charging-only cable shows no drive |
| a breadboard and jumper wires | wiring without solder |
| LEDs, 330 Ω resistors, a push button | blinking, the button |
| a light-dependent resistor (LDR) and a 10 kΩ resistor, a passive buzzer | the light sensor on GP26, tones |
| Waveshare Pico-Environment-Sensor | temperature, humidity and air pressure (BME280) over I2C |
| Waveshare Pico-ePaper-2.13 | the e-paper display, 250 × 122 pixels |
| Waveshare PicoGo | the robot: motors, infrared sensors, ultrasonic sensor |
| Waveshare Pico-BLE (optional) | Bluetooth for a Pico without radio |
The Waveshare boards plug onto the Pico's pins; they use the pins the bench showed. Not every pair fits together – the PicoGo and the environment sensor both want GP20 and GP21.
R2P2 step by step
- Get the firmware.
curl -fsSL https://picoruby.org/r2p2-latest.sh | shdownloads the newest R2P2 file (a.uf2), or take it from the releases on GitHub. - Flash it. Hold the BOOTSEL button while you plug the Pico in: a drive appears (
RP2350on a Pico 2 W). Drag the.uf2onto it; the Pico restarts as a small Ruby computer. - Talk to it. Open the R2P2 Web Terminal at picoruby.org/terminal in Chrome or Edge – it uses Web Serial, nothing to install. You get R2P2's shell, with
ls,cat,vimandirb: the IRB of lesson 96, for real. - Put files on it. Dragging
.rbfiles onto the drive is gone since PicoRuby 3.4. Instead: the Web Terminal's upload, thevimon the board, or PicoModem, R2P2's own transfer protocol with a CRC check:picoruby tools/picomodem.rb put app.rb /home/app.rb. - Start it. At boot R2P2 waits 2 seconds (press s to skip), connects to Wi-Fi if
/etc/network/wifi.ymlexists, and runs/home/app.rb. That is where your program goes. - Libraries go into
/lib:/lib/epd2in13.rb, loaded withrequire "epd2in13", because R2P2 sets$LOAD_PATH = ["/lib"]. The tabs of the cells here do the same – each tab is written to/libbefore the run.
prremote: compile on the computer, run on the chip
R2P2 is a whole Ruby on the board, with a file system and a shell. prremote goes the other way. It is a command-line tool by ITO Yosei of LumberMill, Inc. in Takachiho (Miyazaki, Japan), a gem under the MIT licence since May 2026; version 0.4.2 came out on 16 October 2026, and its README warns that it is in early development and that commands may change. It calls itself "inspired by mpremote for MicroPython" – mpremote for Ruby.
prremote puts a tiny mruby/c runtime firmware on the board. The Ruby is compiled on your computer, by your own mrbc (it must be mruby 4.x), and the bytecode goes to the board over the USB serial line, at 115200 baud unless you choose otherwise. The two speak a short protocol:
- The computer sends
Ctrl-C(the byte 3) every second, until the board answersREADY prremote-runtime/0.4.2 board=picow. - It sends the bytecode. A compiled mruby file begins with the letters
RITE, and that is how the board knows a program is coming. (It watches for three such four-letter words:RITE,DPLY,BORD.) The computer writes in pieces of 256 bytes with 4 ms between them. - The board answers
RUNNING, then whatever the program prints, thenDONE– orERRORand the reason. - For
prremote deploythe computer sendsDPLYbefore the bytecode. The board keeps the program in flash, runs it at every boot, and answersDEPLOYED.
Here is that dialogue with a pretend device – plain Ruby, no board needed:
# A pretend device that answers like prremote's runtime firmware.
# It is still busy at the first Ctrl-C; the second one gets READY.
kicks = 0
device = lambda do |bytes|
if bytes == "\x03"
kicks += 1
kicks < 2 ? [] : ["READY prremote-runtime/0.4.2 board=picow"]
elsif bytes.start_with?("RITE")
["RUNNING", "Hello from Pico W!", "DONE"]
elsif bytes.start_with?("DPLY")
["DEPLOYED"]
else
[]
end
end
# the host's side: send something, print what comes back
talk = lambda do |bytes, label|
puts "host -> #{label}"
device.call(bytes).each { |line| puts " <- #{line}" }
end
bytecode = "RITE..." # what mrbc made of app.rb
talk.call("\x03", "Ctrl-C")
talk.call("\x03", "Ctrl-C (one second later)")
talk.call(bytecode, "the bytecode (prremote run)")
talk.call("DPLY" + bytecode, "DPLY + bytecode (prremote deploy)")
Several files: prremote run lib.rb main.rb compiles the files in that order into one bytecode file, so classes and methods from earlier files are there in later ones. mruby/c has no require, and the README recommends this as its replacement. When a script names a board's constant such as M5StickCPlus, prremote even puts that board's library in front by itself. The tabs of this course imitate R2P2's way instead – files in /lib and require – but the idea is the same: the library in the background, your program in front.
The commands: install -b picow puts the firmware on the board, run runs files once, watch runs them again on every save, deploy and undeploy keep a program in flash or remove it, eval runs one line, reset sends Ctrl-C, list shows the serial ports and version the versions.
Its limits: prremote knows the Pico, the Pico W, the Pico 2 (flashing marked as not yet tested on hardware) and ESP32 boards such as the M5Stack; the Pico 2 W is not on its list. On a Pico W it has pins, ADC, PWM, I2C, SPI, Wi-Fi, NTP and TCP – but no TLS (so no HTTPS) and no BLE. The board has no shell, no file system and no IRB. And it has its own Ruby API, on purpose – it does not follow PicoRuby's names:
| prremote | PicoRuby (R2P2) | |
|---|---|---|
| onboard LED | GPIO.led | CYW43::GPIO.new(CYW43::GPIO::LED_PIN) |
| an output pin | GPIO.new(15, :output) | GPIO.new(15, GPIO::OUT) |
| Wi-Fi | WiFi.connect(ssid, pw, auth, secs) | CYW43.connect_timeout(ssid, pw, auth, secs) |
| getting the program there | bytecode into RAM, or flash with deploy | source files in the file system |
So the code of these lessons runs on R2P2 as it is, and needs changes for prremote.
R2P2: the steps above – curl -fsSL https://picoruby.org/r2p2-latest.sh | sh, BOOTSEL, drag the file, then the Web Terminal.
prremote: gem install prremote (Ruby 3.4 or newer) and an mrbc of mruby 4: brew install mruby on a Mac; on Linux build mruby 4 from source, or point MRBC=/path/to/mrbc at one – Debian's mruby package is 3.x, which prremote calls not compatible. Then once prremote install -b picow (hold BOOTSEL, plug in), and from then on prremote watch app.rb – every save runs the file again. prremote deploy lib.rb main.rb keeps it on the board. In WSL2 the USB device needs usbipd attach --wsl first.
run_status(lines), the way prremote's computer side reads the board's lines: :done once DONE came, "error: <reason>" for ERROR <reason>, :running after RUNNING without an end yet, and :waiting otherwise. The last lines of the cell try four dialogues.def run_status(lines)
# DONE -> :done, "ERROR x" -> "error: x", RUNNING -> :running
:waiting
end
ready = "READY prremote-runtime/0.4.2 board=picow"
[run_status([ready, "RUNNING", "hello", "DONE"]),
run_status([ready, "RUNNING", "ERROR NoMethodError"]),
run_status([ready, "RUNNING", "tick"]),
run_status([ready])]
Straight from this page
Under every bench of these lessons there is a folded panel 🔌 A real Pico (USB). With a Pico running R2P2 on a USB cable, it does what the Web Terminal does, from the cell itself:
- Connect a real Pico… opens the browser's own list of serial ports. It shows R2P2's ports (USB vendor 16C0); R2P2 has three; its shell is normally on the first (the lowest COM or ttyACM number) – if no
$>prompt comes, try the next. The page gets exactly the port you choose – nothing else on your computer. Sending needs an R2P2 with PicoModem, as R2P2 4.0.3 has. - The black box is R2P2's terminal: what the Pico prints, and below it a line to type into, for
lsorirb. Ctrl-C stops a running program. - Send this cell to the Pico and run it presses Ctrl-C (and Ctrl-D, which leaves an
irb), writes each tab of the cell to/liband the code to/home/chunky.rb– with PicoModem, like the Web Terminal's upload, each file checked with CRC-32 – and then types/home/chunky.rbat the prompt$>, which runs it. With the box ticked it becomes/home/app.rb, the program R2P2 starts at power-up. A first line in the file makesrequireread the tabs anew;show_irb, which only this page has, becomes a comment – typeirbat the prompt instead.
Which browsers: Web Serial is in Chrome, Edge and Opera on a computer (Windows, macOS, Linux, ChromeOS), not in Firefox or Safari. On Linux your user may have to be in the group dialout to open /dev/ttyACM0. And the page has to be secure: letsruby.com over https, or localhost. On an address with plain http the panel only says why it cannot.
Bluetooth: in lesson 102 the benches with the laptop also have 📶 A real Pico 2 W (Bluetooth): the laptop there then talks to a real Pico 2 W running a BLE::UART program. Web Bluetooth is in Chrome and Edge on Windows, macOS, ChromeOS and Android; on Linux it may have to be switched on in chrome://flags.
Safe by design: the page can only reach a device you picked in the browser's own chooser, and only while this tab is open; Disconnect, or closing the tab, ends it. Nothing goes anywhere else: the code goes from this tab over the cable or the radio to your Pico. What runs there is the cell's code, which you can read – and like everything on a Pico it switches the pins you wired, so check the wiring first.
To be honest: this connection has not been tried on a real Pico yet. It follows R2P2 4.0.3's sources – the prompt, Ctrl-B for PicoModem, the frames and their checksums – and is tested against a pretend R2P2 and against PicoModem's own device code. If it does not work with your board, the R2P2 Web Terminal at picoruby.org/terminal does the same by hand.