ESP32 Bluetooth Volume Knob
A Bluetooth audio receiver whose rotary encoder and phone volume stay in sync both ways.
- Stars
- 3
- Forks
- 0
- Updated
- 2 mo ago
- Created
- Jan 22, 2023
- License
- MIT
I was messing around with Phil Schatzmann's library and how to use a Rotary Encoder, and then I accidentally created a Bluetooth device using a Rotary Encoder to control the volume. The device's volume will also update when the Rotary Encoder is being rotated.
In addition, when the device is inactive for 1 minute (changeable), it will enter "deep sleep" mode. In order to wake up the module, you need to connect PIN 15 of ESP32 with GND via the pull-down resistor. You can modify the auto shutdown time by changing the value of minutes in the code.
Updated: It works on Android, IOS, and Samsung Watch (Wear OS, but not sure about Tizen OS).
The built-in LED of the board will be lit up when your phone is connected to Bluetooth. Also, when you change the volume, the LED on WS2812B will also lit up depending on the volume of the device, and the number of LEDs that will illuminate is 10 (you can change the number of LEDs depending on your project)
PCM5102A
Here is the information on how to wire the PCM5102A module to the ESP32:
| PCM5102A | ESP32 |
|---|---|
| LCK | GPIO 25 |
| DIN | GPIO 14 |
| BCK | GPIO 26 |
| SCK | GND |
| GND | GND |
| VIN | 3V3 OR 5V (VIN) |

Rotary Encoder
Here is the information on how to wire the Rotary Encoder to the ESP32:
| Rotary Encoder | ESP32 |
|---|---|
| CLK | GPIO 33 |
| DT | GPIO 32 |
| GND | GND |
| VIN | 5V (VIN) |

WS2812B Led Strip
Here is the information on how to wire the WS2812B Led Strip to the ESP32:
| WS2812B | ESP32 |
|---|---|
| V+ | VIN (5V) or 3.3V |
| Data In | GPIO 18 |
| GND | GND |

Library Requirements
https://github.com/pschatzmann/ESP32-A2DP
https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-installation
LICENSE
MIT LICENSED
Related
Arduino GIGA Bluetooth Audio
Custom Bluetooth Classic A2DP and BLE GATT library for Arduino GIGA R1 WiFi: PCM5102A I2S, STM32H747 ARM codec ports and lazy memory allocation. In active development.
ESP32-S31 Multi-Codec Sink
Multi-codec Bluetooth A2DP audio sink for the ESP32-S31 on ESP-IDF v6.1 — LDAC, aptX/HD/LL, LHDC-v5, Opus, LC3plus, AAC, SBC. Runs entirely on internal SRAM
ESP32 Hi-Fi A2DP Sink
ESP32 hi-res Bluetooth speaker firmware: A2DP sink + AVRCP with LDAC, LHDC V5 (192 kHz/24-bit), aptX, aptX HD, AAC, SBC, Opus and Samsung SSC decoders. Own BT host stack, ESP-IDF 6.1.