Getting Started NEXT firmware

Arduino Quick Start (NEXT)

Last updated Jul 10, 2026

The Arduino path is the default for HealthyPi 5. It gives you the complete production firmware, eleven teaching sketches, and the same dual-core architecture the board ships with — in an Arduino IDE workflow.

This page gets you from a blank machine to a live ECG trace in about ten minutes.

1. Install the board core

HealthyPi 5’s main MCU is an RP2040, supported by Earle Philhower’s arduino-pico core.

  1. In the Arduino IDE, open File → Preferences.

  2. Add this URL to Additional Boards Manager URLs:

     https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

    Adding the arduino-pico package URL to Arduino IDE Preferences

  3. Open Tools → Board → Boards Manager, search for pico, and install Raspberry Pi Pico/RP2040 by Earle Philhower.

    Board Manager installing the arduino-pico core

  4. Select Tools → Board → Raspberry Pi RP2040 Boards → Raspberry Pi Pico.

    Raspberry Pi RP2040 boards listed in the Arduino IDE Tools menu

Why “Raspberry Pi Pico” and not a HealthyPi board?

The HealthyPi 5’s RP2040 is a plain RP2040 with 16 MB of flash — electrically a Pico. The board-specific knowledge lives in board.h, shipped in the HealthyPi5 library, so nothing is hardcoded in the sketches.

2. Install the libraries

Open Tools → Manage Libraries and install all three.

Library Minimum version What it provides
ProtoCentral HealthyPi 5 2.0.1 board.h (the pin map), the NEXT dual-core runtime, resp_process.h
ProtoCentral MAX30001 2.0.0 ECG, BioZ (respiration), heart rate
ProtoCentral AFE4490 PPG and SpO2 boards library 1.4.0 The AFE4400 driver and the SpO₂ algorithm

Installing the ProtoCentral sensor libraries via Manage Libraries

The library name and the chip name disagree

The PPG front end on the HealthyPi 5 is an AFE4400. The Arduino library that drives it is published as “ProtoCentral AFE4490 PPG and SpO2 boards library” — the AFE4490 is the same family and the driver covers both. It is not a MAX3010x-series sensor, so a MAX30102 library will not work here.

3. Run your first sketch

Start with a single sensor rather than the full firmware.

  1. Open File → Examples → ProtoCentral HealthyPi 5 → Tutorials → 01_ECG_Plotter.
  2. Connect the board over USB-C and pick its port under Tools → Port.
  3. Click Upload.
  4. Open Tools → Serial Plotter and set the baud rate to 115200.

Snap on the ECG electrodes (Hooking up the Sensors) and you should see a live ECG waveform.

If the board doesn’t appear under Tools → Port, put it into UF2 mode by hand — hold the RP2040 boot button while powering on.

RP2040 boot button location on the Complete Kit
Pressing the RP2040 boot button

The board mounts as a drive named RPI-RP2, and the IDE offers a UF2 Board port.

RPI-RP2 mass storage device on the host
UF2 Board option in the Arduino Tools menu

4. Work through the tutorials

Each sketch brings up one sensor or one idea, and is short enough to read top to bottom. Sketches 01–08 and 10 are plain single-core sketches — they share only board.h, so no GPIO is ever hardcoded.

# Sketch Sensor How to view it
01 01_ECG_Plotter MAX30001 (ECG) Serial Plotter @ 115200
02 02_Respiration_Plotter MAX30001 (BioZ) Serial Plotter
03 03_PPG_Plotter AFE4400 Serial Plotter (IR + RED)
04 04_SpO2 AFE4400 Serial Monitor (SpO₂ %, no-finger safe)
05 05_HeartRate MAX30001 (RtoR) Serial Monitor (bpm + R-R interval)
06 06_Temperature MAX30205 or AS6221 Serial Monitor (°C, absent-safe)
07 07_Vitals_Serial all three Serial Monitor (combined line)
08 08_OpenView_Stream all sensors OpenView 2 (29-byte binary frame)
09 09_RawProcessing all sensors your own DSP in loop()
10 10_Wireless_Bridge all sensors ESP32-C3 → BLE / Wi-Fi
11 11_SD_Datalog all sensors microSD (/REC*.BIN)

