esp01: Today Exchange Rate in BDT (Arduino Platform)

https://www.arduino.cc/en/software

                      http://arduino.esp8266.com/stable/package_esp8266com_index.json

                      esp8266

#include <ESP8266WiFi.h>
#include "SSD1306Wire.h"               // legacy: #include "SSD1306.h"
#include "Dialog_plain_8.h"
#define  SDA_ESP8266_V01   0           // GPIO0 pin for SDA
#define  SCL_ESP8266_V01   2           // GPIO2 pin for SCL 
SSD1306Wire display(0x3c, SDA_ESP8266_V01 , SCL_ESP8266_V01);   // ADDRESS, SDA, SCL  

// WiFi credentials
const char* ssid = "Your_WiFi_SSID";       // Your WiFi SSID
const char* password = "Your_WiFi_Password";   // Your WiFi Password

// ThingHTTP settings
const char* host = "api.thingspeak.com";
const String thingHTTPKey = "MET1M2GLDSKNNMJV";               // Your API key

WiFiClient client;

void setup() {
  Serial.begin(115200);

  display.init();
  display.clear();
  display.flipScreenVertically();
  display.setFont(ArialMT_Plain_16);  // Front : ArialMT_Plain_10/16/24                      
  display.drawString(0, 0,"Connecting WiFi...");
  display.display();
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  display.clear();
  delay(1000);
  display.drawString(0, 0, "WiFi Connected!");
  display.display();
  delay(1000);
  display.setFont(Dialog_plain_8);  // Creating Smaill Front
}

void loop() {
  if (client.connect(host, 80)) {
    String url = "/apps/thinghttp/send_request?api_key=" + thingHTTPKey;

    client.print(String("GET ") + url + " HTTP/1.1\r\n" +
                 "Host: " + host + "\r\n" +
                 "Connection: close\r\n\r\n");

    // Skip headers
    while (client.connected()) {
      String line = client.readStringUntil('\n');
      if (line == "\r") break;
    }

    // Read and process response
    String data = client.readString();
    client.stop();

    // Debug output
    Serial.println("Raw HTML:");
    Serial.println(data);

    // Extract values from <td> tags
    String tokens[12];
    int index = 0;
    int start = 0;

    while ((start = data.indexOf("<td>", start)) != -1 && index < 12) {
      int end = data.indexOf("</td>", start);
      if (end == -1) break;
      tokens[index++] = data.substring(start + 4, end);
      start = end + 5;
    }

    // tokens[0] = USD, tokens[1] = 121.0000, tokens[2] = 122.0000, etc.

    display.clear();
    display.println("CUR       BUY       SELL");
    display.println("------------------------------------");

    for (int i = 0; i < 12; i += 3) {
      display.printf("%s  %.4f   %.4f\n", 
        tokens[i].c_str(), 
        tokens[i+1].toFloat(), 
        tokens[i+2].toFloat()
      );
    }
  } else {
    Serial.println("Connection failed");
  }

  delay(30000); // Update every 30 seconds
}