I'm working with ESP32 with Cloud Firestore. I'm attempting to make a request to get the data from a certain collection and document.
I have been able to access a single collection but, I'm having problems accessing a subcollection.
This is my ESP32 code to get the collection data:
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <WiFi.h>
#define lamp 13
const char* ssid = "SSID";
const char* password = "Ok";
void setup() {
Serial.begin(115200);
pinMode(lamp, OUTPUT);
WiFi.begin(ssid, password);
delay(5000);
Serial.println("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED){
delay(1000);
Serial.print(".");
}
}
void loop() {
if (WiFi.status() == WL_CONNECTED){
HTTPClient http;
http.begin("stuff.net/app/api/read/5j5UF0lFovW8g5QSXXymWYsz0QB2");
int httpCode = http.GET();
if (httpCode > 0){
String payload = http.getString(); //ISSO é PARA GET REQUEST
Serial.println(httpCode);
Serial.println(payload);
char json[500];
payload.toCharArray(json, 500);
StaticJsonDocument<1024> doc;
deserializeJson(doc, json);
String device0 = doc["device0"];
}
http.end();
}else{
Serial.println("Erro com conex?o, chekar conex?o ao WiFi");
}
delay(1000);
}
This is how my Firestore looks:
I have attempted:
https://stuff.net/app/api/read/5j5UF0lFovW8g5QSXXymWYsz0QB2/buttons/button0
Won't work
question from:
https://stackoverflow.com/questions/65905624/esp32-with-rest-api-in-cloud-firestore 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…