Introduction: Cryptocurrency Ticker
Due to the popularity of the Reddit post (link),
I have decided to put together a tutorial for my crypto-ticker. DISCLAIMER: I am by no means a software or computer engineer (as will be evident when you view my code) so PLEASE make edits where you see fit! This project is written by a beginner, for beginners! All of my pictures show the finished product, not the build process, so I will try to make my language as descriptive as possible.
This project uses a Raspberry Pi Zero W and a 16x2 LCD display to show live prices of cryptocurrency from Cryptocompare's API and 24-hour date/time.
Step 1: Gather Materials
The firs thing you'll want to do when starting this project is to get all of your materials together. I am assuming that everyone will have a working version of raspbian running on their their pi, WiFi is connected, and you have a wireless keyboard/mouse to work with prior to starting this project (here is a tutorial if you do not know where to start: link)
(1) Raspberry Pi Zero W kit: (link)
-Please note: This kit DOES NOT include the microUSB-->USB dongle required to hook up a mouse/keyboard. This version (link) has all of the necessary dongles included.
(1) 16x2 LCD with I2C Backpack: (link)
-This display should be the same size as the one I used in this project
(4) M3x8 screws
(4) Jumper Wires
(1) Super Glue
(1) Soldering Iron
All of the 3D printed parts can be found here: (link)
Step 2: Attach the LCD and Feed the Pi Some Code
Much of the info for this section was pulled from an article posted on circuitbasics.com, including extra code to make your text do fun things. Give that article a read if you get lost: link
open the Raspberry Pi terminal (link) and type the following commands:
This will open the configuration menu.
- Find and select "Advanced Settings" from the menu (link)
- Select "I2C Enable/Disable automatic loading" (link)
- Choose "Yes" then exit the configuration menu
- Shutdown and unplug your Pi (wait for the activity LED to stop flashing before unplugging)
Attach the LCD
- Attach jumper cables using the following (Raspberry Pi Zero W pin out [link]):
Pi Pins-->LCD Pins
GPIO 8 --> SDA
GPIO 9 --> SCL
5.0 VDC (either output) -->VCC
Ground (any output) --> GND
- Once you have double and triple checked your connections, solder the jumper cables to you Raspberry Pi
- Plug in your Pi. The LCD screen should light up but nothing will be displayed.
Install Necessary Components
- Open up the Pi terminal
sudo apt-get install i2c-tools
- Wait for the install to complete then enter:
sudo apt-get install python-smbus
- Reboot the Pi (seeing a theme yet?)
- Next we will test our connection with:
i2cdetect -y 1
- This will show show you a table of devices connected to your pi (link)
- In the example, the I2C address is "21". Take note of your number, you will need it later.
Install the Library
- Open a Python 3 shell (link)
- Copy this code from GitHub user DenisFromHR (link) and save it in a file named "I2C_LCD_driver.py"
- On line 19, you will want to change "I2CBUS = 0" to "I2CBUS = 1"
- On line 22, enter your I2C address that we found in the "Install Necessary Components" section. Using the example, line 22 would be changed to: "ADDRESS = 0x21"
Test the Display
- Let's write "Hello World!" to the display
- Open a new Python 3 shell
- Enter the following:
import I2C_LCD_driver<br>from time import * mylcd = I2C_LCD_driver.lcd() mylcd.lcd_display_string("Hello World!", 1)
- Press "F5" to save and run your python code.
- If your message comes up, Congratulations! your LCD is ready to use. If not, double-check your connections
- This is also a great time to adjust your contrast. Use a phillips screwdriver on the little blue box on the back of the I2C unit to adjust the contrast of your screen.
Upload the code
- Download and open the code: link
- Press "F5" to save and run the code
Make the code start on boot
- First, note the location of the CryptoTicker.py file. (Example: /home/pi/Desktop/CryptoTicker.py)
- Open the terminal and type the following:
- At the bottom of all of the hashtagged text, input the following:
@reboot sudo python (TYPE IN THE LOCATION OF YOUR CRYPTOTICKER.PY FILE)
- Type Crtl-X, Y (for yes), and Enter to save
- Now, Reboot your Pi and see if it works!
Step 3: Glue, Glue, GLUE
All parts were designed to fit snug to make gluing easier. Depending on printer tolerances, your parts may not fit together perfectly (use sandpaper or a knife to trim them to size). Make sure to sand down all areas that will be contacted by glue.
Its time to assemble your parts
First, shutdown and unplug your Pi.
Assemble the front plate:
- I found it easiest to unplug and mount my LCD screen prior to gluing
- The screen should only fit in the hole one way.
- Use the 4 M3x8 screws to mount the LCD display to the pi housing. DO NOT OVERTIGHTEN as at screws will strip out the plastic from the integrated holes. There is a slight draft to ensure a snug fit.
Attach the front plate to the base:
- Put a small amount of super glue on the attachment point of the front plate and the base. Use clamps to ensure you have an even, snug fit.
- After drying, feed the four cables through the top of your pi case and attach to the correct pins (DOUBLE-CHECK YOUR WIRING)
Attach the topper to the cap:
- Position the topper how you would like it to sit in the top hole and make a seam of super glue around the top.
- Once dried, apply a seam of glue to the attachment point on the inside of the case,.
Lastly, place the pi inside the case, cover with the cap, and plug it in!
Step 4: CONGRATULATIONS!
Your cryptocurrency ticker is complete!
(Please note: this device requires a functioning WiFi connection to operate properly. If your top line stops showing prices, your bandwidth may be struggling!)
But anonananananabatman, I want to add another crypto-price to my ticker!
Unfortunately, this is not a python tutorial, but note the pattern of the code to add or subtract as many exchanges as you would like! I wrote this code through much of the same trial and error, so I encourage you to do the same!
Running this in the python shell will also give you some debugging information so you can double-check that the value you see on the screen are appropriate.