Giter VIP home page Giter VIP logo

zero-btc-screen's Introduction

Zero BTC Screen

Bitcoin (or any other currency) stock 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-pil python3-numpy git
    pip3 install RPi.GPIO spidev
    
  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
currency                 : 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

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"

zero-btc-screen's People

Contributors

dr-mod avatar martinatime avatar mauker1 avatar mayniklas avatar mspark 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zero-btc-screen's Issues

new

My name is Luis, I'm a big-data machine-learning developer, I'm a fan of your work, and I usually check your updates.

I was afraid that my savings would be eaten by inflation. I have created a powerful tool that based on past technical patterns (volatility, moving averages, statistics, trends, candlesticks, support and resistance, stock index indicators).
All the ones you know (RSI, MACD, STOCH, Bolinger Bands, SMA, DEMARK, Japanese candlesticks, ichimoku, fibonacci, williansR, balance of power, murrey math, etc) and more than 200 others.

The tool creates prediction models of correct trading points (buy signal and sell signal, every stock is good traded in time and direction).
For this I have used big data tools like pandas python, stock market libraries like: tablib, TAcharts ,pandas_ta... For data collection and calculation.
And powerful machine-learning libraries such as: Sklearn.RandomForest , Sklearn.GradientBoosting, XGBoost, Google TensorFlow and Google TensorFlow LSTM.

With the models trained with the selection of the best technical indicators, the tool is able to predict trading points (where to buy, where to sell) and send real-time alerts to Telegram or Mail. The points are calculated based on the learning of the correct trading points of the last 2 years (including the change to bear market after the rate hike).

I think it could be useful to you, to improve, I would like to share it with you, and if you are interested in improving and collaborating I am also willing, and if not file it in the box.

If tou want, Please read the readme , and in case of any problem you can contact me ,
If you are convinced try to install it with the documentation.
https://github.com/Leci37/stocks-Machine-learning-RealTime-telegram/tree/develop I appreciate the feedback

Waveshare Red-Black-White Screen

Hello, I already have the Waveshare red/black/white e-ink screen. Any idea on how to modify the code to account for the different screen? I can't seem to figure out how to get it to even turn on. Can I add the appropriate screen in myself on the screen configuration? EPD2in13bc I think is the one I need.

Exception: Could not determine Jetson model

I have the examples from waveshare up and running.

Trying to run your code: "python3 ~/zero-btc-screen/main.py"
I get the following message: "Exception: Could not determine Jetson model"
IMG_0534

Am I supposed to configure the model I'm using somewhere? I'm using a 2in13V2
Can anyone help me out here? Thank you!

Waveshare 2.13inch e-Paper HAT v2 screen update not working

It looks like I've encountered some kind of glitch/bug that affects screen update. Prices are fetching, everything seems to be working fine in the logs but I'm only able to update the prices on the screen by resetting the running program - that's the only way to update the screen.
Doesn't matter if the interval is set for 1 minute, 3 or 15.
Screenshot 2022-01-17 at 23 24 28

Any ideas what could go wrong?

Missing git dependency in guide

An amazing little project, thank you!

Just as a heads up, in your guide, for newbies out there you may want to include git as a dependency.

Simply:
sudo apt install git

Improvement: autostart with boot

Hey @dr-mod ,
I've noticed something and thought of a better way solving autostart:

Following the README, I wasn't able to get the skript to autostart.

In /etc/rc.local you are using /usr/bin/python3 /home/pi/zero-btc-screen/main.py&.
-> it won't work, because the skript is being executed from the wrong directory (e.g. the font is missing).

