Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.

samyarsadat/crypto_printer_v2

Repository files navigation

NOTE: This is an ancient project that no longer receives updates. For this reason, I have decided to archive this repo.


Crypto Printer V2

Get a paper hard copy of the price for some crypto currencies at the push of a button.

Powered by the CoinGecko API V3.

About :

Get a paper copy of the price for 4 crypto currencies:
NOTE : The currency for the returned price is settable. For more info, please click here.

  1. Bitcoin
  2. Ethereum
  3. Binance coin
  4. Cardano

Components :

  1. Raspberry Pi 4B 4GB RAM (Tested on a pi4, but it should also work with a pi3 or pi2)
  2. Mini Thermal Receipt Printer (From adafruit)
  3. 2 Pin momentary push button
  4. 5mm LED (Any color)
  5. 9V 2A Power supply
  6. 16GB (or higher) class 10 micro SD card
  7. A suitable 5V power supply for the Raspberry Pi
  8. A mouse and keyboard for the Raspberry Pi
  9. A suitable HDMI cable for the Raspberry Pi
  10. A suitable display or monitor for the Raspberry Pi

For Raspberry Pi 2 users (Without wifi) :

  1. Option A: A USB wifi dongle
  2. Option B: A direct connection with an ethernet cable

Hardware :

Wiring diagram :

wiring_diagram_v2

The thermal printer's RX pin (usualy the yellow wire) connects to GPIO 14 on the Raspberry pi.
DO NOT CONNECT THE TX (USUALY GREEN) WIRE OF THE THERMAL PRINTER TO THE PI. IT IS 5V AND IT MIGHT PERMANENTLY DAMAGE YOUR RASPBERRY PI.

The thermal printer's GND (black) wire connects to a ground (GND) pin on the pi.

The led's cathode connects to a ground (GND) pin on the pi and the anode to GPIO 24.

One of the pins on the button connects to a ground (GND) pin on the pi and the other to GPIO 23.

Software :

First you must install Raspberry Pi OS on to your micro SD card and then insert it in to your Raspberry Pi.
If you don't know how to do this, Click here.

Next download the installation file: install.zip

Unzip it on your Raspberry Pi and then right click on install.sh. Then click on properties. A window will open. Go to the permissions tab and click on Execute. some options will appear. click on anyone and then click on OK:
If you don't know how to unzip zip files on the pi, Click here.

2021-04-03-153841_1920x1080_scrot

Now double click on install.sh. something like this will appear:

2021-04-02-235737_1920x1080_scrot

Click on "Execute in Terminal". A terminal window will open. Now just wait for all of the libraries and files to be installed.

2021-04-02-235742_1920x1080_scrot

When the installation is completed, you should get a message in the terminal saying "Installation completed successfuly !" "Closing in 20 seconds"

After that there is only one small thing left to do; Configuring the serial port on the pi:
First open a terminal window. The terminal icon looks like this:

Terminal icon

Next type sudo raspi-config in the terminal and hit enter:

2021-04-03-000913_1920x1080_scrot

The conifiguration tool will open. press the down cursor key twice to select "3 Interface Options". Then hit enter:

Untitled

When the interface options menu opens, press the down cursor key 5 times to select "P6 Serial Port". Then hit enter:

2021-04-03-000929_1920x1080_scrot

Next this screen will apear. With the left and right cursor keys select No and hit enter:

2021-04-03-000938_1920x1080_scrot

After that this screen will apear. With the left and right cursor keys select Yes and hit enter:

2021-04-03-000942_1920x1080_scrot

When this screen apears just hit enter:

2021-04-03-000945_1920x1080_scrot

Next you will return to this screen. Here using the left and right cursor keys select Finish and hit enter:

2021-04-03-000955_1920x1080_scrot

Then you will be prompted to reboot, using the left and right cursor keys select Yes and hit enter.
If not then type this into the terminal: sudo reboot now and hit enter.
Now the pi will reboot and the software installation will be completed!

Runing the code :

To run the code open a terminal window and type:
cd crypto_printer_v2 hit enter. then type python3 crypto_printer_V2.py and hit enter.

Now the code will start runing. To print the prices push the button and wait.
Due to the CoinGecko API's slow speed, the program might sometimes get stuck for a bit

To stop the code you can close the terminal or hold the ctrl key and then press c on the keyboard. now you can release the ctrl key. (Or basically ctrl + c)

To test the printer, instead of typing python3 crypto_printer_V2.py type python3 printertest.py

Modifying the code :

Opening the code in the thonny python IDE :

The thonny python IDE by default comes with Raspberry Pi OS. You can view, edit and run python codes with thonny.
To open the main code for this project open the file manager on the pi. The file managers icon looks like this:

file manager

The file manager window will open. By default file manager opens in the directory that the crypto_printer_v2 folder is in. Now open the crypto_printer_v2 folder:

edited_1

Inside the folder there are 3 main python codes:

  1. Adafruit_Thermal.py (The "library" for the thermal printer from Adafruit)
  2. crypto_printer_V2.py (The main code for the project written by me)
  3. printertest.py (The test code for the thermal printer from Adafruit)

The rest of the files and folders (directories) are for other purposes:

  1. README.md (This file that you are reading right now)
  2. gfx (The bitmaps and graphics for the printertest.py code)
  3. Wiring (The wiring diagram for this project in .JPG image format and .FZZ fritzing format)
  4. install - uninstall (Contains install.sh and uninstall.sh. to run these, follow the steps above for runing install.sh (follow the same steps for uninstall.sh))

edited_2

To open the python code files (.py), right click on them and then click on Thonny python IDE. Now thonny will open and you can edit the code:

2021-04-03-194243_1920x1080_scrot

To save your changes click the Save button:

thonny 1

To run the code click the Run button and to stop the code click the Stop button:

thonny 2

For more information about thonny, Click here.

Changing the currency of prices :

You can change the currency that the prices are printed in.
To do this, open the main (crypto_printer_V2.py) code in thonny (as described above) and scroll down to line 59:

2021-04-03-194317_1920x1080_scrot

Here you can change the three letters inside the single quotation marks. You can change it to any currency as long as CoinGecko supports it.

Here is the list of supported currencies:
NOTE : Some of these currencies are actualy crypto currencies themselvs; So as well as normal currencies you can get the prices in some crypto currencies.

Some popular currencies:

  1. usd (US dollars)
  2. eur (Euro)
  3. cad (Canadian dollars)
  4. aud (Australian dollars)
  5. btc (Bitcoin)
  6. eth (Ethereum)

The rest of supported crypto and normal currencies:

  1. ltc
  2. bch
  3. bnb
  4. eos
  5. xrp
  6. xlm
  7. link
  8. dot
  9. yfi
  10. aed
  11. ars
  12. bdt
  13. bhd
  14. bmd
  15. brl
  16. chf
  17. clp
  18. cny
  19. czk
  20. dkk
  21. gbp
  22. hkd
  23. huf
  24. idr
  25. ils
  26. inr
  27. jpy
  28. krw
  29. kwd
  30. lkr
  31. mmk
  32. mxn
  33. myr
  34. ngn
  35. nok
  36. nzd
  37. php
  38. pkr
  39. pln
  40. rub
  41. sar
  42. sek
  43. sgd
  44. thb
  45. try
  46. twd
  47. uah
  48. vef
  49. vnd
  50. zar
  51. xdr
  52. xag
  53. xau
  54. bits
  55. sats

After you have made your changes, save the code with the Save button and run it with the Run button.
Thanks for following allong and reading this document. I hope that you have enjoyed this project. Have a nice day :)

About

Get a paper hard copy of the price for some crypto currencies at the push of a button.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published