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
MPY tool - manage files on devices running MicroPython

mpytool MPY tool - manage files on devices running MicroPython It is an alternative to ampy Target of this project is to make more clean code, faster,

Pavel Revak 5 Aug 17, 2022
Control DJI Tello with Raspberry Pi and PS4 Controller

Control-DJI-Tello-with-Raspberry-Pi-and-PS4-Controller Demo of this project see

MohammadReza Sharifi 24 Aug 11, 2022
This repository contains all the code and files needed to simulate the notspot quadrupedal robot using Gazebo and ROS.

Notspot robot simulation - Python version This repository contains all the files and code needed to simulate the notspot quadrupedal robot using Gazeb

50 Sep 26, 2022
Home Assistant component to handle key atom

KeyAtome Home Assistant component to handle key atom, a Linky-compatible device made by Total/Direct-Energie. Installation Either use HACS (default),

18 Dec 21, 2022
This Home Assistant custom component adds support for controlling Midea dehumidiferes on local network.

This is a custom component for Home assistant that adds support for Midea dehumidifier appliances via the local area network. midea-dehumidifier-lan H

Nenad Bogojevic 97 Jan 08, 2023
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
Tools and documentation to aid in modifying the ADI ADALM Pluto firmware

Pluto firmware modifications This repository contains tools and documentation to aid in modifying the ADI ADALM Pluto firmware. Extraction of the Plut

Daniel Estévez 28 Dec 21, 2022
Pylorawan is a Micropython wrapper for lorawan devices from RAK Wireless.

pylorawan Pylorawan is a Micropython wrapper for lorawan devices from RAK Wireless. Tested on a Raspberry PI Pico with a RAK4200(H) Evaluation Board (

Peter Houghton 3 Nov 04, 2022
OpenStickFirmware is open source software designed to handle any and all tasks required in a custom Fight Stick

OpenStickFirmware is open source software designed to handle any and all tasks required in a custom Fight Stick. It can handle being the brains of your entire stick, or just handling the bells and wh

Sleep Unit 23 Nov 24, 2022
Real-time Coastal Monitoring at the University of Hawaii at Manoa

Coastal Monitoring at the University of Manoa Source code for Beaglebone/RPi-based data loggers, shore internet gateways, and web server. Software dev

Stanley Lio 7 Dec 07, 2021
Automate gate/garage door opening via 433.92MHz emitter with Raspberry Pi, Home Assistant and Homekit.

Automate opening your garage door / gate Summary This project sums up how I automated opening my garage door using a Raspberry PI, a 433Mhz emitter, H

Julien Fouilhé 29 Nov 30, 2022
ESP32 micropython implementation of Art-Net client

E_uArtnet ESP32 micropython implementation of Art-Net client Instalation Use thonny Open the root folder in thonny and upload the Empire folder like i

2 Dec 07, 2021
SALUS THERMOSTAT Custom component for Home-Assistant

Home-Assistant Custom Components Custom Components for Home-Assistant (http://www.home-assistant.io) Salus Thermostat Climate Component My device is R

21 Dec 18, 2022
Python para microcontroladores com MicroPyhton

MicroPython - PyBR2021 Python para microcontroladores com MicroPyhton Repositório de exemplos para tutorial "Python para microcontroladores com MicroP

gabriel aragão 1 Oct 18, 2021
Python library to interact with the GCE Electronics IPX800 device

A python library to control a GCE-Electronics IPX800 V4 device through its API.

Marc-Aurèle Brothier 2 Oct 20, 2021
OctoPrint is the snappy web interface for your 3D printer!

OctoPrint OctoPrint provides a snappy web interface for controlling consumer 3D printers. It is Free Software and released under the GNU Affero Genera

OctoPrint 7.1k Jan 03, 2023
Run this code to blink your ThinkPad LED with a hidden mysterious Morse code! ;)

TMorse Run this code to blink your ThinkPad LED with a hidden mysterious Morse code! ;) Compatible with python3.9+. No third-party library is required

Mahyar 2 Jul 11, 2022
Intel Realsense t265 into Unreal Engine

t265_UE Intel Realsense t265 into Unreal Engine. Windows only, and Livelink plugin is 4.26.2 only at the moment. Might recompile it for different vers

Bjarke Aagaard 30 Jan 02, 2023
智能无人机路径规划仿真系统是一个具有操作控制精细、平台整合性强、全方向模型建立与应用自动化特点的软件

Drone智能无人机路径规划仿真系统是一个具有操作控制精细、平台整合性强、全方向模型建立与应用自动化特点的软件。它以A、B两国在C区开展无人机战争为背景,该系统的核心功能是通过仿真平台规划无人机航线,并进行验证输出,数据可导入真实无人机,使其按照规定路线精准抵达战场任一位置,支持多人多设备编队联合行动。

wwy 349 Jan 03, 2023
Python implementation of ZMP Preview Control approach for biped robot control.

ZMP Preview Control This is the Python implementation of ZMP Preview Control app

Chaobin 24 Dec 19, 2022