Tips that save time:

  • Baud must match. The Serial Plotter and Monitor both need 115200.
  • Sketches print label:value (e.g. ECG:123, IR:900,RED:1200) so each Serial Plotter trace is named.
  • The ECG and PPG sketches high-pass the signal to strip baseline drift. Comment those lines out to see the raw sensor data — a good exercise.
  • 04_SpO2: FINGER_IR_MIN is a starting value. Watch data.IR_data with and without a finger on your own board and tune it.

5. Three sketches need one extra setting

Most of the tutorials are ordinary single-core sketches — they talk to a sensor and print. Three are different, because they use the dual-core runtime inside the HealthyPi5 library:

Sketch Why it needs the runtime
09_RawProcessing Reads acquired samples in loop()
11_SD_Datalog Records through the library’s SD sink
HealthyPi5_NEXT The full production firmware

The runtime is built on FreeRTOS, and the arduino-pico core ships FreeRTOS as a separate board variant that you select by hand. Before compiling any of the three, set:

Tools → os → “FreeRTOS SMP”

Then start the sketch with these two includes, in this order:

#include <FreeRTOS.h>                 // must come first
#include <Protocentral_HealthyPi_5.h>

Order matters because the HealthyPi5 header checks that the FreeRTOS variant is active and refuses to compile without it.

If you forget

You get this, immediately, instead of a confusing linker error later:

error: HealthyPi5 requires the arduino-pico FreeRTOS-SMP variant.
Select Tools > 'FreeRTOS SMP' (FQBN option os=freertos), and
#include <FreeRTOS.h> before <Protocentral_HealthyPi_5.h>.

Building from the command line? build.sh and upload.sh already pass os=freertos for the sketches that need it — there’s nothing to set.

Don’t write setup1() or loop1()

On arduino-pico those two functions are how a sketch normally runs code on the second core. The HealthyPi5 library defines them itself — that’s how it keeps core1 doing nothing but acquiring samples. If your sketch defines its own, it won’t link.

Your loop() stays free. In the production firmware it’s empty, because every consumer (DSP, USB, SD, wireless) runs as its own task pinned to core0. In 09_RawProcessing you use it to read samples and run your own algorithm.

6. Build the production firmware

examples/Applications/HealthyPi5_NEXT is the complete headless firmware — and it’s a twelve-line sketch:

#include <FreeRTOS.h>
#include <Protocentral_HealthyPi_5.h>

void setup() {
  HealthyPi5.computeVitals();      // HR + SpO2 + respiration
  HealthyPi5.streamOpenView();     // OpenView 2 over USB-CDC
  HealthyPi5.enableCommands();     // host control plane on USB RX
  HealthyPi5.persistConfig();      // device name + auto-stream saved to flash
  HealthyPi5.recordSD();           // REC*.BIN to a FAT SD card on SPI1
  HealthyPi5.enableSensors();      // I2C temperature + battery
  HealthyPi5.enableBridge();       // HealthyBridge link to the ESP32-C3
  HealthyPi5.begin();              // ring + broker + telemetry + watchdog
}

void loop() {}                     // everything runs in pinned core0 tasks

Delete a line to drop a feature. Each call registers an independently queued sink, so a slow SD card or an unplugged ESP32 drops only its own samples — counted, and reported once a second on the HPI_INSTR telemetry line over UART0.

Don’t route telemetry to USB

HPI_INSTR and fault dumps default to Serial1 (UART0, GP0/GP1). Never point setDebug() at the USB Serial that carries the binary OpenView stream — the text will corrupt the packets.

Command-line workflow

For CI, batch builds, or flashing over a Raspberry Pi Debug Probe, the repo ships three scripts (they need arduino-cli):

./extras/scripts/install-core.sh       # one-time: board core + sensor libraries
./extras/scripts/upload.sh ecg --monitor   # flash tutorial 01, open the console
./extras/scripts/upload.sh next            # flash the production firmware

Targets: next · openview · raw · datalog · ecg resp ppg spo2 hr temp vitals wireless · tutorials (all standalone sketches) · all.

upload.sh defaults to the Debug Probe over SWD; --serial falls back to USB/UF2 and --monitor opens the UART console.

Next