Any attempt to contact the host
const char* host = "https://api.brightsky.dev/current_weather?lat=52&lon=7.6"
with an ESP32 fails. However, if I use an ESP8266 processor, I can connect to this host. The author of brightsky has suggested that it could be because brightsky can be reached via IPv4 and IPv6. Here is the minimalist program for establishing a connection:
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
const char* ssid = "***";
const char* password = "***";
const char* host = "https://api.brightsky.dev/current_weather?lat=52&lon=7.6";
//const char* host = "www.howsmyssl.com"; //
int nowifi;
void setup()
{
Serial.begin(115200);
Serial.printf("\n\nCompiled from: %s at: %s %s", __FILE__, __DATE__, __TIME__);
Serial.println("\nESP32_brightsky");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("connectet to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
nowifi++;
Serial.print(nowifi);
if(nowifi > 4) {
ESP.restart();
}
}
Serial.println("");
Serial.println(WiFi.localIP());
Serial.println(WiFi.RSSI());
}
void loop() {
Serial.println("Connecting to " + String(host));
WiFiClientSecure client;
client.setInsecure();
if (client.connect(host, 443)) {
Serial.println("Successful connection!");
while(true){yield(); delay(100);};
} else {
Serial.println("\nConnection to " + String(host) + " failed");
while(true){yield(); delay(100);};
}
client.stop();
delay(10000);
}
Unfortunately, I have no in-depth knowledge of network protocols.
Please take this into account in your answers.