7219

BITCOIN TICKER using a Raspberry Pi Zero W and a MAX7219 LED MATRIX 4 IN 1. 13/5/21 MikeMakesIt www.youtube.com/mikemakesit

I’ve been interested in cryptocurrency for a while and wanted an easy way to check on 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 take on producing a Bitcoin ticker. The project is based on a Raspberry Pi Zero W; a single board £10 computer and a Max7219 4in1 (8x8led, 4off module) display which is used to display the Bitcoin information of my choosing from here:   https://bitcoinblockhalf.com  

Basically, what you will be creating is a Raspberry Pi looking at a web site 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!

Follow my tutorial below and check out the additional information on my Google drive linked here:

https://drive.google.com/drive/folders/19RTkMWL_x1vDy2bA7iAydagGcyaRaBuQ?usp=sharing

All this information is based on a Windows 10 machine and I have used Note++ throughout. Using anything else, I have found, can alter the formatting of the document and cause issues. As already stated,
I have assumed you are familiar with Windows and "Pi". I was not and it was a steep learning curve! But I worked it out. So can you. 
Please have a go yourself as I have spent many, many hours getting to where I am now with this setup, and it works!

Google drive link:

Go to https://www.raspberrypi.org/software/operating-systems/#raspberry-pi-os-32-bit

This is where you can download the Raspberry Pi software.

Choose "Raspberry Pi OS with desktop" and download the file.

Then go to https://www.raspberrypi.org/software/

and download the imager program to install operating system to your microSD card. Read and follow the install instructions.

Fit a USB drive adaptor with your microSD card in it that you want to put your Pi system on into your Windows machine.

Run the imager program you just installed above. Click “YES” to start the program.
 It should pick up on the file you downloaded in the first line of this instruction sheet. 

Click “Choose OS”
Pick the top option (Raspberry Pi OS 32bit) 
Then click Second box, “Choose Storage”
Pick your microSD card
Now click “Write”
Click “Yes” to confirm

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

Fit microSD card to your Pi and boot.

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

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

You may like to try and connect the Pi to your Windows system and transfer this whole document. It is certainly a more foolproof way of doing it rather than typing my hand.

This is the software I used and it really is straight forward, it’s called Win SCP. You will need to turn on SSH on the Pi but in the link below it is all explained. It was scary for me to start as I knew very little about the Raspberry Pi. After this project I knew considerably more. You will enable SSH when you use Win SCP. Remember to turn it off when you have the Ticker working.

https://behind-the-scenes.net/using-winscp-to-connect-to-a-raspberry-pi/

Copy and paste these lines one by one into a terminal window. Be careful not to miss any lines out!  And only copy the text after the number and bracket!

Another word of warning, “don’t error correct” any of the text below. It is correct as it is!

1)sudo raspi-config

Move to "interface" Hit "Enter" and to "SPI"  Enter. Enable. Select "Yes" Click "Enter" Confirm. Finish. Reboot and then continue with the following in a terminal window as before.

2) sudo apt-get update
3) 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
4) wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
5) sudo tar zxf Python-3.8.0.tgz
6) cd Python-3.8.0
7) sudo ./configure --enable-optimizations
8) sudo make -j4 
9) sudo make altinstall -y
10) git clone https://github.com/psf/requests.git
11) cd requests
12) sudo pip3.8 install .
13) sudo pip3.8 install beautifulsoup4
15) CD
15) sudo usermod -a -G spi,gpio pi
16) sudo apt install build-essential python-dev python-pip libfreetype6-dev libjpeg-dev libopenjp2-7 libtiff5
17) sudo -H pip3.8 install --upgrade luma.led_matrix
18) git clone https://github.com/jonathanrjpereira/bitcoin-bar.git

If you have already connected up your Pi to the display correctly then enter the following and you should see your display spring to life.

18) cd bitcoin-bar
19) python3.8 bcbar.py

Be aware that the web site the information is pulled from has a problem. It is missing a line of data for “Current pending soft forks”. As the result is missing the program on the Pi hangs. There is a way around this by not asking for this line of data to be displayed on the ticker. Look at the program (bcbardemo.py ) on my Google drive. I explain in the program. (Open using “nano” editor in a terminal window)

I edited crontab (A program that runs on boot) so as when the Pi is turned on the program will run automatically. My Pi Zero is a stand-alone unit only used for the Bitcoin program. 
If this is what you would like then follow the instructions below.

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

1) 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.8 /home/pi/bitcoin-bar/bcbar.py

Then press control X then Y to save then confirm.

If you now reboot and your LED matrix display is connected correctly and the World is good you should see a scrolling display after about 60 seconds. 
You entered 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:

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

Control and C to stop it running.

To edit Bitcoin ticker

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

There is a demo program called bcbardemo.py included in the Google drive. This has a number of extra lines and information about displaying the information you want to see. Take a look and copy it over if you wish. Run this in the same way as above, in a terminal window. It may not run from Thonny etc.

Links to the resources I used to produce this text and Bitcoin Ticker.


My Google drive link for this project 

https://drive.google.com/drive/folders/19RTkMWL_x1vDy2bA7iAydagGcyaRaBuQ?usp=sharing

Bitcoin information gathered from here https://bitcoinblockhalf.com
Useful Max 7219 information   https://luma-led-matrix.readthedocs.io/en/latest/install.html
Bitcoin bar on GitHub   https://github.com/jonathanrjpereira/Bitcoin-Bar
Raspberry Pi software https://www.raspberrypi.org/software/operating-systems/#raspberry-pi-os-32-bit
Raspberry Pi imager https://www.raspberrypi.org/software/
Banggood for Max 7219 https://www.banggood.com/custlink/GKKdjaJ7ht
The PiHut for Pi Zero W https://thepihut.com/collections/raspberry-pi/products/raspberry-pi-zero-w
eBay for printed case https://www.ebay.co.uk/itm/274670747024
Banggood plastic bolts etc https://www.banggood.com/custlink/GvGhOOZQWM
Banggood cables https://www.banggood.com/custlink/GvmhLOZAV3