Bitcoin Price Ticker using a Raspberry Pi Zero 2 W and MAX7219 8x8 LED Matrix

avatar
(Edited)

I've been interested in cryptocurrencies for a while and i wanted an easy way to check the price of bitcoin. After a bit of a search, i picked up on a few ideas from other people and come up with my own version of Bitcoin price ticker.

This project is based on a Raspberry Pi Zero 2 W, a $10 single board computer and a Max7219 4in1 8x8 LED Matrix display which is used to display the Bitcoin information from here: https://bitcoinblockhalf.com

photo_2022-09-20_15-25-27.jpg

Basically, what we will create is a Raspberry Pi looking at a website that contains just about everything you need to know about Bitcoin apart from if its going to crash or when it will break the $100,000 barrier!

I have assumed you are familiar with Raspberry Pi, if not please have some patience because i have spent many hours getting to where i am now with this setup, and it works! So it will worth th time spent.

Follow the diagram below to connect the 8x8 LED Display Matrix MAX7219 to Raspberry Pi. The Raspberry Pi in the image is a model 3 but the connections in the GPIO are the same.

diagram.png

Now follow the instructions below:

You can download the Raspberry Pi software from the official website https://www.raspberrypi.com/software/operating-systems/

Choose "Raspberry Pi OS with desktop" 32 Bits should be enough, and download the file.

Then go to https://www.raspberrypi.org/software/ or use the command below in a Terminal window to install Pi Imager:

apt install rpi-imager

Install the Pi Imager program to install the Raspberry Pi operating system into your microSD card.

Follow the install instructions below:

Insert your microSD card and run the Pi Imager software that you just installed above.

  • Click “Choose OS”
  • Choose the first option (Raspberry Pi OS 32bit)
  • Then click on the second box, “Choose Storage”
  • Choose your microSD card
  • Now click “Write” and finally click “Yes” to confirm

pi imager.png

Now wait until the operation completes and remove the microSD card from your machine. Ignore Windows prompt to format the card.

Insert the microSD card to your Raspberry Pi and boot it.

Follow instructions on screen to connect the Raspberry Pi to your Wi-Fi and setup the Raspberry Pi normally. Complete any updates you are prompted to do on screen and reboot when complete.

You can also update and upgrade your repositories with the command below

apt update -y

apt upgrade -y

Now we have to install the required software for the Bitcoin Ticker. Do everything in the order below and don’t miss out anything or else it will end badly and you may have to start again.
I did it many times until i got it right!

You will need to turn on SSH on the Raspberry Pi. To do it just open Terminal and type:

sudo raspi-config

Now select Interface Options

raspi-config.png

And then select SSH to enable the remote command line access

ssh.png

It will ask if you would like the SSH Server to be enabled. Just press "Yes" and you will see that SSH is enabled.

ssh yes.png

Follow the steps above to also enable SPI.

Reboot and then open the terminal window as before.

Now copy and paste the following commands one by one into a terminal window. Be careful not to miss any lines out!

apt-get update

sudo apt-get install -y build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev tar wget vim

wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz

tar zxf Python-3.8.0.tgz

cd Python-3.8.0

./configure --enable-optimizations

make -j4 

make altinstall -y

git clone https://github.com/psf/requests.git

cd requests

pip3 install .

pip3 install beautifulsoup4

cd

usermod -a -G spi,gpio pi

apt install build-essential python-dev python-pip libfreetype6-dev libjpeg-dev libopenjp2-7 libtiff5

sudo -H pip3 install --upgrade luma.led_matrix

git clone https://github.com/jonathanrjpereira/bitcoin-bar.git

If you have already connected up your Raspberry Pi to the display correctly then enter the following and you should see your display light up with the following command.

cd bitcoin-bar

python3 bcbar.py

Now we need to create a cronjob so when the Raspberry Pi is turned on the program will run automatically. Follow the instructions below.

Copy and paste these lines one by one into a terminal window.

crontab -e

If this is the first time you have edited crontab you will be presented with 4 options, I always choose 1, the nano editor. Press 1 and scroll to the bottom of the text displayed and type the following:

@reboot sleep 60 && sudo python3 /home/pi/bitcoin-bar/bcbar.py

Then press control X then Y to save and then confirm.

If you now reboot and your LED Matrix display is connected correctly you should see a scrolling display after about 60 seconds.

I added a delay in crontab to allow time for your network to the Pi to be established.
You can Control C to exit the program when running.

Enter the following lines into a terminal window to run the program:

To start Bitcoin ticker:

python3 /home/pi/bitcoin-bar/bcbar.py 

Control and C to stop it running.

To edit Bitcoin ticker:

nano /home/pi/bitcoin-bar/bcbar.py

And here's the final result:

photo_2022-09-20_15-47-58.jpg

photo_2022-09-20_15-47-54.jpg

That's all for now! I hope you like it! If you have any questions let me know in the comments.

Thank you for your time!



0
0
0.000
13 comments
avatar

good informative tutorial! so you have there a OS similar to linux ?

!1UP

0
0
0.000
avatar

Yes, that's Raspberry PI OS aka Raspbian. A Debian based OS for Raspberry Pi

0
0
0.000
avatar

Running scripts as a super-user is very dangerous.
The Python commands should also work without "sudo".
Please check it.

0
0
0.000
avatar

You're absolutely right! I already removed the unnecessary sudo from commands. That's a bad habit that i have to lose.

0
0
0.000