Wiring — current setup (Raspberry Pi 3)
Your current setup
Section titled “Your current setup”| Part | What it is |
|---|---|
| Computer | Raspberry Pi 3 B/B+ running the Nerves firmware |
| Audio | HiFiBerry Amp2 stacked on the Pi’s 40-pin header, two speakers |
| Light controller | One ESP32 DevKit, 30-pin (classic ESP32 with a CP2102 USB-C chip — not an ESP32-S3). It is powered from the Pi’s 5 V pin (header pin 2 or 4 → ESP32 VIN) and talks to the Pi over its UART pins (GPIO14/15), both reached under the Amp2 |
| Light | 60-LED WS2812B strip on the ESP32’s D13, with its own 5 V supply |
| Bedside button | optional: LoRa module on the Pi’s SPI |
There is no second ESP32 and no ESP32-S3 in this build. (The two-ESP32 version is the future board bench.)
Three independent circuits hang on the Pi 3. Build them one at a time and check each before the next: audio, light, bedside button.
The 40-pin header at a glance
Section titled “The 40-pin header at a glance”Pin numbers are physical pin numbers (not GPIO numbers). The chart is drawn as on a pinout poster: pin 1 at the top, odd pins on the left (the inner row) and even pins on the right (the outer row, nearest the edge of the board). Pin 1 is the square pad, next to the corner of the board closest to the SD slot.
Finding the pins when the HAT hides the names
Section titled “Finding the pins when the HAT hides the names”With the amplifier fitted, the names printed on the Pi are covered. Find a pin by position, not by name:
- Turn the board so the SD card slot is on your left and the 40-pin header runs along the top edge.
- The header has two rows of 20 pins. The top row (nearest the board edge)
is the even pins
2, 4, 6 … 40; the bottom row is the odd pins1, 3, 5 … 39. - Count from the left end: pin 1 is the first of the bottom row, pin 2 the
first of the top row. Pin
nis the ⌈n ÷ 2⌉-th pin of its row.
| Pin | Row | Count from the left | Function here |
|---|---|---|---|
| 6 | top | 3rd | GND → ESP32 |
| 8 | top | 4th | TXD → ESP32 D18 |
| 10 | top | 5th | RXD ← ESP32 TX2 |
| 17 | bottom | 9th | 3V3 → LoRa |
| 19 | bottom | 10th | MOSI → LoRa |
| 21 | bottom | 11th | MISO ← LoRa |
| 23 | bottom | 12th | SCLK → LoRa |
| 24 | top | 12th | CE0 → LoRa NSS |
| 25 | bottom | 13th | GND → LoRa |
Check you are on the right pin with a continuity tester, everything unpowered: pin 6 must beep with pins 9, 14, 20, 25, 30, 34 and 39 (all ground). If it does not, you are one position off, or on the wrong row.
The Amp2 itself needs no wire: it takes the I²C and I²S pins and feeds the Pi with 5 V simply by sitting on the header.
1. Audio — HiFiBerry Amp2
Section titled “1. Audio — HiFiBerry Amp2”You need: Pi 3 B/B+, HiFiBerry Amp2, a regulated 16.5 V / 2 A supply, two passive 4–8 Ω speakers.
- Fit the Amp2 on the Pi’s 40-pin header, all 40 pins seated.
- Connect both speakers, respecting polarity. Do not join the two “−” wires.
- Connect the supply last, then switch it on.
- Boot, open the web interface and play a manual test sound at low volume.
The card is detected automatically (
alsa_device: "auto").
2. Light — ESP32 and LED strip
Section titled “2. Light — ESP32 and LED strip”You need: ESP32 DevKit 30-pin (CP2102), a 60-LED WS2812B strip, a separate 5 V supply sized for the strip (up to 3.6 A at full white; the firmware caps the brightness), a 330 Ω resistor, Dupont wires.
- Join the grounds: Pi GND, ESP32 GND, strip GND and the 5 V supply GND must all meet. Without a common ground the data signal is garbled.
- Wire the UART: Pi pin 8 → ESP32
D18, Pi pin 10 ← ESP32TX2. - Put the 330 Ω resistor in series on the data line, close to the strip’s
DIN(the end where the arrows point into the strip). - Feed the strip’s
+5V/GNDfrom the 5 V supply, not from the ESP32 or the Pi. - Power the ESP32 from the Pi: header pin 2 (or 4, both are 5 V) → ESP32
VIN. About 50–80 mA, well within what the Amp2 supplies to the Pi. Do not also plug a USB cable into the ESP32 whileVINis wired: two 5 V sources feed into each other. To flash the ESP32 from the Pi’s USB port, unplug theVINwire first, flash, then put it back and unplug the USB cable. - Check from the web interface: on the evening screen (Soir), start a sunrise or the reading light.
3. Bedside button — LoRa module (SX1276 / RFM95)
Section titled “3. Bedside button — LoRa module (SX1276 / RFM95)”You need: an RFM95 (or Ra-01H) 868 MHz module, a 868 MHz antenna (a plain wire of about 86 mm works), a 10 kΩ resistor, 100 nF and 10 µF capacitors.
On power-up the driver reads the module’s version register and expects 0x12.
Any other value (loose wire, wrong module) puts the radio in an unavailable
state instead of listening with a broken radio. Protocol and pairing:
remote button note.
Power-up order
Section titled “Power-up order”- All grounds joined, all wires checked against the figures.
- Speakers connected.
- Antenna on the LoRa module.
- ESP32
VINwire to the Pi’s 5 V (it is only live once the Amp2 supply is on). - Amp2 supply (this powers the Pi), then the 5 V strip supply.
- Never hot-plug the Amp2 supply.
Reference table
Section titled “Reference table”| From | Pin | To | Notes |
|---|---|---|---|
| Pi | 8 · GPIO14 TXD | ESP32 D18 |
UART, mini UART ttyS0 |
| Pi | 10 · GPIO15 RXD | ESP32 TX2 |
UART |
| Pi | 6 · GND | ESP32 GND | common ground |
| Pi | 2 · 5 V | ESP32 VIN |
power, no USB cable |
| ESP32 | D13 |
strip DIN |
via 330 Ω |
| 5 V supply | +5 V / GND |
strip +5V / GND |
joined to ESP32 GND |
| Pi | 17 · 3V3 | LoRa 3.3V | + 100 nF, 10 µF |
| Pi | 25 · GND | LoRa GND | any GND pin works |
| Pi | 23 · SCLK | LoRa SCK | SPI0 |
| Pi | 21 · MISO | LoRa MISO | SPI0 |
| Pi | 19 · MOSI | LoRa MOSI | SPI0 |
| Pi | 24 · CE0 | LoRa NSS | SPI0 chip select |
| LoRa | RESET | 3.3 V via 10 kΩ | pull-up |