RP2040 MIDI Scanner — Dual-Core IPMidi/USB Master-Slave for Digital Pipe Organ
Raspberry Pi Pico MIDI scanner for GrandOrgue & Hauptwerk pipe organs. Dual-core RP2040, I2C master/slave, W5500 Ethernet IPMidi or USB MIDI output.
Overview
The RP2040 MIDI Scanner is an open-source firmware for the Raspberry Pi Pico that turns it into a high-performance MIDI keyboard and controller scanner for digital pipe organs. It supports both IPMidi (UDP multicast over Ethernet via WIZnet W5500) and USB MIDI output, making it fully compatible with GrandOrgue and Hauptwerk virtual pipe organ software.
The system supports a Master/Slave architecture over an I2C bus, allowing multiple Pico boards to be linked together via a 10-way ribbon cable. The master polls all slaves and aggregates their MIDI events into a single IPMidi multicast stream. Both cores of the RP2040 are used to maximise scanning performance and minimise latency.
System topology
One master board connects to multiple slave boards over a 4MHz I2C bus via a 10-way ribbon cable. The master collects all MIDI events from the slaves and transmits them as IPMidi UDP multicast packets over Ethernet using a W5500 module, or as USB MIDI if Ethernet is not available.
Dual-core architecture
Both RP2040 cores are used in parallel. Core 0 handles all I/O, networking, and MIDI transmission, while Core 1 is dedicated entirely to scanning keyboards, pistons, and analogue controllers — ensuring minimum latency between key press and MIDI output.
What This Project Does
- Scans organ keyboard matrices (61 or 73 keys), piston buttons, and analogue controllers (expression pedals, swell)
- Transmits MIDI events via IPMidi (UDP multicast) using WIZnet W5500 Ethernet, or USB MIDI as fallback
- Supports Master/Slave multi-board topology over 4MHz I2C bus via 10-way ribbon cable (tested up to 4M)
- I2C address
0= Master; all other addresses = Slave (only one master per bus) - GPIO22 drives a console relay — turns on when any key or piston is pressed, with a 5-minute re-triggerable timer (for console lighting)
- Supports NRPN control change to trigger a re-scan of all analogue controllers on all boards
- Auto-detects W5500: if no Ethernet hardware or DHCP fails, falls back to USB MIDI seamlessly
- DHCP renewal handled via
ethernet.maintain()every 100ms for seamless lease renewal - I2C bus recovery via stop/restart commands (no hardware reset line needed)
I2C protocol & hardware wiring
The master polls each slave in ascending I2C address order, reading 2 bytes at a time. The ribbon cable carries power, ground, I2C SDA/SCL, and an optional console relay signal. Pull-up resistors of 10K are fitted on each board.
Hardware
- MCU: Raspberry Pi Pico (RP2040, dual-core ARM Cortex-M0+, 133MHz)
- Ethernet: WIZnet W5500 module — SPI (MISO=GP16, CS=GP17, SCK=GP18, MOSI=GP19, RST=GP20, INT=GP21)
- I2C bus: 4MHz, SDA=GP7, SCL=GP9 (10-way ribbon, 10K pull-ups, tested to 4M)
- Console relay: GPIO22 — relay output on master, 5-minute re-triggerable timer
- Connection: 10-way ribbon cable between boards (even pins = ground)
Software & Compatibility
- Framework: Raspberry Pi Pico SDK (C++)
- MIDI output: IPMidi (UDP multicast, variable-size packets up to UDP_TX_PACKET_MAX_SIZE) or USB MIDI
- Pipe organ software: GrandOrgue and Hauptwerk compatible
- Version: V7.1.1 (latest)
- Author: David J Bottrill, Shady Grove Electronics © 2019–2023
How to Build & Flash
- Clone:
git clone https://github.com/djbottrill/RP2040_Midi_Scanner - Install Raspberry Pi Pico SDK and set
PICO_SDK_PATH - Open
RP2040_Midi_Scanner/folder in VS Code with the Pico extension, or build via CMake - Set I2C address in the default settings section:
0= Master,1..N= Slave - Flash the
.uf2file by holding BOOTSEL and connecting USB, then drag-and-drop - Connect W5500 module via SPI and Ethernet cable to your network
- Open GrandOrgue or Hauptwerk and configure IPMidi as MIDI input
FAQ
Q1. What is IPMidi and why use it over USB MIDI?
IPMidi sends MIDI events as UDP multicast packets over a standard Ethernet network. This allows the organ console to be located anywhere on the LAN without a direct USB cable to the PC. It has very low latency and supports multiple MIDI streams simultaneously. GrandOrgue and Hauptwerk both support IPMidi natively.
Q2. How many slave boards can be connected?
Up to 127 slaves can theoretically be addressed on the I2C bus (addresses 1–127). In practice, the number is limited by the cable length and I2C signal integrity. The system has been tested with ribbon cables up to 4 metres in length with 10K pull-up resistors on each board.
Q3. What happens if the Ethernet connection fails?
If no W5500 hardware is detected, or if DHCP fails, the firmware automatically falls back to USB MIDI. This means the scanner will still work as a standard USB MIDI device even without a network connection.
Q4. What does the console relay (GPIO22) do?
The relay output on GPIO22 of the master board turns ON whenever any key or piston is pressed. It uses a 5-minute re-triggerable timer, so the relay stays on as long as the organ is being played. This can be used to control console lighting, power management, or other auxiliary systems.
Q5. Can I use this with a standard 61-key MIDI keyboard?
Yes — the scanner is designed for organ keyboards but can scan any matrix keyboard. The scanning interval is configurable in the default settings section. Analogue controllers (expression pedals, swell shoes) are also supported via the analogue scanning function on Core 1.
Q6. How is the W5500 connected?
The W5500 connects via SPI: MISO=GP16, CS=GP17, SCK=GP18, MOSI=GP19, RST=GP20, INT=GP21. Standard WIZnet W5500 breakout modules wired to these Pico GPIO pins work correctly. The firmware uses the WIZnet Ethernet library for Arduino-compatible Pico builds.
Key Takeaway
The RP2040 MIDI Scanner is a complete, production-ready solution for building a digital pipe organ console. By combining the RP2040 dual-core processor, WIZnet W5500 Ethernet for low-latency IPMidi, and a scalable I2C Master/Slave architecture, it delivers professional-quality MIDI scanning at minimal cost — and is fully compatible with GrandOrgue and Hauptwerk.
Source Code: https://github.com/djbottrill/RP2040_Midi_Scanner
