Leah Chan.
Contact
arrow_backAll Projects
Featured Fabrication • Electronics / ESP32

The Musical Grad Book Box.

A keepsake box that plays a song the moment its lid opens. Everything runs on three AAA batteries hidden inside, with no cable needed.

ESP32 DFPlayer Mini Reed Switch Acoustics
The finished book box, its wooden lid painted with a heart-shaped meadow scene and a white duck
Overview

Open the lid and a song starts playing. Inside, a small magnet on the lid sits right above a reed switch. When the lid lifts, the magnet moves away, the ESP32 notices, and it tells a little MP3 player to play the song through a speaker hidden in the box.

To change the song, I just swap one file, 0001.mp3, on the microSD card. Three AAA batteries tucked inside power everything, so the box doesn’t need a cable.

Breadboard prototype: ESP32, level shifter and DFPlayer Mini wired on a breadboard, with the AAA battery holder and speaker
Breadboard prototype, before going into the box
How It Works
01

Lid Trigger

A reed switch closes when the lid magnet is near. Its two wires go to GPIO4 and ground, so the ESP32 sees the moment the lid opens. Nothing presses on the lid, and the glass switch never touches the magnet.

02

Sound

The ESP32 sends serial commands to the DFPlayer Mini on GPIO16 and GPIO17. A BSS138 level shifter sits between them so the player’s 5 V signal can’t damage the 3.3 V ESP32. The player drives the 8Ω speaker directly.

03

Power

Three AAA cells in a switched holder power the ESP32 (through its VIN pin), the MP3 player and the level shifter directly, with no boost converter. The holder’s own switch turns the whole box off for battery or song changes.

Wiring

ESP32 DevKit v1

powered by 3 × AAA, no boost converter

top header

VIN
GND
D13
D12
D14
D27
D26
D25
D33
D32
D35
D34
VN
VP
EN

bottom header

3V3
GND
D15
D2
D4
RX2 · GPIO16
TX2 · GPIO17
D5
D18
D19
D21
RX0
TX0
D22
D23
battery_full

3×AAA battery holder

VCC
GND
swap_vert

BSS138 level shifter

LV side
LV
GND
A1
A2
A3
A4
HV side
HV
GND
B1
B2
B3
B4
sensors

Reed switch

PIN1
PIN2
sd_card

DFPlayer Mini

VCC
RX
TX
DAC_R
DAC_L
SPK_1
GND
SPK_2
volume_up

8Ω speaker

POS
NEG
  • power +
  • GND
  • 3V3 → LV
  • GPIO4 → reed
  • GPIO16 → DFPlayer TX
  • GPIO17 → DFPlayer RX
  • SPK1
  • SPK2
In the Box
Demo: lid opens, song plays (sound on)
The box with its lid open: breadboard, ESP32, DFPlayer, speaker and AAA battery holder inside
Everything fitted inside the box
Keep Exploring Back to Projects & Ideas
arrow_forward