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.
Step 1: What You Will Need
- TTGO ESP32
- WiFi connection
- Visuino program: Download Visuino
Step 2: 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
Step 3: 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 Sockets3 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
Step 4: 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
Step 5: 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
Step 6: 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
Step 7: 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
Step 8: 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.
Step 9: 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
Download ESP32_LiveBitcoinPrice.zip