Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

phosphore/zero-stock-screen

Open more actions menu
 
 

Repository files navigation

Zero BTC Screen

Bitcoin (or any other asset) price for your RPi Zero

display

Hardware

Platform

  • Raspberry Pi Zero W
  • Raspberry Pi 3b+
  • Raspberry Pi 4
  • Any other modern RPi

Supported displays

  • Waveshare eInk types:
    • epd2in13v2
    • epd2in13v3
    • epd2in13bv3
    • epd2in7
    • epd3in7
  • inkyWhat (Red, Black, White)
  • Virtual (picture)

Installation

  1. Turn on SPI via sudo raspi-config

    Interfacing Options -> SPI
    
  2. Install dependencies

    sudo apt update
    sudo apt-get install python3-pip python3-numpy git
    pip3 install RPi.GPIO spidev pillow
    
  3. Install drivers for your display (you don't need to install both)

    1. If you have a Waveshare display
    git clone https://github.com/waveshare/e-Paper.git ~/e-Paper
    pip3 install ~/e-Paper/RaspberryPi_JetsonNano/python/
    
    1. If you have an Inky wHAT display
    pip3 install inky[rpi]
    
  4. Download Zero BTC Screen

    git clone https://github.com/dr-mod/zero-btc-screen.git ~/zero-btc-screen
    
  5. Run it

    python3 ~/zero-btc-screen/main.py
    

Screen configuration

The application supports multiple types of e-ink screens, and an additional "picture" screen.

To configure which display(s) to use, configuration.cfg should be modified. In the following example an e-ink epd2in13v2 and "picture" screens are select:

[base]
console_logs             : false
#logs_file               : /tmp/zero-btc-screen.log
dummy_data               : false
refresh_interval_minutes : 15
# Data API base URL (must serve /products/{ticker}/candles like Coinbase)
data_api_base_url        : https://api.exchange.coinbase.com
# Price pair from Coinbase (BTC-EUR, ADA-GBP) or a stock/ETF ticker from your API
ticker                   : BTC-USD
# Optional label shown on the screen (defaults to first part of ticker)
#ticker_label            : BTC

# Enabled screens or devices
screens : [
    epd2in13v2
#    epd2in13v3
#    epd2in13bv3
#    epd2in7
#    epd3in7
    picture
#    inkyWhatRBW
  ]

# Configuration per screen
# This doesn't make any effect if screens are not enabled above
[epd2in13v2]
mode : candle

[epd2in13v3]
mode : candle

[epd2in13bv3]
mode : line

[epd2in7]
mode : candle

[epd3in7]
mode : candle

[picture]
filename : /home/pi/output.png

[inkyWhatRBW]
mode : candle

Custom stock/ETF data

To use arbitrary stock or ETF tickers, host a small service that matches Coinbase's /products/{ticker}/candles response format. The endpoint should return a JSON array of arrays:

[
  [time, low, high, open, close, volume],
  ...
]

Configure data_api_base_url to point to your service and set ticker to the symbol you want to display.

Finnhub PHP proxy example

This repo includes finnhub_candles.php, a small proxy that translates Finnhub candles into the Coinbase /products/{ticker}/candles format. Deploy it on your hosting and point data_api_base_url to the host:

https://your-host.example.com

Example request:

https://your-host.example.com/products/AAPL/candles?granularity=900&start=2024-01-01T00:00&end=2024-01-02T00:00&token=YOUR_FINNHUB_KEY

The script accepts the Finnhub API token via token=..., the X-Finnhub-Token header, or the FINNHUB_TOKEN environment variable.

Autostart

To make it run on startup you can choose from 2 options:

  1. Using the rc.local file
    1. sudo nano /etc/rc.local
    2. Add one the following before exit 0
    /usr/bin/python3 /home/pi/zero-btc-screen/main.py &
    
    conversely, you can run in screen you can install it with sudo apt-get install screen
    su - pi -c "/usr/bin/screen -dm sh -c '/usr/bin/python3 /home/pi/zero-btc-screen/main.py'"
    
  2. Using the system's services daemon
    1. Create a new service configuration file

       sudo nano /etc/systemd/system/btc-screen.service
      
    2. Copy and paste the following into the service configuration file and change any settings to match your environment

       [Unit]
       Description=zero-btc-screen
       After=network.target
      
       [Service]
       ExecStart=/usr/bin/python3 -u main.py
       WorkingDirectory=/home/pi/zero-btc-screen
       StandardOutput=inherit
       StandardError=inherit
       Restart=always
       User=pi
      
       [Install]
       WantedBy=multi-user.target
      
    3. Enable the service so that it starts whenever the RPi is rebooted

       sudo systemctl enable btc-screen.service
      
    4. Start the service and enjoy!

       sudo systemctl start btc-screen.service
      

      If you need to troubleshoot you can use the logging configurations of this program (mentioned below). Alternatively, you can check to see if there is any output in the system service logging.

       sudo journalctl -f -u btc-screen.service
      

Support the project

If you would like to support this project and and keep me caffeinated, you can do it here:

"Buy Me A Coffee"

About

Stock price for RPi Zero

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.