Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/Egge21M/BitcoinPriceLED


https://github.com/Egge21M/BitcoinPriceLED

Last synced: about 2 months ago
JSON representation

Lists

README

        

# BitcoinPriceLED

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

![Prototype V1](/pictures/LED.jpg)
*BitcoinPriceLED in a prototype case made by [HODLITEMS](https://hodlitems.com/).*

## Content
[BitcoinPriceLED](#bitcoinpriceled)
* [Hardware](#hardware)
* [Color scale](#color-scale)
* [๐Ÿ› ๏ธ Installation](#%EF%B8%8F-installation)
+ [๐Ÿ’ฟ Flashing the OS (& enabling SSH and Wifi)](#-flashing-the-os--enabling-ssh-and-wifi)
+ [๐Ÿ”จ Assembly](#-assembly)
+ [๐Ÿ‘จโ€๐Ÿ’ป Logging in via SSH](#-logging-in-via-ssh)
+ [๐Ÿ—๏ธ Install dependencies](#%EF%B8%8F-install-dependencies)
+ [๐Ÿšง Install LED-HAT Python Library](#-install-led-hat-python-library)
+ [๐Ÿ“ Download BitcoinPriceLED](#-download-bitcoinpriceled)
+ [๐Ÿ‘ท Creating systemd services](#-creating-systemd-services)
- [Creating led.service](#creating-ledservice)
- [Creating ledServer.service](#creating-ledserverservice)
* [๐Ÿงฐ Optional: Configure your BitcoinPriceLED](#-optional-configure-your-bitcoinpriceled)
- [๐ŸŽจ Static](#-static)
- [โฑ๏ธ Interval](#%EF%B8%8F-interval)
- [๐Ÿ’ค Nightmode](#-nightmode)
* [๐Ÿงก Donations](#-donations)

## Hardware

* Raspberry Pi Zero WH [amazon](https://www.amazon.de/Raspberry-Pi-Zero-WH/dp/B07BHMRTTY)
* Waveshare RGB LED Hat [amazon](https://www.amazon.de/Waveshare-RGB-LED-HAT-Expansion/dp/B06ZYLC1BJ)
* Micro SD Card [amazon](https://www.amazon.de/SanDisk-Ultra-microSDHC-Speicherkarte-Adapter/dp/B073K14CVB)
* 1A/5W USB Charger
* Micro-USB Cable

* HODLITEMS Case [HODLITEMS](https://hodlitems.com/shop/)

(no ref links, if you want to support me check out [๐Ÿงก Donations](#-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](/pictures/Farbskala.png)

### Web-Remote

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

![Webinterface](/pictures/Webinterface.jpg)

## ๐Ÿ› ๏ธ 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](https://www.raspberrypi.org/software/). 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](https://www.raspberrypi.org/software/operating-systems/).

### ๐Ÿ”จ 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

```shell
ssh pi@
```

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.

```shell
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)

```shell
sudo pip3 install rpi_ws281x flask
```

### ๐Ÿ“ Download BitcoinPriceLED

Use Git to clone this repository onto your Raspberry Pi

```shell
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'

```shell
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.

```shell
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

```shell
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

```shell
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](https://tallyco.in/Egge/)