Skip to content

BoardApple/PiBoard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PiBoard

Simple Dashboard for the Raspberry Pi

This is a simple project I made for an old Raspberry Pi 4 Model B. Sorry in advance if I get any of the information wrong, or if this doesn’t work on every version of the Raspberry Pi.

This was built specifically for a Raspberry Pi 4 Model B with an 800x480 touchscreen that I bought from Temu, but it should work on other setups with little to no modification.

PiBoard Demo

Demo of PiBoard running on a Browser (not on pi)


Requirements

  • Raspberry Pi (I used a Pi 4 Model B, but this should run on lower-spec models as well.)

  • Touchscreen (optional) The dashboard was designed for a Pi with a screen, but it can still be used without one.

  • Spotify Premium subscription (optional) The Spotify page was built around Premium features, but the rest of the dashboard will still work without it.


Walkthrough

1. Create a Spotify Developer App

To begin, go to https://developer.spotify.com/ and create a new app. Give it a name and a description, then add the following as a Redirect URI:

http://127.0.0.1:8888/callback/

If you want to use a different redirect URI, just remember to update it later in config.env.

Make sure Web API is checked, then save the app.


2. Set up your Raspberry Pi

Now head over to your Raspberry Pi and install Node.js:

sudo apt install nodejs npm

Once that's installed, clone the repository:

git clone https://github.com/BoardApple/PiBoard

3. Configure the dashboard

Before running anything, you’ll need to set up the configuration file.

Configuration file

PiBoard uses a simple environment file to keep all configuration in one place.

In the project root you’ll find a file called config.env-example. To use it:

  1. Change into the PiBoard directory
  2. Make a copy of the file
  3. Remove -example from the name so it becomes config.env
cd PiBoard
cp config.env-example config.env

Open config.env and update the following values:


Spotify
  • SPOTIFY_CLIENT_ID → Client ID from your Spotify Developer app
  • SPOTIFY_REDIRECT_URI → Redirect URI (only change this if you changed it in the Spotify app settings)
  • SPOTIFY_OVERLAY_ENABLED → Enable or disable the small Spotify overlay on the first page (true or false)

Weather (optional)

To enable the weather overlay, you’ll need a free WeatherAPI account.

  1. Go to https://www.weatherapi.com and create a free account
  2. Once logged in, copy your API Key from the dashboard

Then update the following values in config.env:

  • WEATHER_ENABLED → Turn weather section on or off (true or false)
  • WEATHER_API_KEY → Your WeatherAPI key
  • WEATHER_LOCATION → Your location (city name, town, or postcode)

Power Button (optional)

You can also enable or disable the power button in the top right:

  • POWER_BUTTON_ENABLED → Enable or disable the power button (true or false)

Refresh Button (optional)

You can enable or disable the refresh button in the top left:

  • REFRESH_BUTTON_ENABLED → Enable or disable the refresh button (true or false)

System Info Overlay (optional)

You can enable or disable a little system overlay in the top right that display's CPU and RAM usage by changing the value in config.env:

  • SYSTEM_OVERLAY_ENABLED → Enable or disable the system info overlay (true or false)

Date & Time

To change the date and time settings, edit the following values in config.env:

  • TIMEZONE → Timezone in IANA format (e.g. Europe/London, America/New_York)
  • LOCALE → Locale used for date and time text
  • TIME_24H → Choose between a 24-hour clock or 12-hour clock (true or false)
  • DATE_FORMAT → Date display format. Supported values:
    • dddd = weekday name (Sunday)
    • Do = date with ordinal (10th)
    • MMMM = full month name (October)
    • YYYY = year (2024)

List of supported locale codes:
https://saimana.com/list-of-country-locale-code/

Once these values are filled, save the file. The server will automatically load them on startup.


4. Install dependencies

Now change into the project directory and install the required dependencies:

cd PiBoard
npm install

This may take a couple of minutes. Once it finishes, everything needed to run the dashboard will be installed.


5. Run the server

To start the server manually, run:

node server.js

Then open a browser and go to:

http://127.0.0.1:8888/

From here:

  • Double-tap the screen (or click the second button at the top) to open the Spotify page
  • Click Connect to Spotify or go to /login and go through the authorization steps

Once that’s finished, start playing music on any other device and you’ll have a simple Spotify media controller running on your Pi.


Open on Startup (Kiosk Mode)

If you want the server to start automatically and open the dashboard when the Pi boots, follow the steps below.

Create a startup script

Create a file called run.sh (you can place this anywhere):

nano ~/run.sh

Add the following:
(Make sure to change ~/PiBoard to wherever you saved it)

#!/bin/bash

cd ~/PiBoard
node server.js &

sleep 10
DISPLAY=:0 firefox -kiosk http://127.0.0.1:8888

Save the file and exit, then make it executable:
(Make sure to change ~/run.sh to wherever you saved the script)

chmod +x ~/run.sh

Create a systemd service

Now create a systemd service file so this runs automatically on boot:

sudo nano /etc/systemd/system/piboard.service

Add the following:

Make sure to update these values:

  • pi - Change to your username
  • /home/pi/run.sh - Change to wherever you saved the script
[Unit]
# PiBoard dashboard startup service
Description=PiBoard Startup Script

# Wait for the desktop environment and network to be ready
After=graphical.target network-online.target
Wants=network-online.target

[Service]
# Simple service that runs continuously
Type=simple

# Run as the user (required for Firefox/X access)
User=pi

# Specify the display for kiosk mode
Environment=DISPLAY=:0

# Use the current X session authentication
Environment=XAUTHORITY=/home/pi/.Xauthority

# Start the PiBoard launch script
ExecStart=/home/pi/run.sh

# Restart the service if it crashes
Restart=on-failure
RestartSec=5

[Install]
# Start when the graphical session is loaded
WantedBy=graphical.target

Save and exit, then reload and enable the service:

sudo systemctl daemon-reload
sudo systemctl enable piboard.service

Final step

Reboot your Raspberry Pi:

sudo reboot

Once the Pi boots, the server will start automatically and the dashboard will open in kiosk mode.


Resources

Below are a few resources I found helpful while working on this project:


Changelog - ʕ•ﻌ•ʔ

v1.2.2

  • Added System Info Overlay (CPU / RAM)
  • Added System Info Page (CPU / RAM / Uptime)
  • Added Spotify Overlay
  • Added Extra Buttons to Spotify Media Control Page (Like, Loop, Mute)
  • Added Refresh Button to Top Left
  • Changed Spotify Buttons to SVG Icons
  • Removed Blank "Photo" Page

v1.2.1

  • Added Shutdown Button
  • Changed Hardcoded Values to be Stored in a config.env File
  • Added Toggleable Values in config.env (Weather Overlay, Shutdown Button)
  • Updated Weather API

v1.2.0 (First Release)

  • Added Working Spotify Calls
  • Added Updated Fonts

Known Bugs

These should hopefully be updated in the next release however until then these are the current bugs:

  • After leaving it running while nothing is playing, token rotation seems to break
  • After leaving it running for a while while not playing, node server shutsdown

Fixes

I know these are not the best solutions however they work until this is updated, sorry

Reboot the pi, this can either be done by clicking the button on the side and selecting "reboot" or by opening a terminal either on the pi or through SSH and running the reboot command

sudo reboot

License

Free and open source, use for whatever you want ( ദ്ദി ˙ᗜ˙ )

About

Simple Dashboard for the Raspberry Pi (Date, Time, Weather, Spotify Media Controls)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published