This example sketch demonstrates the use of the ESP8266WiFi and WiFiClientSecure libraries to access an HTTPS API. The code fetches and displays the status of the esp8266/Arduino project continuous integration build from the "indodax.com" website.
Ensure you have the following Arduino libraries installed:
Update the following WiFi credentials in the code:
#ifndef STASSID
#define STASSID "Your_SSID"
#define STAPSK "Your_PASSWORD"
#endif
Replace "Your_SSID" with your WiFi network's SSID and "Your_PASSWORD" with the corresponding password.
Set the host and HTTPS port:
const char* host = "indodax.com";
const int httpsPort = 443;
Provide the SHA1 fingerprint of the server certificate:
const char fingerprint[] PROGMEM = "CF 27 71 86 F3 25 8E FD 79 49 6C 39 E9 EC EF 8E B0 F8 73 02";
Ensure the fingerprint matches the certificate fingerprint of the server you are connecting to. You can obtain the fingerprint using a web browser.
- Upload the code to your ESP8266 board.
- Open the serial monitor to view the output.
The code establishes a secure connection to "indodax.com" and retrieves the ticker information for Bitcoin to Indonesian Rupiah exchange rates. The response is then parsed using the ArduinoJson library, and relevant details (last, buy, sell prices) are displayed on the serial monitor.
Feel free to modify the code for your specific use case or integrate it into a larger project.