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
Python code written to utilize the Korlan usb2can hardware to send and receive data over the can-bus on a 2008 Nissan 350z

nissan_ecu_hacking Python code written to utilize the Korlan usb2can hardware to send and receive data over the can-bus on a 2008 Nissan 350z My goal

Liam Goss 11 Sep 24, 2022
Hardware-accelerated ROS2 packages for camera image processing.

Isaac ROS Image Pipeline Overview This metapackage offers similar functionality as the standard, CPU-based image_pipeline metapackage, but does so by

NVIDIA Isaac ROS 52 Dec 15, 2022
Lenovo Legion 5 Pro 2021 Linux RGB Keyboard Light Controller

Lenovo Legion 5 Pro 2021 Linux RGB Keyboard Light Controller This util allows to drive RGB keyboard light on Lenovo Legion 5 Pro 2021 Laptop Requireme

36 Dec 16, 2022
Port of Uxn to digital hardware in the Logisim simulator

Uxn-Logisim Implements the Uxn instruction set in digital hardware. Very WIP. Contents cpu.circ - The Logisim file microcode.mc - Microcode source fil

DeltaF1 11 Mar 27, 2022
I made this so I can control my Tapo L510 light bulb and Govee H6159 light strip using the PyP100 module and the Govee public API

TAPO-And-Govee-Controller I made this so I can control my Tapo L510 light bulb and Govee H6159 light strip using the PyP100 module and the Govee publi

James Westhead 0 Nov 23, 2021
Philippe 1 Jan 09, 2022
Open source home automation that puts local control and privacy first.

Home Assistant Open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiast

Home Assistant 57k Jan 01, 2023
🏡 My Home Assistant Configs. Be sure to 🌟 my repo to follow the updates!

Home Assistant Configuration Here's my Home Assistant configuration. I have installed HA on a Lenovo ThinkCentre M93P Tiny with an Intel Dual-Core i5-

iLyas Bakouch 25 Dec 30, 2022
Final-project-robokeeper created by GitHub Classroom

RoboKeeper! Jonny Bosnich, Joshua Cho, Lio Liang, Marco Morales, Cody Nichoson Demonstration Videos Grabbing the paddle: https://youtu.be/N0HPvFNHrTw

Cody Nichoson 1 Dec 12, 2021
Simple python3 implementation of microKanren with lots of type annotations for clarity

MicroKanren-py This is (yet another) python implementation of microKanren. It's a reasonably 1:1 translation of the code provided in the paper, but ev

Erik Derohanian 3 Dec 10, 2022
The software that powers the sPot: a 4th generation

This code is meant to accompany this project in which a Spotify client is built into an iPod "Classic" from 2004. Everything is meant to run on a Raspberry Pi Zero W.

Guy Dupont 683 Dec 28, 2022
This is a python script to grab data from Zyxel NSA310 NAS and display in Home Asisstant as sensors.

Home-Assistant Python Scripts Python Scripts for Home-Assistant (http://www.home-assistant.io) Zyxel-NSA310-Home-Assistant Monitoring This is a python

6 Oct 31, 2022
Designed and coded a password manager in Python with Arduino integration

Designed and coded a password manager in Python with Arduino integration. The Program uses a master user to login, and stores account data such as usernames and passwords to the master user. While lo

Noah Colbourne 1 Jan 16, 2022
Like htop (CPU and memory usage), but for your case LEDs. 😄

Like htop (CPU and memory usage), but for your case LEDs. 😄

Derek Anderson 3 Dec 08, 2021
This allows you to record keyboard and mouse input, and play it back using pynput.

Record and Play with Python! This allows you to record keyboard and mouse input, and play it back (with looping) using pynput. It allows for automatio

George Jensen 45 Jan 02, 2023
Create a low powered, renewable generation forecast display with a Raspberry Pi Zero & Inky wHAT.

GB Renewable Forecast Display This Raspberry Pi powered eInk display aims to give you a quick way to time your home energy usage to help balance the g

Andy Brace 32 Jul 02, 2022
Samples for robotics, node, python, and bash

RaspberryPi Robot Project Technologies: Render: intent Currently designed to act as programmable sentry.

Martin George 1 May 31, 2022
Software framework to enable agile robotic assembly applications.

ConnTact Software framework to enable agile robotic assembly applications. (Connect + Tactile) Overview Installation Development of framework was done

Southwest Research Institute Robotics 29 Dec 01, 2022
Raspberry Pi Pico and LoRaWAN from CircuitPython

Raspberry Pi Pico and LoRaWAN from CircuitPython Enable LoRaWAN communications on your Raspberry Pi Pico or any RP2040-based board using CircuitPython

Alasdair Allan 15 Oct 08, 2022
NYCT-GTFS - Real-time NYC subway data parsing for humans

NYCT-GTFS - Real-time NYC subway data parsing for humans This python library provides a human-friendly, native python interface for dealing with the N

Andrew Dickinson 37 Dec 27, 2022