FAILED REASON: missing required credentials e.g., database URL, host and tokens

i m beginner i have this code to send temperature and humidity from esp32 to firebase and i got this problem
FAILED
REASON: missing required credentials e.g., database URL, host and tokens.

</
#include <WiFi.h>
#include <FirebaseESP32.h>
#include <DHT.h>
#define FIREBASE_HOST "https://laddi1-default-rtdb.firebaseio.com/" //Without <a href="http:// or"> http:// or </a> <a href="https:// schemes"> https:// schemes</a>
#define FIREBASE_AUTH " AIzaSyC-5l5qN3e7UL4cFI2Pi_UOxsnEOeuVKu8 " 
#define WIFI_SSID "TP-LINK_4206DF"
#define WIFI_PASSWORD "20172018"

#define DHTPIN 27		// Connect Data pin of DHT to D2
int led = 25;			// Connect LED to D5

#define DHTTYPE    DHT22
DHT dht(DHTPIN, DHTTYPE);

//Define FirebaseESP8266 data object
FirebaseData firebaseData;
FirebaseData ledData;

FirebaseJson json;
FirebaseConfig config;
FirebaseAuth auth;
void setup()
{

  Serial.begin(115200);

  dht.begin();
  pinMode(led,OUTPUT);
  
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(300);
  }
  Serial.println();
  Serial.print("Connected with IP: ");
  Serial.println(WiFi.localIP());
  Serial.println();

  config.api_key = FIREBASE_AUTH;
  config.database_url = FIREBASE_HOST;

  Firebase.begin(&config, &auth);
  Firebase.reconnectWiFi(true);

}

void sensorUpdate(){
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }

  Serial.print(F("Humidity: "));
  Serial.print(h);
  Serial.print(F("%  Temperature: "));
  Serial.print(t);
  Serial.print(F("C  ,"));
  Serial.print(f);
  Serial.println(F("F  "));

if (Firebase.setFloat(firebaseData, "/FirebaseIOT/temperature", t))
  {
    Serial.println("PASSED");
    Serial.println("PATH: " + firebaseData.dataPath());
    Serial.println("TYPE: " + firebaseData.dataType());
    Serial.println("ETag: " + firebaseData.ETag());
    Serial.println("------------------------------------");
    Serial.println();
  }
  else
  {
    Serial.println("FAILED");
    Serial.println("REASON: " + firebaseData.errorReason());
    Serial.println("------------------------------------");
    Serial.println();
  }

  if (Firebase.setFloat(firebaseData, "/FirebaseIOT/humidity", h))
  {
    Serial.println("PASSED");
    Serial.println("PATH: " + firebaseData.dataPath());
    Serial.println("TYPE: " + firebaseData.dataType());
    Serial.println("ETag: " + firebaseData.ETag());
    Serial.println("------------------------------------");
    Serial.println();
  }
  else
  {
    Serial.println("FAILED");
    Serial.println("REASON: " + firebaseData.errorReason());
    Serial.println("------------------------------------");
    Serial.println();
  }
}
void loop() {
  sensorUpdate();
  
  if (Firebase.getString(ledData, "/FirebaseIOT/led")){
    Serial.println(ledData.stringData());
    if (ledData.stringData() == "1") {
    digitalWrite(led, HIGH);
    }
  else if (ledData.stringData() == "0"){
    digitalWrite(led, LOW);
    }
  }
  delay(5000);

}  >

Read what is written after the //....

//Without http:// or <a href="https:................. ........

I tried and it didn't work and the same problem remains

The Nano ESP32 section is specific for the Arduino Nano ESP32 boards, not for other ESP32 boards. Therefore your topic has been moved.

I further advise you to replace any credentials / password in your code by dummies before posting on the forum.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.