Giter VIP home page Giter VIP logo

epaper-spotify-clock's Introduction

RaspberryPi E-Paper Spotify Clock

๐Ÿ•ฐ๏ธ Quick Project Overview

This is a E-Paper Clock built with Python3 to display two users' recent Spotify history, and the local weather. Written for Waveshare's 4.2 e-paper display, the E-Paper Clock uses Spotify's API via Spotipy to display the recent listening information, and the OpenWeathermap API to get the current and forecasted local weather. Email me, [email protected], if you have any questions regarding the implementation, suggestions to improve the project, or if you built one yourself!

2024 rewrite notes

Install imagemagick via sudo apt-get install imagemagick as it's used in dither_image()

โŒ› Quick Install Guide

Waveshare provides a set of instructions under the Hardware/Software setup tab to install the libraries required to drive the display. I'm using a Raspberry Pi Zero W running this bash script in rc.local to run mainSpotifyClock.py. Three custom Python modules were used, Spotipy, Requests, and Pillow aka PIL, all of which can be installed using Pip. Openweathermap gets the current weather and forecast, and the Spotipy wrapper interfaces with Spotify's API

Drive the EPD, call necessary functions -> mainSpotifyClock.py

Image and Front Resources -> Icons and Fonts

โณ Full Instillation Guide

  1. In the 'Hardware/Software setup' tab of Waveshare's 4.2inch wiki, use the GPIO guide to attach the display to the Pi

  2. Enable SPI interface by launching raspi-config, choosing 'Interfacing Options', 'SPI', Yes to enable SPI interface

sudo raspi-config
# Interfacing Options -> SPI -> Yes
  1. Install Python libraries
sudo apt-get update
sudo apt-get install git python3-pip python3-pil python3-numpy
sudo pip3 install RPi.GPIO
sudo pip3 install spidev
sudo pip3 install spotipy
sudo pip3 install requests

As an aside, sudo pip install is generally frowned upon, but these are popular and vetted packages which won't pose security threats to your system

  1. Download Waveshare Examples and Python Libraries
sudo git clone https://github.com/waveshare/e-Paper
  1. Navigate to Pi/Python folder, and Install 'waveshare-epd' Python module from setup.py
cd e-Paper/RaspberryPi\&JetsonNano/python
sudo python3 setup.py install
  1. Navigate to Pi/Python/examples folder, and run the Waveshare's provided example file to make sure the wiring is correct
cd examples
sudo python3 epd4in2.py
  1. Clone this repository into the examples folder
sudo git clone https://github.com/alexthescott/ePaper-Spotify-Clock
  1. Use a text editor such as Vim, Emacs or nano open launch_epaper.sh and replace YOUR_USERNAME, then move file into your home directory
# If you choose Vim, first open the file
vim launch_epaper.sh
# Press i for insert mode, replace USERNAME, then write and quit with :wq
:wq
# Move to launch_epaper.sh to home directory
mv launch_epaper.sh /$HOME
  1. For both Spotify users, login to the Spotify Developer Portal, create an app, write down the Client ID and Client Secret as we will use these later

  2. On the Spotify Developer Portal, add http://www.google.com/ as the Redirect URI, and save at the bottom

  3. Create a free OpenWeatherMap account, and navigate to your profile, and then API keys. Generate and store a new key as it will be inserted into mainSpotifyEPD.py

  4. Using a text editor, place the generated Spotify Client Id, Client Secret and openWeatherMap key into config/keys.json

  5. Navigate to your home directory, make launch_epaper.sh an executable, and then run it as the super user

cd $HOME
chmod +x launch_epaper.sh
sudo ./launch_epaper.sh
  1. You will be asked to paste two URLs into a web browser to link the Spotify accounts to the project. The first request corresponds with the user on the left, and the second request corresponds with the user on the right. After accepting Spotify's terms, copy and paste the full Google url back into the terminal.

  2. If everything runs well, consider adding launch_epaper.sh to rc.local which runs at boot

sudo vim /etc/rc.local
# above exit 0, add 'bash /home/YOUR_USERNAME/launch_epaper.sh &'
  1. Give yourself three cheers for following along and building the project! Huzzah ๐ŸŽ‰

If you made this project, I'd love to see it! Send me an email with a photo of your finished project

epaper-spotify-clock's People

Contributors

alexthescott avatar imgbotapp avatar iuc73663 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

epaper-spotify-clock's Issues

Error in new mainSpotifyEPD.py

Hey,

after updating the mainSpotifyEPD.py to your newest released version, I doesn't run.
That's the error message:

root@raspberrypi:~# bash launch_epaper.sh
File "mainSpotifyEPD.py", line 316
URL_UNITS = "&units=metric" if metric_units else url_units = "&units=imperial"
^
SyntaxError: can't assign to conditional expression

GrayScale AlbumArt

  • Currently, Album Art is given a 1bit reduction, however we're able to create and push 4 grayscale colors to the Waveshare

config.json -> album_art_on_right

  • Add ability to set the placement of Album Artwork on single_user to right or left
  • Involve a re-configuring of config.json for individual sub-single_user settings?

Resolve Gracefully 401 Spotify Response

  • Cache the last playing track, artist, context, context_type, album and show of 401 Spotify response
  • If no cached playing information, show an error message

Icon Update

  • Create "Collections" Liked Songs and "DJ" Icon for the two new context types

"New bug caught 'main'"

Trying to run this directly from python and get the following, but I'm unable to diagnose its origin:

python3 mainSpotifyEPD.py

2:40am

new bug caught

'main'

Retrying main_loop() in 20 seconds...

The ePaper doesn't render during this time and the bugs.txt file only has one line: 'main'

What's the origin of this?

Thanks!

IndentationError: unexpected unindent - localJsonIO.py

Hey,

you get an error by executing the new localJsonIO.py.
It says:

root@raspberrypi://root# bash launch_epaper.sh
Traceback (most recent call last):
File "mainSpotifyEPD.py", line 38, in
import localJsonIO as contextIO
File "/home/pi/ePaper-Spotify-Clock-master/ePaper-Spotify-Clock-master/localJsonIO.py", line 35
context_data = {}
^
IndentationError: unexpected unindent

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.