# HannaBox ## 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. ![](images/ESP32-wroom-32-pinout.png) ## Pins The plain number refers to the GPIO pin. ### Amplifier MAX98357A I2S 3W DAC Class D Amplifier Module ![](images/amp.png) 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 ``` 26 -> DIN 27 -> BCLK 25 -> LRC 5V -> Vin GND -> GND ``` ### SD Card Reader SD Card Reader Adapter Modul ``` CS -> 22 (D1) MOSI -> 23 (D7) CLK -> 18 (D5) MISO -> 19 (D6) ``` ### RFID Reader NFC RFID module RC522 ``` SOA -> 32 SCK -> 18 MOSI -> 23 MISO -> 19 IRQ -> NC GND -> GND RST -> 33 3.3V -> 3.3V ``` #### RFID Chip Registers 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 ### Buttons ``` Start / Stop -> 17 and GND Wake up / Next -> 04 and GND Previous -> 16 and GND ``` ## 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. ## TODOs ## Schematic without modules ### Charging circuit https://ww1.microchip.com/downloads/en/AppNotes/01149c.pdf MCP73837 ? ## Links https://github.com/earlephilhower/ESP8266Audio [Running two SPI devices at once](https://randomnerdtutorials.com/esp32-spi-communication-arduino/)