Python application, displaying currently played track from Spotify on OLED display connected via I2C

Related tags

HardwareSpotifyOLED
Overview

RaspberryPi Spotify OLED Display

This application will display currently played track on SSD1306 OLED display connected to RaspberryPi.

Displayed stuff:

  • Current track/album/artist (in case it's too long for screen, it will scroll)
  • Track time and progress
  • Current status (playing/stopped)
  • Progress bar

pic rel

How to run

First, you have to create an application in your Spotify dashboard: https://developer.spotify.com/dashboard/applications

After you've done that, go to the app page and look for Client ID and Client Secret. You'll also need redirect URI, i'm using http://localhost:16969/callback because i have literally no clue what it's used for and it just works.

After that, install dependencies required for this app:

# this should be in repo and since Pillow uses C libs, it's probably better to install it that way
sudo apt install python3-pil python3-pip
# get the rest of dependencies with pip
pip3 install spotipy schedule adafruit-circuitpython-ssd1306

Then, i recommend creating a script that'll set environmental variables for Spotipy so it'll run. I'm using something like this:

#!/bin/sh
# Setup the environment for Spotipy
export SPOTIPY_CLIENT_ID='YOUR_CLIENT_ID'
export SPOTIPY_CLIENT_SECRET='YOUR_CLIENT_SECRET'
export SPOTIPY_REDIRECT_URI='http://localhost:16969/callback'

# Note: change the paths if necessary.
# cd to the directory you'll want to keep the cache and logs it.
# make sure you have write permissions there, otherwise it won't work
# and spotipy will keep asking for API key.
cd /home/pi/SpotifyOLED
python app.py

After that, give this script permissions to run (assuming you saved it as run.sh -> chmod +x run.sh), and RUN IT FOR THE FIRST TIME MANUALLY. Then, check the terminal window - you should see a message saying Go to the following URL - copy and paste this URL to your browser, and when it finishes loading (and it will fail if you've set the redirect URI to localhost, so don't worry about it, it's perfectly fine) copy the URL from browser and paste it to the terminal. After that, there should be .cache file created with your API key, and the script should start running normally.

How to run at boot?

Edit /etc/rc.local as superuser with your favourite editor. You'll probably see something like this there:

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

exit 0

Remove the exit 0 line, and add this instead (obviously change the path, if it's different for you):

bash -c '/home/pi/SpotifyOLED/run.sh > /home/pi/SpotifyOLED/stdout.log 2>&1' &

This will run the script in background, redirecting the standard output and standard error output to /home/pi/SpotifyOLED/stdout.log file (in case there's some critical error, it'll be there instead of going nowhere) - if the app crashes, please provide the message from this file in issue report.

There's also log in spotify_display.log file, which should be in script working directory. In case something is going wrong with Spotify API, all the messages will go there. If you wanna diagnose the issues in detail, change the log level in app.py from INFO to DEBUG

Owner
Wojciech Olech
C, C++, Python and embedded stuff (Arduino, STM32, ESP8266)
Wojciech Olech
A python script for macOS to enable scrolling with the 3M ergonomic mouse EM500GPS in any application.

A python script for macOS to enable scrolling with the 3M ergonomic mouse EM500GPS in any application.

3 Feb 19, 2022
A global contest to grow and monitor your own food with Raspberry Pi

growlab A global contest to grow and monitor your own food with Raspberry Pi A capture from phototimer of my seed tray with a wide-angle camera positi

Alex Ellis 442 Dec 23, 2022
Uses the Duke Energy Gateway to import near real time energy usage into Home Assistant

Duke Energy Gateway This is a custom integration for Home Assistant. It pulls near-real-time energy usage from Duke Energy via the Duke Energy Gateway

Michael Meli 28 Dec 23, 2022
Using a GNSS module (Beidou + GPS) and the mapquest static map API

Using a GNSS module (Beidou + GPS) and the mapquest static map API

Kongduino 1 Nov 04, 2021
Create (templateable) cameras that display qr codes in homeassistant

QRCam This custom component creates cameras displaying qrcodes. The QRCodes can be static or generated from templates. If you use a template as conten

Jannes Müller 5 Oct 06, 2022
Yet another automation project because a smart light is more than just on or off.

Automate home Yet another home automation project because a smart light is more than just on or off. Overview When talking about home automation there

Maja Massarini 62 Oct 10, 2022
An alternative to Demise-Assistant-Batch made entirely in Python for more capabilities.

Demise-Assistant-Python An alternative to Demise-Assistant-Batch made entirely in Python for more capabilities. IMPORTANT NOTE Demise-Assistant-Batch

SkelOrganisation 1 Nov 24, 2021
🌱 - WebhookHard◞ Fines Educativos ◟

v1.0.0 WebhookHardware ¿Que es WebhookHardware? WebhookHardware se trata de un proyecto tratado para sacar informacion sobre el hardware de tus victim

3 Jun 14, 2021
A Home Assistant sensor that tells you what holiday is next

Next Holiday Sensor This sensor tells you what holiday is coming up next. You can use it to set holiday light colors or other scenes. The state of the

Nick Touran 20 Dec 04, 2022
A simple portable USB MIDI controller based on Raspberry-PI Pico and a 16-button keypad, written in Circuit Python

RPI-Pico-16-BTn-MIDI-Controller-using-CircuitPython A simple portable USB MIDI controller based on Raspberry-PI Pico, written in Circuit Python. Link

Rounak Dutta 3 Dec 04, 2022
从零开始打造一个智能家居系统

SweetHome 从零开始打造智能家居系统的尝试,主要的实现有 可以扫码添加设备并控制设备的Android App 可以控制亮灭的灯,并可以设置在Android App连接到指定Wifi后自动亮起 可以控制开关的窗帘,机械结构部分自己设计并3D打印出来 树莓派主控,实现Http请求接口和ZigBe

金榜 5 May 01, 2022
KIRI - Keyboard Interception, Remapping, and Injection using Raspberry Pi as an HID Proxy.

KIRI - Keyboard Interception, Remapping and Injection using Raspberry Pi as a HID Proxy. Near limitless abilities for a keyboard warrior. Features Sim

Viggo Falster 10 Dec 23, 2022
SPI driven CircuitPython driver for PCA9745B constant current LED driver.

Introduction THIS IS VERY MUCH ALPHA AND IN ACTIVE DEVELOPMENT. THINGS WILL BREAK! THIS MAY ALSO BREAK YOUR THINGS! SPI driven CircuitPython driver fo

Andrew Ferguson 1 Jan 14, 2022
Programming of Robotics Systems course at the University of Aveiro, Portugal, 2021-2022.

Programação de Sistemas Robóticos Miguel Riem Oliveira Universidade de Aveiro 2021-2022 Projeto AtlasCar Projecto RACE IROS 2014 AtlasCar2 ATOM IROS 2

Miguel Riem de Oliveira 22 Jul 13, 2022
Alternative firmware for ESP8266 with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at

Alternative firmware for ESP8266/ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability

Theo Arends 59 Dec 26, 2022
A Fast, Easy, and User Friendly way to control Robotics Actuators.

T-Motor Controller A Fast, Easy, and User Friendly way to control Robotics Actuators. View Demo · Report Bug · Request Feature Table of Contents About

26 Aug 23, 2022
Modeling and Simulation of Satellite Servicing Manipulators

Modeling and Simulation of Satellite Servicing Manipulators Final Project for the course ENPM662: Introduction to Robot Modeling (Fall 2021). This pro

Adarsh M 1 Jan 24, 2022
Self Driving Car Prototype

Package Delivery Rover 🚀 This project is a prototype of Self Driving Car. It's based on embedded systems, to meet the current requirement of delivery

Abhishek Pawar 1 Oct 31, 2021
A low power 1U Raspberry Pi cluster server for inexpensive colocation.

Raspberry Pi 1U Server There are server colocation providers that allow hosting a 1U server for as low as $30/month, but there's a catch: There are re

Paul Brown 627 Dec 31, 2022
Minimal and clean dashboard to visualize some stats of Pi-Hole with an E-Ink display attached to your Raspberry Pi

Clean Dashboard for Pi-Hole Minimal and clean dashboard to visualize some stats of Pi-Hole with an E-Ink display attached to your Raspberry Pi.

Alessio Santoru 104 Dec 14, 2022