GET BITCOIN LIVE PRICE TTGO ESP32
by RonFrtek in Circuits > Arduino
5255 Views, 13 Favorites, 0 Comments
GET BITCOIN LIVE PRICE TTGO ESP32
In this tutorial we will learn how to get a current Bitcoin price in USD and EUR using a TTGO ESP32 and Visuino.
Watch the video.
(New Updated File for Download below!)
What You Will Need
- TTGO ESP32
- WiFi connection
- Visuino program: Download Visuino
Start Visuino, and Select the Arduino TTGO T-Display ESP32 Board Type
The Visuino: https://www.visuino.eu needs to be installed. Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "TTGO T-Display ESP32" as shown on Picture 2
In Visuino Set WiFi
Select TTGO T-Display ESP32 board and in the properties window expand "Modules>WiFi>Connect To Access Points
- Click on the Connect To Access Points 3 Dots
- In the AccessPoints window drag "WiFi Access Point" to the left side
- In the properties window set SSID (name of your WiFi hotspot or router)
- In the properties window set Password (password of your WiFi hotspot or router)
- Close AccessPoints window
Select TTGO T-Display ESP32 board and in the properties window expand "Modules>WiFi>Sockets
- Click on the Sockets 3 Dots
- In the Sockets window drag TCP/IP Secure Client (SSL) to the left
- In the properties window set Host to: blockchain.info
- Close Sockets window
In Visuino Set Display
Select TTGO T-Display ESP32 board and in the properties window expand "Modules>Display>Orientation
Set Orientation to:goRight
Select TTGO T-Display ESP32 board and in the properties window expand "Modules>Display>Elements
Click on the Elements 3 Dots
In the Elements window drag Draw Bitmap to the left
In the properties window set Y to 20, Click on the Bitmap 3 Dots
In the Bitmap Editor Load the Bitcoin bitmap (picture 6) and close the Bitmap editor
In the Elements window drag Draw Text to the left
In the properties window set color to aclOrange, size to 2, text to USD, X to 150, Y to 10
In the Elements window drag Text Field to the left
In the properties window set size to 3, X to 100, Y to 35
In the Elements window drag Draw Text to the left
In the properties window set color to aclOrange, size to 2, text to EUR, X to 150, Y to 80
In the Elements window drag Text Field to the left
In the properties window set size to 3, X to 100, Y to 105
Close the Elements window
In Visuino Add Components
- Add "HTTP Client" component
- Select and in the properties window set Host to api.coindesk.com
- Click on the Requests 3 Dots
- In the requests window drag "GET" to the left
- In the properties window set URL to: /v1/bpi/currentprice.json
- Close the requests window
- Add "HTTP Client" component "Char To Text" component
- Select "CharToText1" and in the properties window se Max Length to 2000
- Add "Clock Generator" component
- Select "ClockGenerator1" and in the properties window set frequency to 0.1
- Add "Delay" component
- Select "Delay1" and in the properties window set Interval to 2000000
- Add "Split JSON Object" component
In Visuino Parsing JSON
- With the mouse right click on the "SplitJSON1" and in the menu click on the "Parse JSON Object.."
- In the "JSON Object" window paste this sample code(avalible on https://www.coindesk.com/coindesk-api:
{"time":{"updated":"Sep 18, 2013 17:27:00 UTC","updatedISO":"2013-09-18T17:27:00+00:00"},"disclaimer":"This data was produced from the CoinDesk Bitcoin Price Index. Non-USD currency data converted using hourly conversion rate from openexchangerates.org","bpi":{"USD":{"code":"USD","symbol":"$","rate":"126.5235","description":"United States Dollar","rate_float":126.5235},"GBP":{"code":"GBP","symbol":"£","rate":"79.2495","description":"British Pound Sterling","rate_float":79.2495},"EUR":{"code":"EUR","symbol":"€","rate":"94.7398","description":"Euro","rate_float":94.7398}}}
- Close the "JSON Object" window
- "SplitJSON1" component will now create new pins
In Visuino Connecting Components
- Connect "ClockGenerator1" pin Out to "HTTPClient1" pin Clock and "Delay1" pin Start
- Connect "HTTPClient1" pin Content to "CharToText1" pin In
- Connect "HTTPClient1" pin to TTGO T-Display ESP32 > WiFi>TCP Secure Client1 pin In
- Connect "Delay1" pin Out to "CharToText1" pin Clock and TTGO T-Display ESP32 > WiFi>TCP Secure Client1 pin Disconnect
- Connect "CharToText1" pin Out to "SplitJSON1" pin In
- Connect "SplitJSON1>USD>rate_float to TTGO T-Display ESP32>Text Field1 pin In
- Connect "SplitJSON1>EUR>rate_float to TTGO T-Display ESP32>Text Field1 pin In
Note: you can also play with the other pins from "SplitJSON1" component
Generate, Compile, and Upload the Code
In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.
Play
If you power the TTGO ESP32 module it will connect to the network and display the current Bitcoin price in USD and EUR
Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it and open it in Visuino: https://www.visuino.eu
Note: In the File Project when you open it in Visuino, change the WiFi settings (Access point and password) to your settings.
Downloads
Troubleshooting
In case you dont get any data:
- make sure that you are using the latest Visuino version
- check that you entered correct WiFi settings
- connect "SplitJSON1" pin "rate_float" to serial [0] pin, upload and click connect button and see if you get any data there (see attached pictures )