//https://buger.dread.cz/simple-esp8266-https-client-without-verification-of-certificate-fingerprint.html #include #include #include #include void setup() { Serial.begin(115200); Serial.println(F("\n\r* * * ESP BOOT * * *")); Serial.println(F("WiFi begin!")); WiFi.mode(WIFI_STA); WiFi.begin("SSID", "PASSWORD"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(F("\n\rWiFi connected!")); } void getpr24h() { std::unique_ptrclient(new BearSSL::WiFiClientSecure); client->setInsecure(); HTTPClient https; if (https.begin(*client, "https://blockchain.info/q/24hrprice")) { // HTTPS Serial.println("[HTTPS] GET..."); int httpCode = https.GET(); // httpCode will be negative on error if (httpCode > 0) { // HTTP header has been send and Server response header has been handled Serial.printf("[HTTPS] GET... code: %d\n", httpCode); // file found at server? if (httpCode == HTTP_CODE_OK) { String payload = https.getString(); Serial.println(String("[HTTPS] Received payload: ") + payload); Serial.println(String("1BTC = ") + payload + "USD"); } } else { Serial.printf("[HTTPS] GET... failed, error: %s\n\r", https.errorToString(httpCode).c_str()); } https.end(); } else { Serial.printf("[HTTPS] Unable to connect\n\r"); } } void loop() { getpr24h(); Serial.println("Wait 20s before next round to not get banned on API server..."); delay(20000); }