This is an old revision of the document!


ESP32 Bluetooth audio player with statistics

  • Author: Veaceslav Cazanov
  • Email: veaceslav.cazanov@stud.acs.upb.ro
  • Master: SRIC

Introduction

The project's main goal is to offer the user the possibility to stream music over Bluetooth to ESP32 which will forward the received music to a DAC. Thus, this project enables Bluetooth audio connection to speakers which lack Bluetooth support. Thanks to existing libraries, this is a fairly easy thing to implement. In order to make the project more complex and enable means of communication of ESP32 other than Bluetooth, I decided to add usage statistics tracking. In this page, I will cover general description, hardware design, software design, implementation highlights and challenges faced developing this project.

General description

How it works

This is a flow chart which represents state flow of ESP32.

Simultaneous use of Wi-Fi and Bluetooth is reportedly problematic and that's why they work mutually exclusive in this project. Gathering local statistics means gathering the artist, album, title and the cover art (if supported) of the currently playing song. Also, it means collecting the number of plays and total play time for each recorded song. The play time is the total time when song was in the 'play' state. For a play to count, a song must have a play time of a minimum 5 seconds in a playback session.

Hardware design

Parts used:

  • ESP32-WROOM
  • PCM5102A (DAC)
  • Pushbutton
  • RGB LED common cathode

The pushbutton allows to disconnect currently connected Bluetooth device. Also, if it is pressed on ESP32's startup, SPIFFS will be formatted, which means that all unsent info, known Wi-Fi networks and settings will be erased. The LED shows current status of the board. Blinking LED means that the board waits for user action: blue blinking – waiting for BT connection, yellow blinking – waiting for Wi-Fi configuration (ESP32 is in AP mode). Constant blue lighting means that there is Bluetooth device connected. Constant yellow lighting indicates ongoing connection to Wi-Fi (ESP32 in station mode) or other data transfer over Wi-Fi. PCM5102A was chosen because it can deliver PCM quality stereo-sound, with sampling frequency up to 384 kHz and resolution up to 32 bits. However, the maximum sampling rate is capped at 48kHz by SBC codec. According to subjective sound quality evaluation, the sound is good and clear, with stable transmission without stuttering.

Software design

The software part of this project is composed of:

  • ESP32 code
    • Bluetooth music streaming mode + local statistics gathering
    • Statistics transmission in Wi-Fi station role
    • Wi-Fi network provisioning
  • Python TCP server – statistics receiver
  • Nginx webserver – neat statistics presentation

ESP32 code

References

iothings/proiecte/2025sric/cv_example.1748496420.txt.gz · Last modified: 2025/05/29 08:27 by veaceslav.cazanov
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0