There are 3 ways we could easily solve this:

  1. Installing the missing font system wide
  2. Instead of executing the python skript directly, we could run a "start.sh" which would first cd into the right folder (we also could use ´crontab's @reboot' instead of using rc.local
  3. Creating a systemd service

I personally think, that systmd would be the cleanest way to solve this: we would have a autorestart in case something would go wrong and we also would receive logs!

Implementing this would be really simple:

sudo nano /etc/systemd/system/btc-screen.service

Then we would insert the following content:

[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

To start & enable our newly created service:

sudo systemctl start btc-screen.service
sudo systemctl enable btc-screen.service

In case you think this would be a great idea, I would love to add it to the README.md.
But before I do so: is this even wanted? We also could provide a sample .service file, the user could easily copy into the right folder without manually creating it.

King regards,
Niki

Getting stuck running main.py

File "/home/pi/zero-btc-screen/main.py", line 60, in main() File "/home/pi/zero-btc-screen/main.py", line 40, in main builder.bind(data_sink) File "/home/pi/zero-btc-screen/config/builder.py", line 23, in bind screen_class(observable=observable, **kwargs) File "/home/pi/zero-btc-screen/presentation/screens/epd2in13v2.py", line 24, in init self.screen_image = self._init_display(self.epd) File "/home/pi/zero-btc-screen/presentation/screens/epd2in13v2.py", line 30, in _init_display epd.init(epd.FULL_UPDATE) File "/home/pi/.local/lib/python3.9/site-packages/waveshare_epd/epd2in13_V2.py", line 126, in init if (epdconfig.module_init() != 0): File "/home/pi/.local/lib/python3.9/site-packages/waveshare_epd/epdconfig.py", line 76, in module_init self.SPI.open(0, 0) FileNotFoundError: [Errno 2] No such file or directory

Pico W

Do you think this could be replicated with a Pico W and the Pico Display?

module 'presentation.screens.epd2in7' has no attribute 'Epd2in7'

Getting this traceback with a Waveshare 2.7 inch e-Paper hat:

python3 ~/zero-btc-screen/main.py
module 'presentation.screens.epd2in7' has no attribute 'Epd2in7'
Traceback (most recent call last):
File "/home/pi/zero-btc-screen/config/builder.py", line 17, in bind
screen_class = getattr(package, screen.lower().capitalize())
AttributeError: module 'presentation.screens.epd2in7' has no attribute 'Epd2in7'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/pi/zero-btc-screen/main.py", line 60, in
main()
File "/home/pi/zero-btc-screen/main.py", line 40, in main
builder.bind(data_sink)
File "/home/pi/zero-btc-screen/config/builder.py", line 27, in bind
raise BtcConfigError(
config.builder.BtcConfigError: Cannot instantiate epd2in7

euro

Now it shows just the price in USD, but I would love to have it in euro.

Waveshare V4 - AttributeError: module 'presentation.screens' has no attribute 'epd2in13bv4'

I have a Waveshare v4 screen for my raspberry pi zero w. Im trying to make it work...but for some reason Im not able to load it. I get the following errors:

module 'presentation.screens' has no attribute 'epd2in13bv4'
Traceback (most recent call last):
  File "/home/kira/zero-btc-screen/config/builder.py", line 16, in bind
    package = getattr(screens, screen.lower())
AttributeError: module 'presentation.screens' has no attribute 'epd2in13bv4'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kira/zero-btc-screen/main.py", line 60, in <module>
    main()
  File "/home/kira/zero-btc-screen/main.py", line 40, in main
    builder.bind(data_sink)
  File "/home/kira/zero-btc-screen/config/builder.py", line 27, in bind
    raise BtcConfigError(
config.builder.BtcConfigError: Cannot instantiate epd2in13bv4

What I did:

  • Configuration.cfg
[base]
console_logs             : false
#logs_file                : /tmp/zero-btc-screen.log
dummy_data               : false
refresh_interval_minutes : 15
currency		 : BTC

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

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

[epd2in13v3]
mode : candle

[epd2in13bv4]
mode: line

[epd2in13bv3]
mode  : line

[epd2in7]
mode : candle

[epd3in7]
mode  : candle

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

[inkyWhatRBW]
mode : candle

I have also created this file within "presentations/screens" called epd2in13bv4.py

import os

from PIL import Image, ImageDraw, ImageFont
try:
    from waveshare_epd import epd2in13b_V4
except ImportError:
    pass
from data.plot import Plot
from presentation.observer import Observer

SCREEN_HEIGHT = 122
SCREEN_WIDTH = 250

FONT_SMALL = ImageFont.truetype(
    os.path.join(os.path.dirname(__file__), os.pardir, 'Roses.ttf'), 7)
FONT_LARGE = ImageFont.truetype(
    os.path.join(os.path.dirname(__file__), os.pardir, 'PixelSplitter-Bold.ttf'), 22)

class Epd2in13bv4(Observer):

    def __init__(self, observable, mode):
        super().__init__(observable=observable)
        self.epd = epd2in13b_V4.EPD()

        self.epd.init()
        self.image_black = Image.new('1', (SCREEN_WIDTH, SCREEN_HEIGHT), 255)
        self.image_ry = Image.new('1', (SCREEN_WIDTH, SCREEN_HEIGHT), 255)
        self.draw_black = ImageDraw.Draw(self.image_black)
        self.draw_ry = ImageDraw.Draw(self.image_ry)
        self.mode = mode

    def form_image(self, prices):
        self.draw_black.rectangle((0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), fill="white")
        screen_draw = self.draw_black
        if self.mode == "candle":
            Plot.candle(prices, size=(SCREEN_WIDTH - 38, 79), position=(35, 0), draw=screen_draw)
        else:
            last_prices = [x[3] for x in prices]
            Plot.line(last_prices, size=(SCREEN_WIDTH - 36, 79), position=(36, 0), draw=screen_draw)

        flatten_prices = [item for sublist in prices for item in sublist]
        Plot.y_axis_labels(flatten_prices, FONT_SMALL, (0, 0), (32, 76), draw=screen_draw)
        screen_draw.line([(9, 83), (204, 83)])
        screen_draw.line([(33, 3), (33, 80)])
        screen_draw.line([(51, 87), (51, 101)])
        Plot.caption(flatten_prices[len(flatten_prices) - 1], 81, SCREEN_WIDTH, FONT_LARGE, screen_draw)

    def update(self, data):
        self.form_image(data)
        image_black_rotated = self.image_black.rotate(180)
        image_ry_rotated = self.image_ry.rotate(180)
        self.epd.display(
            self.epd.getbuffer(image_black_rotated),
            self.epd.getbuffer(image_ry_rotated)
        )

    def close(self):
        self.epd.Dev_exit()

Wondering if you could maybe hint me where is the issue as Im not able to pinpoint why the screen is not loading. I would appreciate it a lot. Im looking to "rework" your code once the screen is working for the BTC tracker to make an Euribor Tracker for mortgages.

Again thanks for your time and work. I appreciate you shared this.

Cheers!

Program just doesn't start

Everything actually works for me but in the end the program just doesn't start. I do troubleshoot I get the following:

st3v3n@raspberrypi:~ $ sudo journalctl -f -u btc-screen.service
-- Journal begins at Tue 2023-12-05 04:07:44 CET. --
Jan 24 14:03:11 raspberrypi systemd[1]: Started zero-btc-screen.
Jan 24 14:03:11 raspberrypi systemd[404]: btc-screen.service: Changing to the requested working directory failed: No such file or directory
Jan 24 14:03:12 raspberrypi systemd[404]: btc-screen.service: Failed at step CHDIR spawning /usr/bin/python3: No such file or directory
Jan 24 14:03:12 raspberrypi systemd[1]: btc-screen.service: Main process exited, code=exited, status=200/CHDIR
Jan 24 14:03:12 raspberrypi systemd[1]: btc-screen.service: Failed with result 'exit-code'.
Jan 24 14:03:12 raspberrypi systemd[1]: btc-screen.service: Scheduled restart job, restart counter is at 5.
Jan 24 14:03:12 raspberrypi systemd[1]: Stopped zero-btc-screen.
Jan 24 14:03:12 raspberrypi systemd[1]: btc-screen.service: Start request repeated too quickly.
Jan 24 14:03:12 raspberrypi systemd[1]: btc-screen.service: Failed with result 'exit-code'.
Jan 24 14:03:12 raspberrypi systemd[1]: Failed to start zero-btc-screen.

Can anyone help...plz? :-)

Request: support for Pimoroni Inky pHAT red, black, and white 2.13" EPD display

hello and thank you for this project!

I have a "Pimoroni Inky pHAT for Raspberry Pi - 3 Color eInk Display" with a red, black, and white 2.13" EPD display sitting on my Pi Zero. I tried running the zero-btc-screen trying different display options but only get strange stripes on the eink.

What can I adjust in order for it to display correctly?

Display has gone blank and flashing today

pi@raspberrypi:~ $ python3 ~/zero-btc-screen/main.py
Traceback (most recent call last):
File "/home/pi/zero-btc-screen/main.py", line 60, in
main()
File "/home/pi/zero-btc-screen/main.py", line 46, in main
data_sink.update_observers(prices)
File "/home/pi/zero-btc-screen/presentation/observer.py", line 18, in update_observers
observer.update(data)
File "/home/pi/zero-btc-screen/presentation/screens/epd2in13v2.py", line 54, in update
self.form_image(data, self.screen_draw)
File "/home/pi/zero-btc-screen/presentation/screens/epd2in13v2.py", line 41, in form_image
Plot.candle(prices, size=(SCREEN_WIDTH - 45, 93), position=(41, 0), draw=screen_draw)
File "/home/pi/zero-btc-screen/data/plot.py", line 61, in candle
for i in range(data_offset, len(data), windows_per_candle):
ValueError: range() arg 3 must not be zero

I have tried re-flashing the whole system and re-installing all dependencies, but the issue still persists.

Please advise.

Getting an error when trying to run main.py

Hi, I have set this up with a pi zero w with a Waveshare 2.13 inch SPI E-Ink E-Paper (B) Display - 3 Colors; followed the instructions to a T, but I am getting the following:

jared7118@raspberrypi:~ $ python3 ~/zero-btc-screen/main.py
Traceback (most recent call last):
File "/home/jared7118/zero-btc-screen/main.py", line 60, in
main()
File "/home/jared7118/zero-btc-screen/main.py", line 40, in main
builder.bind(data_sink)
File "/home/jared7118/zero-btc-screen/config/builder.py", line 23, in bind
screen_class(observable=observable, **kwargs)
File "/home/jared7118/zero-btc-screen/presentation/screens/epd2in13v2.py", line 23, in init
self.epd = self._init_display()
File "/home/jared7118/zero-btc-screen/presentation/screens/epd2in13v2.py", line 31, in _init_display
epd.init(epd.FULL_UPDATE)
File "/home/jared7118/.local/lib/python3.9/site-packages/waveshare_epd/epd2in13_V2.py", line 132, in init
if (epdconfig.module_init() != 0):
File "/home/jared7118/.local/lib/python3.9/site-packages/waveshare_epd/epdconfig.py", line 76, in module_init
self.SPI.open(0, 0)
FileNotFoundError: [Errno 2] No such file or directory

Any ideas what is wrong? SPI is enabled (I've checked 2x)

Thanks in advance!!!!

Graph not shown

Hi, as of today my btc-screen no longer displays the price graph. The API seems ok, what could this be due to?
Here's a picture of the problem.
btc-screen-problem

Raspberry Pi Pico W Support

Hello,

Is the Raspberry Pi Pico W supported for this project? If so, where can I find info on how to set it up.

Thanks I appreciate any help.

Name 'epd2in13_V2' is not defined

I am trying to run this on a Raspberry Pi 3 model B with Kali Linux installed. When I run the main python script I get these errors:

Traceback (most recent call last): File "/home/kali/zero-btc-screen/main.py", line 60, in <module> main() File "/home/kali/zero-btc-screen/main.py", line 40, in main builder.bind(data_sink) File "/home/kali/zero-btc-screen/config/builder.py", line 23, in bind screen_class(observable=observable, **kwargs) File "/home/kali/zero-btc-screen/presentation/screens/epd2in13v2.py", line 23, in __init__ self.epd = self._init_display() File "/home/kali/zero-btc-screen/presentation/screens/epd2in13v2.py", line 30, in _init_display epd = epd2in13_V2.EPD() NameError: name 'epd2in13_V2' is not defined. Did you mean: 'Epd2in13v2'?

I have tried changing the name in the code and stuff like that but more errors kept coming up.
What can I do to fix this?

IndexError: list index out of range

Hi, it hasn't worked for a few days anymore, I get this error:

Traceback (most recent call last):
  File "/home/pi/zero-btc-screen/main.py", line 61, in <module>
    main()
  File "/home/pi/zero-btc-screen/main.py", line 47, in main
    data_sink.update_observers(prices)
  File "/home/pi/zero-btc-screen/presentation/observer.py", line 18, in update_observers
    observer.update(data)
  File "/home/pi/zero-btc-screen/presentation/screens/epd2in13v2.py", line 54, in update
    self.form_image(data, self.screen_draw)
  File "/home/pi/zero-btc-screen/presentation/screens/epd2in13v2.py", line 41, in form_image
    Plot.candle(prices, size=(SCREEN_WIDTH - 45, 93), position=(41, 0), draw=screen_draw)
  File "/home/pi/zero-btc-screen/data/plot.py", line 63, in candle
    open = window[0][0]
IndexError: list index out of range

ADA in GBP

Firstly, thank you! Have been struggling for a while to get my Pi Zero W up and running with ePaper hat, your code has been most useful.

I have changed BTC to ADA in the configuration.cfg file and it now displays my preferred Cardano crypto....but I'm struggling to have it show in GBP (UK currency) as it defaults to the US Dollar.

Any suggestions would be greatly appreciated.

Thanks

Stocks support?

Hi, I have been searching for a while for a stock ticker but I think that you could do that, I have used this project in the past but since then I don't use crypto anymore and use stock.
It would be really cool and nice for support

Error

If i try to do my first start up with the code: python3 ~/zero-btc-screen/main.py
It has an Error.
Fileno
Screenshot 2022-12-23 at 14 22 26

[Question] What case is used?

In the images you show of this working there is a really nice case. I'm wondering if it's something I could buy somewhere or if you made the case for your Raspberry Pi Zero plus screen yourself.

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.