Go to file
Stefan Ostermann 6ecb54e5ee folder play / next song fixes 2025-12-13 23:18:48 +01:00
.vscode vscode stuff 2025-11-01 23:55:44 +01:00
images documentation 2024-02-13 20:49:58 +01:00
include missing files 2023-07-15 19:54:48 +02:00
lib fixed jump to second of playtime 2025-07-07 21:28:37 +02:00
schema/hannabox documentation 2024-02-13 20:49:58 +01:00
scripts [ai] memory optimized web serving 2025-11-02 00:04:31 +01:00
sounds improvements 2023-10-09 21:24:57 +02:00
src folder play / next song fixes 2025-12-13 23:18:48 +01:00
test First experiments 2023-05-28 00:32:39 +02:00
web folder play / next song fixes 2025-12-13 23:18:48 +01:00
.gitignore [ai] Many (memory) improvements, cleanup script, still problems 2025-10-06 23:13:26 +02:00
.gitmodules removed ESP32-audioI2S submodule 2025-07-06 21:09:49 +02:00
MEMORY_OPTIMIZATIONS.md [ai] tcp optimizations 2025-11-04 21:58:57 +01:00
MEMORY_OPTIMIZATIONS_WEB.md Memory Optimizations 2025-07-06 22:25:49 +02:00
README.md Upgraded libraries, fixed compatibility 2025-07-06 19:58:39 +02:00
SD_CARD_SETUP.md docs 2025-07-07 21:28:20 +02:00
USER_MANUAL.md fixed config, memory consumption, manual 2025-10-18 22:56:11 +02:00
copy_to_sd.sh docs 2025-07-07 21:28:20 +02:00
example_config.txt config file 2025-07-28 22:59:59 +02:00
platformio.ini lib updates 2025-11-30 20:44:37 +01:00

README.md

HannaBox

The HannaBox is a Wifi enabled music player for toddlers and small children. It features an sd card reader, three buttons, a speaker up to 3 watts and an RFID reader. It is powered by a ESP32 microcontroller module.

Preparation

The library https://github.com/schreibfaul1/ESP32-audioI2S is not available for Platformio in a working version. It is linked into the lib folder as a git submodule.

Init and pull the submodule before continuing:

git submodule update --init

Microcontroller

We are using an ESP-WROOM-32 module. For the mp3 decoding we need a multicore CPU, be careful, there are some ESP32 with only one core.

Pins

The plain number refers to the GPIO pin.

Amplifier

We use a MAX98357A I2S 3W DAC Class D Amplifier Module

26 -> DIN
27 -> BCLK
25 -> LRC
5V -> Vin
GND -> GND

For sound output, we use the ESP32-audio2I2S library. Important note: Last release without PSRAM is V 3.2.1. You get OOM errors if using a later library without PSRAM.

SD Card Reader

SD Card Reader Adapter Modul

CS -> 22 (D1)
MOSI -> 23 (D7)
CLK -> 18 (D5)
MISO -> 19 (D6)

The pinout of a micro sd card is like this:

Alt text

RFID Reader

For RFID, we use a standard module: NFC RFID module RC522

These are the connections:

SOA -> 32
SCK -> 18
MOSI -> 23
MISO -> 19
IRQ -> NC
GND -> GND
RST -> 33
3.3V -> 3.3V

Buttons

We use three buttons, preferably big and robust. They are grounded if closed, so normally high and pressed low.

Start / Stop -> 17 and GND
Wake up / Next -> 04 and GND
Previous -> 16 and GND

#define BTN_START_STOP 4 // Button on XX and GND
#define BTN_NEXT 17
#define BTN_PREV 16

Battery Voltage

The battery voltage is measured by the ADC of pin 35. A voltage divider halves the voltage so that the pin can not be overloaded (max 3.3V). The voltage divider consists of two 100kOHM resistors, the voltage is measured between them. One side is connected to the battery and the other to ground. There are 2 ADCs, make sure to not use the one which is not usable during WIFI!

Power

We use the voltage regulator of the SD Card module. We also can use a LDL1117S33R Low Dropout Voltage regulator. For Loading the LiIon we can use a LTC4054 or a dedicated module.

System sounds

Place these sounds in the folder system on the SD card:

  • sleep.mp3
  • start.mp3

sleep.mp3 will be played just before the timed shutdown, start.mp3 will be played if the box started and initialized successfully.

Schematic without modules

This schematic uses the amplifier and sd card reader as discrete components instead of modules:

alt text

Notes

ESP32-Wroom Pinout:

esp32-wroom-32 pinout

RFID Chip Registers

The interrupt method was not working because it seems reading a card does not trigger one.

See https://arduino.stackexchange.com/a/76285 and https://github.com/miguelbalboa/rfid/blob/master/examples/MinimalInterrupt/MinimalInterrupt.ino

Charging circuit

Possible circuit Chip to use: MCP73837?

Amplifier

The Chip is a MAX98357 Class D Amp. Pin 1 is on the lower left side, seen from the letters in correct orientation.

SD / MODE

This pin is used for shutdown mode but is also used for setting which channel is output. It's a little confusing but essentially:

  • If SD is connected to ground directly (voltage is under 0.16V) then the amp is shut down
  • If the voltage on SD is between 0.16V and 0.77V then the output is (Left + Right)/2, that is the stereo average.
  • If the voltage on SD is between 0.77V and 1.4V then the output is just the Right channel
  • If the voltage on SD is higher than 1.4V then the output is the Left channel. This is compounded by an internal 100K pulldown resistor on SD so you need to use a pullup resistor on SD to balance out the 100K internal pulldown.

For the breakout board, there's a 1Mohm resistor from SD to Vin which, when powering from 5V will give you the 'stereo average' output. If you want left or right channel only, or if you are powering from non-5V power, you may need to experiment with different resistors to get the desired voltage on SD

Audio Library

Running two SPI devices at once