I’m working on a Google Photo Clock project using an ESP32 board and encountering an issue with establishing an HTTPS connection. Here’s the relevant code and the error I’m getting:
Code:
`
// WiFi and HTTPS setup
#if defined(ESP32)
#include <WiFi.h>
#include <WiFiMulti.h>
#include <HTTPClient.h>
#include <WiFiClientSecure.h>
const char* rootCACertificate =
"-----BEGIN CERTIFICATE-----n"
/* ... */
"-----END CERTIFICATE-----n";
WiFiMulti WiFiMulti;
WiFiClientSecure *client = new WiFiClientSecure;
// ...
void setup() {
// ...
// init WiFi
WiFi.mode(WIFI_STA);
WiFiMulti.addAP(SSID_NAME, SSID_PASSWORD);
while (WiFiMulti.run() != WL_CONNECTED) {
delay(500);
}
// init HTTPClient
client->setCACert(rootCACertificate);
}
void loop() {
// ...
HTTPClient https;
https.begin(*client, GOOGLE_PHOTO_SHARE_LINK);
https.setTimeout(HTTP_TIMEOUT);
int httpCode = https.GET();
// ...
}
This is what i got as the error on serial monitor:
https://photos.app.goo.gl/_____________
[HTTPS] begin...
[HTTPS] GET...
[HTTPS] return code: -1
[HTTPS] GET... failed, error: connection refused
I’m able to connect to the Wi-Fi network successfully, but the HTTPS connection to the Google Photos share link fails with the error “connection refused”. I’ve double-checked the share link, and it seems to be correct.
What could be causing this issue, and how can I resolve it?
Cheetohzzz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.