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.
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.
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.
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.
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.
ESP32 DevKit v1
powered by 3 × AAA, no boost convertertop header
bottom header
3×AAA battery holder
BSS138 level shifter
Reed switch
DFPlayer Mini
8Ω speaker
- power +
- GND
- 3V3 → LV
- GPIO4 → reed
- GPIO16 → DFPlayer TX
- GPIO17 → DFPlayer RX
- SPK1
- SPK2