communication between esp32 and firestore "response payload read timed out"

109 Views Asked by At

i am trying to uplaod a temperature sensor data into firestore data base using an ESP32 and DS18B20 temperature sensor. the problem is when trying to connect ESP32 to firestore database i do not know what is the cause of this problem, the code compiles and uploads with success, in the serial monitor it prints this

Connecting to WiFi....

Connected with IP: 192.168.

firebase client v4.4.10 Token info: type = id token (GITKit token),
status = on request Token info: type = id token (GITKit token), status
= error Token error: code: -6, message: response payload read timed out
        Token info: type = id token (GITKit token), status = on
request Token info: type = id token (GITKit token), status = error
Token error: code: -6, message: response payload read timed out       
Token info: type = id token (GITKit token), status = on request Token
info: type = id token (GITKit token), status = error Token error:
code: -6, message: response payload read timed out        Token info:
type = id token (GITKit token), status = on request Token info: type =
id token (GITKit token), status = error Token error: code: -6,
message: response payload read timed out

this is the code if it helps

#include <Arduino.h>
#include <OneWire.h>
#include <Wire.h>
#include <DallasTemperature.h>

#include <WiFi.h>
#include <Firebase_ESP_Client.h>
#include <addons/TokenHelper.h>

#define WIFI_SSID "TPlink"
#define WIFI_PASSWORD "laugh__ta1e"

#define API_KEY "the firestore API key"
#define FIRESTORE_PROJECT_ID "firestore project ID"
#define USER_EMAIL "email"
#define USER_PASSWORD "password"

int oneWireBus = 4;
OneWire oneWire(oneWireBus);
DallasTemperature sensors(&oneWire);

FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;

void setup()
{
  Serial.begin(115200);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to WiFi");

  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(300);
  }

  Serial.println();
  Serial.print("Connected with IP: ");
  Serial.println(WiFi.localIP());
  Serial.println();

  Serial.printf("firebase client v%s\n\n", FIREBASE_CLIENT_VERSION);

  config.api_key = API_KEY;

  auth.user.email = USER_EMAIL;
  auth.user.password = USER_PASSWORD;

  config.token_status_callback = tokenStatusCallback;
  Firebase.reconnectNetwork(true);

  Firebase.reconnectWiFi(true);

  Firebase.begin(&config, &auth);
  delay(1500);
  Serial.println("Connected successfully");

  // Start the DS18B20 sensor
  sensors.begin();
  pinMode(btn, INPUT_PULLUP);
}

void loop()
{
  String path = "/Sensor/temp";
  FirebaseJson content;
  float tempC = sensors.getTempCByIndex(0);

  content.set("TempCollection/Device1/Temperature", String(tempC));
  Serial.print("update/add temp to data... ");

  if (Firebase.Firestore.patchDocument(&fbdo, FIRESTORE_PROJECT_ID, "", path.c_str(), content.raw(), "Temperature"))
  {
    Serial.printf("ok\n%s\n\n", fbdo.payload().c_str());
  }
  else
  {
    Serial.println("its in here !!!");
    Serial.println(fbdo.errorReason());
  }
}

i do not know if this is relevant but when creating firestore database i could not at first the error message for that i disabled react extentions and deselect "show CORS errors in console" i refreshed and the database was created

i tried changing the security rules i tried changing the sign-up methods in firebase as for the code i did not know what to change

upon further testing the issue might be around here

#include <addons/TokenHelper.h>

FirebaseConfig config; config.token_status_callback = tokenStatusCallback;

0

There are 0 best solutions below