Currconv.com - (Crypto)exchange Rate - ESP32, Arduino, ESP8266

Introduction: Currconv.com - (Crypto)exchange Rate - ESP32, Arduino, ESP8266

About: I am NodeMCU, Arduino developer, who make interactive projects.

The currency exchange rate is a very interesting piece of information that can be used in a project with Arduin or a development board from the Espressif platform. There are a number of freely available and documented APIs that can be used to get the current exchange rate of two currencies. For this tutorial, I used the service http://free.currconv.com/, which offers a simple exchange rate of two currencies in JSON format.

The user uses his API key and the mentioned currencies in the query to access the exchange rates of those currencies. To get the key just ask via the form on the page, it requires only email. For this tutorial, we'll show the exchange rate between CZK and EUR. I we will count the value of one euro in Czech crowns.

The free program currconv service is limited to 60 queries per hour. If it is exceeded, the user is blocked within the next hour. JSON is a data format with a value that belongs to a variable. The variable is enclosed in quotation marks, and the entire data package is contained in {} brackets.

Service output for EUR_CZK course: {"EUR_CZK": 25.574488}

In our case, the numeric value is 25.574488 and the variable whose value belongs to EUR_CZK. JSON will find application especially in automation systems, big data, databases. Platform Arduino, respectively. ESP32 also has an ArduinoJson library that can be installed to break whole fields with JSON data through it, but in this example we will only use the substring function of the String object to cut off any unnecessary parts, i. {"EUR_CZK":}.

The microcontroller loads into the service output variable as a string that can then be clipped. This means that substring is applied to characters 11-20, which returns only a numeric value in the output, all characters less than 11 and more than 20 are trimmed. To make the rate more usable, we cast it to a float variable with two decimal places (rounding is also taken into account). In the picture you can see the output of Serial Monitor for ESP32 and its example for reading EUR - CZK currency.

Supplies:

  • Arduino + Ethernet W5100
  • Arduino + Ethernet W5500
  • ESP32 (devkit)
  • ESP8266 (NodeMCU, Wemos D1 mini)

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Supported Methods, Server Response, Output, Code, More Projects

Currconv.com can be accessed under HTTP protocol (use for Arduino and Ethernet shield / module, does not support HTTPS) and HTTPS connectivity for ESP8266, ESP32. The ESP32 development board also needs to import the Root CA certificate into the program, in this case CloudFlare Inc ECC CA-2 (used in the example). For ESP8266 it is possible to use fingerprint certificate in SHA1 format.

Currconv.com has a wide variety of currencies that can be combined with each other to get a course. A complete list of possible names (including Bitcoin) is available at: https://free.currconv.com/api/v7/currencies?apiKe... The obtained course can be further used, for example for displaying on the display (TFT, LCD), sending it to the database or otherwise using it.

The program for ESP32 can be found in my Github repository: https://github.com/martinius96/CURRENCY-RATE-Arduino-ESP8266-ESP32/blob/master/ESP32.ino
Other projects can be found on my site: https://arduino.php5.sk/?lang=en

Be the First to Share

    Recommendations

    • LED Strip Speed Challenge

      LED Strip Speed Challenge
    • Sculpting Challenge

      Sculpting Challenge
    • Tiny Speed Challenge

      Tiny Speed Challenge

    Discussions