Skip to content

Latest commit

 

History

History
198 lines (130 loc) · 7.13 KB

README.md

File metadata and controls

198 lines (130 loc) · 7.13 KB

BitcoinPriceLED

LED-lamp that represents the current Bitcoin price trend. Comes with a handy web-remote.

Prototype V1 BitcoinPriceLED in a prototype case made by HODLITEMS.

Content

BitcoinPriceLED

Hardware

  • Raspberry Pi Zero WH amazon

  • Waveshare RGB LED Hat amazon

  • Micro SD Card amazon

  • 1A/5W USB Charger

  • Micro-USB Cable

  • HODLITEMS Case HODLITEMS

(no ref links, if you want to support me check out 🧡 Donations)

Features

Colorscale

Current trend will be displayed using different colors. Positive trend -> green light, negative trend -> red light. Saturation is used to display percentage of price movement.

colorscale

Web-Remote

BitcoinPriceLED comes with a handy remote that is hosted accessible via your browser.

Webinterface

🛠️ Installation

💿 Flashing the OS (& enabling SSH and Wifi)

The easiest way to get your Raspberry Pi Zeros OS ready is to use the Raspberry PI Imager. Download, install and launch the software, choose "Raspberry Pi OS Lite" from "Raspberry Pi OS (other)". Hit CTRL+Shift+X to bring up the advanced options. Enable SSH (which will be used later to control your Pi), enter a password for user "pi" and setup a custom hostname (eg. led.local). Enable Wifi and enter your WIFIs ssid and passkey.

Optional: You can also configure a timezone (which might be usefull if you plan on using time-controlled features like nightmode).

You can also download and flash the OS manually. You can find all avaiable Raspberry Pi OS here.

🔨 Assembly

Insert your microSD card into your Raspberry Pi Zero and put the LED-HAT on. Then connect the power plug.

👨‍💻 Logging in via SSH

Because our device has neither a display nor any peripherals you will need to control it using SSH and another machine. On your computer open up your OS' CLI (Windows: PowerShell, MacOS/Linux: Terminal) and connect to your Pi using the follwing command

ssh pi@<hostname>

If you setup a custom hostname, replace with your custom one. If you didn't you can lookup the Pis IP by checking connected devices in your routers admin panel. Your CLI will ask you for the password you chose during the OS setup.

🏗️ Install dependencies

Before you can run the Python-code that will make your LED light up, you will need to install some depented-upon software.

sudo apt-get update
sudo apt-get install git python3-pip

🚧 Install LED-HAT Python Library

Use the packet installer for Python (pip) to install rpi_ws281x module (which is required to control the LED-HAT using Python) and Flask (which will act as a local mini-webserver that hosts the webinterface)

sudo pip3 install rpi_ws281x flask

📁 Download BitcoinPriceLED

Use Git to clone this repository onto your Raspberry Pi

git clone https://github.com/Egge7/BitcoinPriceLED.git

👷 Creating systemd services

Creating led.service

Create a systemd service that will execute our Python scripts. This will run the script on startup and in the background, so you don't need to log-in via ssh everytime your Pi looses power

create a new service file called 'led.service'

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

Insert the following lines into the service file. This will execute the Python-script on startup (after network is established) and restart whenever the service fails. It will also execute the off.py script if you stop the service (otherwise the LED panel will stay on)

[Unit]
Description=Bitcoin Price LED Service
After=network-online.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/python3 /home/pi/BitcoinPriceLED/src/main.py
ExecStopPost=/usr/bin/python3 /home/pi/BitcoinPriceLED/src/off.py

[Install]
WantedBy=multi-user.target

Creating ledServer.service

Now create a second service called ledServer.service. This second service file starts the server for the webinterface.

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

and insert the follwing lines into the service file.

[Unit]
Description=Bitcoin Price LED Server Service
After=network-online.target

[Service]
Type=simple
User=pi
Group=pi
Restart=always
ExecStart=/usr/bin/python3 /home/pi/BitcoinPriceLED/src/server/app.py

[Install]
WantedBy=multi-user.target

Reload systemctl deamon, enable the new services

sudo systemctl daemon-reload
sudo systemctl enable led
sudo systemctl enable ledServer

Reboot to check if the new service will start on startup as intended

sudo reboot

🧰 Optional: Configure your BitcoinPriceLED

By default your LED will run 24/7 and represent current price-trends in a 30 minute loop. BitcoinPriceLED comes with a webinterface to configure your LED. In your local network, simply open :5000 and adjust the settings to your liking.

🎨 Static

Default: False

This will stop your BitcoinPriceLED from representing the current Bitcoin prices and make it shine in a desired color. Simply switch on Staticmode and enter the HEX-Value (e.g. #FFFF00 for blue) of the desired color

⏱️ Interval

Default: 900

This is the time in seconds your BitcoinPriceLED will wait before fetching a new price and calculating the trend. Please be aware that a very small interval (1-10 seconds) might result in your IP address getting blocked by the API provider.

💤 Nightmode

Default: False

Nightmode dims your LED at night. In order to activate this feature set "nightmode = True" and set the time where your LED should enter and leave nightmode (beginSleep and endSleep in 24h format).

🧡 Donations

Please feel free to copy, fork and alter this project as you wish. If you would like to support me, you can leave a on-chain or lightning donation in my tip-jar