Ubidots Community

ESP 32 Firebase Coding error to Database

Hello i’m having problem compiling this coding . I don’t know what mistakes i did , So i’m trying to sync my sensor data to firebase but the problem turns out like this.

this is the error message

this is where the problem but i don’t know how to solve it

//esp32 with wifi library
#include <WiFi.h>
#include <WiFiClient.h>
#include <esp_now.h> 
#include <esp_wifi.h> 






//firebaseArduino library
#include <FirebaseESP32.h>





//dht11 library
#include <DHT.h>

//define dht sensor
#define DHTTYPE DHT11

//insert wifi credential
const char* ssid = "nasran65@unifi";
const char* password = "nasran65";

//define rtdb
#define FIREBASE_HOST "projectfirebase-688c5-default-rtdb.asia-southeast1.firebasedatabase.app"

//define rtdb secret key
#define FIREBASE_AUTH "EXpcv1T6ggWyGLusYX2nABy9cAVAqvpNxVODw1NF"

//define dht sensor pin
const int DHTPin = 5;


// Initialize DHT sensor.
DHT dht(DHTPin, DHTTYPE);


void setup() {
Serial.begin(9600);
 dht.begin();
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.println("Connecting to wifi...");
    delay(500);
  }
 Serial.println("wifi connected");
 Serial.println(WiFi.localIP());
 Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
 

pinMode(23,INPUT);
digitalWrite(23,LOW);
}
void loop() {
   Serial.print("RSSI: ");
  Serial.print(WiFi.RSSI());
  Serial.println("dBm");

  long rssiValue = WiFi.RSSI();
  
//store data into firebase rtdb

  Firebase.setFloat("Sensor/RSSI",rssiValue);
  Firebase.getFloat("Sensor/RSSI");

  //read humidity
  float h = dht.readHumidity();
  //read temperature (in Celsius) 
  float t = dht.readTemperature();

   // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
  Serial.println("Failed to read from DHT sensor!");
  return;
 }  
 //Computes temperature values in Celsius
  float hic = dht.computeHeatIndex(t, h, false);

  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println("°C");
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.println("%");

  //store dht11 data into firebase rtdb
  Firebase.setFloat("Sensor/TEMP",t);
  Firebase.getFloat("Sensor/TEMP");
  Firebase.setFloat("Sensor/HUMID",h);
  Firebase.getFloat("Sensor/HUMID");

// store pir data into firebase rtdb
 Firebase.setFloat("Sensor/PIR",PIR);
  Firebase.getFloat("Sensor/PIR");

// store pir data into firebase rtdb
 Firebase.setFloat("Sensor/LDR",ldr);
  Firebase.getFloat("Sensor/LDR");


if(digitalRead(23)==HIGH) {
Serial.println("Somebody is here.");
}
else {
Serial.println("Nobody.");
}

int ldr = analogRead( A0 );
Serial.println("LDR : " + String(ldr) );


delay(1000);
}

Hi @lutfi,

I hope all is well.

Can you please clarify how does it related with Ubidots platform, as it seems that you are using Firebase? This could help us and the community better address your question.

In case you want to connect the ESP32 with Ubidots, please refer to the following article to learn how.

– Isabel

Nvm i have solved the problem

1 Like