A Spotify player display implementation using ESP32 and an OLED I2C display.
This project displays Spotify playback information on an OLED screen connected to an ESP32 microcontroller.
For desmonstration and testing purposes, a simulated prototype is available at Wokwi (an online ESP32 simulator).
Note
This project is developed and tested on Linux-based systems. Compatibility with other operating systems is not guaranteed.
- ESP32 (or compatible board)
- OLED 128x64 Display (SSD1306 or similar)
- USB cable for programming
- I2C connection cables
- Arduino IDE with ESP32 support
- u8g2 library for display control
- Linux-based system
- playerctl
- Spotify1
- Install playerctl (installation guide)
- Clone this repository
- Compile the serial communication program:
gcc -o playerctl_to_serial playerctl_to_serial.c -lpthread
Execute the compiled binary:
./playerctl_to_serial [--port=SERIAL_PORT] [--baud=BAUD_RATE]
Default values:
- Port:
/dev/ttyACM0
- Baud:
1152000
Example:
./playerctl_to_serial -p /dev/ttyUSB0 -b 9600
Configure your OLED display controller in esp32-spotify-player.ino
:
// initialization for the 128x64px OLED display
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
See supported controllers for options.
Serial data format:
status;volume%;title;artist;current_position;time_left;full_time;percentage_position;
1;69%;Open Hearts;The Weeknd;1:21;-2:33;3:54;34;
Display Output:
Important
- Verify serial port connection
- Check playerctl installation
- Confirm display I2C connection
Error display:
- The serial communication program not stop to comunicate with the port when the ESP32 is disconnected.
- Songs with too long titles or artists may not fit the display was shown by the example below:
Footnotes
-
While Spotify is the default player, others can be used by modifying the
playerctl_to_serial.c
file. ↩