I am making a project for school where I have to send data from a sensor to a webpage. After doing some research I decided to use a Real-Time Firebase database. Security is not really important and I want to focus on other aspects of the project, so this seemed like an easy and quick option. I am using a d1 mini (esp8266) and a DHT11 humidity and temp sensor. For libraries I am using DHT, FirebaseArduino and ESP8266WiFi. The code is:

#include <ESP8266WiFi.h>                                                    // esp8266 library
#include <FirebaseArduino.h>                                                // firebase library
#include <DHT.h>                                                            // dht11 temperature and humidity sensor library

#define FIREBASE_HOST "xx"                   // the project name address from firebase id
#define FIREBASE_AUTH "xx"            // the secret key generated from firebase

#define WIFI_SSID "xx"                                             // input your home or public wifi name 
#define WIFI_PASSWORD "xx"                                        //password of wifi ssid

#define DHTPIN D5                                                           // what digital pin we're connected to
#define DHTTYPE DHT11                                                       // select dht type as DHT 11 or DHT22
DHT dht(DHTPIN, DHTTYPE);                                                     

void setup() {
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);                                     //try to connect with wifi
  Serial.print("Connecting to ");
  while (WiFi.status() != WL_CONNECTED) {
  Serial.print("Connected to ");
  Serial.print("IP Address is : ");
  Serial.println(WiFi.localIP());                                            //print local IP address
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);                              // connect to firebase
  dht.begin();                                                               //Start reading dht sensor

void loop() { 
  float h = dht.readHumidity();                                              // Reading temperature or humidity takes about 250 milliseconds!
  float t = dht.readTemperature();                                           // Read temperature as Celsius (the default)

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

  Serial.print("Humidity: ");  Serial.print(h);
  String fireHumid = String(h) + String("%");                                         //convert integer humidity to string humidity 
  Serial.print("%  Temperature: ");  Serial.print(t);  Serial.println("°C ");
  String fireTemp = String(t) + String("°C");                                                     //convert integer temperature to string temperature

  Firebase.pushString("Humidity/", fireHumid);                                       //setup path and send readings
  Firebase.pushString("Temperature/", fireTemp);                                //setup path and send readings


replaced some 'sensitive' information with "xx". When running this code, it connects to my wifi connection and shows data from the DHT11 in the serial monitor. However NOTHING changes in Firebase. After enabling the feature to display extensive feedback/errors in the serial monitor, I noticed it's displaying this:

[HTTP-Client][begin] host: https://testtesttest-bd679.firebaseio.com/ port: 443 url: /Temperature/.json?auth=xxxx httpsFingerprint: 03 D6 42 23 03 D1 0C 06 73 F7 E2 BD 29 47 13 C3 22 71 37 1B
[HTTP-Client][sendRequest] type: 'POST' redirCount: 0
[HTTP-Client] failed connect to https://xxx-xxx.firebaseio.com/:443
[HTTP-Client][returnError] error(-1): connection refused
[HTTP-Client][returnError] error(-4): not connected
[HTTP-Client][end] tcp is closed
Humidity: 43.00%  Temperature: 22.50°C

I have tried the following things:

  • Using a different version of the FirebaseArduino library (5.13.x (still using this one))
  • Manually updating the fingerprint of the FirebaseArduino library (see current fingerprint in 2nd code section above)
  • Using different versions of the Arduino IDE, using 1.8.12 now

And some other minor changes like creating a new Firebase Database or using something different from pushString to add data to the database.

None of this helped and I am running out of time for my project, hope someone here knows what's wrong and can help me out! :)

1 Answer 1


You added a / to the end of the Humidity and Temperature collections. e.g Firebase.pushString("Humidity/", fireHumid);
Firebase.pushString("Temperature/", fireTemp);

The firebase API translates it to an address


as we can see in the output.

I'm pretty sure the correct address is ...Temperature.json... and not ...Temperature/.json....

Please try to remove the slashes from the end of the collection names in the pushString statements..

Firebase.pushString("Humidity", fireHumid);    
Firebase.pushString("Temperature", fireTemp);

If this does not help, it is possibly a problem with the auth string or the Host name. e.g trailing or leading space characters or something like that.

  • Thank you for your answer. It is able to connect to Firebase now. However i am getting this error now, maybe you know how to resolve this one aswell :) [HTTP-Client][handleHeaderResponse] RX: 'HTTP/1.1 400 Bad Request' This error occurs after it connects and it starts trying to push information into the database.
    – Luukv19
    Mar 8, 2020 at 16:44
  • I deleted my former comment because my explanation was not correct. I do not know Firebase very well. The message says that page (respective the api method ) you try to access did not exist, Perhaps it works if you use other access methods. Perhaps push is not supported (for what reason ever): try setString insteadof pushString for example. If that works, I can not explain why, but you have a start point for further investigations. It would be helpful to know that, the Firebase. ... methods are translated to REST api calls and send as HTTP Requests to the firebase server. Mar 8, 2020 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.