/micropython-spotify-status-display

"Currently playing" display for Spotify with play/pause/next/save controls

Primary LanguagePythonMIT LicenseMIT

micropython-spotify-status-display

MicroPython implementation for ESP32 using a small OLED display to show the "currently playing" information of a Spotify playback device. Two buttons can optionally be added for controlling the playback device. For intended usability, having the buttons is highly recommended.

2.42" OLED in 3D printed case

Features

  • "currently playing" information with progress bar
    • artist + track
    • show/podcast + episode
  • playback control (optional)
    • play / pause
    • next track
    • pause after current track
    • add current track to library
  • configurable poll interval and behaviour
  • access token stored in device after initial login
  • buzzer (optional) for confirming button presses
  • screensaver for standby mode
  • self contained implementation
  • custom 3D printable case with lid

Requirements

  • ESP32 with MicroPython 1.14 or later
    • version 1.18 or later recommended
  • SSD1306 or SSD1309 compatible 128x64 pixel OLED display in i2c mode
  • wlan connectivity
  • Spotify account
    • Premium needed for playback control
  • control buttons (optional)
  • buzzer (optional)

See also beginning of Case.md for a full list of needed components for building the cased solution shown above.

Limitations

  • buttons don't react during api requests / server communication
  • buttons require Spotify Premium due to api restrictions
  • default font supports mainly us-ascii characters
    • unsupported western characters are however automatically mapped to closest us-ascii equivalents
  • playback device isn't aware of the status display resulting in delayed status changes when the playback device is directly controlled

TODO

  • better handling of rare cases of ECONNABORTED followed with EHOSTUNREACH which gets displayed
  • async api requests / server communication (if possible)

Building it

Controls

Left button Right button
active, short press play / pause / resume next track
active, long press save track pause after current track
standby wake up and resume playback wake up

Long press is >= 500 ms by default.

Included 3rd party implementations

file description
ssd1306.py based on https://github.com/adafruit/micropython-adafruit-ssd1306
uurequests.py based on https://github.com/pfalcon/pycopy-lib/blob/master/uurequests/uurequests.py
helpers.py reduced from https://github.com/blainegarrett/urequests2