ESP8266 board version 2.7.4
FirebaseArduino version 0.3 (from 2018? Is there a newer one I didn't manage to find?) together with ArduinoJson 5.13.1
OR FirebaseESP8266 version 3.0.2
For Firebase access I've tried both FirebaseArduino and FirebaseESP8266, both with essentially the same problem:
In setup() I open up a WiFi connection, and then in loop() I access Firebase to retrieve a list of strings of length 10, about 160 of those strings but the number and keys of those strings are unknown in advance. Upto this point, everything works like a charm. I can even loop over the String[] and show all the retrieved Firebase keys.
But, as soon as I open an HTTPS client connection using
WiFiClientSecure client;
client.setInsecure(); // to avoid fingerprint stuff
if(!client.connect()) {
Serial.println("connection failed");
} else {
... // do stuff like client.print("GET ......")
}
I will either see "connection failed" (for FirebaseArduino) or I will get a soft WDT reset (for FirebaseESP8266).
Opening an HTTPS client connection to those URLs with no previous Firebase access works consistently.
What I would like to do: For each 10 character string retrieved from Firebase, I would like to connect to an HTTPS server related to that string and retrieve some information I would like to store in Firebase at a path related to that string.
By the way, I have also attached a SSD1306 OLED display to my ESP8266
Essential code parts:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiClientSecureBearSSL.h>
#include <WiFiClient.h>
#include <Wire.h>
#include <SSD1306.h>
#include <FirebaseESP8266.h>
#define FIREBASE_HOST "xxxxxxxxxxxxxxxxxxxxxxx"
#define FIREBASE_AUTH "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
#define OLED_ADDRESS 0x3C //you may need to change this, this is the OLED I2C address.
SSD1306 display(OLED_ADDRESS, D2, D1);
ESP8266WiFiMulti WiFiMulti;
FirebaseData firebaseData;
...
void setup() {
...
WiFi.mode(WIFI_STA);
WiFiMulti.addAP("aaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbb");
while(WiFiMulti.run() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
...
}
void loop() {
WiFiClientSecure client;
client.setInsecure();
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
Firebase.reconnectWiFi(true);
firebaseData.setBSSLBufferSize(3072, 512);
firebaseData.setResponseSize(3072);
if(Firebase.get(firebaseData, "/my/path")){
Serial.print("Read object of type ");
Serial.println(firebaseData.dataType());
FirebaseJson& json = firebaseData.jsonObject();
size_t len = json.iteratorBegin();
String key, value = "";
int type = 0;
String buffer[len];
for (size_t i = 0; i < len; i++)
{
json.iteratorGet(i, type, key, value);
buffer[i] = key;
}
json.iteratorEnd();
delay(500);
// check single IDs
for(size_t i = 0; i < len; i++) {
String url = "/" + buffer[i];
if (!client.connect(host, httpsPort)) { // the problems happen here
Serial.println("connection failed");
} else {
...
}
client.stop();
}
}
}