In this guide, you’ll learn how to log data with the ESP8266 NodeMCU to the Firebase Realtime Database with timestamps (data logging) so that you have a record of your data history. As an example, we’ll log temperature, humidity, and pressure from a BME280 sensor and we’ll get timestamps from an NTP server. Then, you can access the data using the Firebase console, or build a web app to display the results (check this tutorial).

Updated 15 May 2025
Part 2: ESP32/ESP8266: Firebase Data Logging Web App (Gauges, Charts, and Table)
Other Firebase Tutorials with the ESP32/ESP8266 that you might be interested in:
- ESP8266 NodeMCU: Getting Started with Firebase (Realtime Database)
- ESP8266 NodeMCU with Firebase – Creating a Web App
- ESP32/ESP8266 Firebase Authentication (Email and Password)
- ESP32/ESP8266 Firebase: Send BME280 Sensor Readings to the Realtime Database
- ESP32/ESP8266: Firebase Web App to Display Sensor Readings (with Authentication)
What is Firebase?

Firebase is Google’s mobile application development platform that helps you build, improve, and grow your app. It has many services used to manage data from any android, IOS, or web application like authentication, realtime database, hosting, etc.
Project Overview
The following diagram shows a high-level overview of the project we’ll build.

- The ESP8266 authenticates as a user with email and password (that user must be set on the Firebase authentication methods);
- After authentication, the ESP gets the user UID;
- The database is protected with security rules. The user can only access the database nodes under the node with its user UID. After getting the user UID, the ESP can publish data to the database;
- The ESP8266 gets temperatrure, humidity and pressure from the BME280 sensor.
- It gets epoch time right after gettings the readings (timestamp).
- The ESP8266 sends temperature, humidity, pressure and timestamp to the database.
- New readings are added to the database periodically. You’ll have a record of all readings on the Firebase realtime database.
These are the main steps to complete this project:
- Create Firebase Project
- Set Authentication Methods
- Get Project API Key
- Set up Realtime Database
- Set up Database Security Rules
- ESP8266 Datalogging (Firebase Realtime Database)
You can continue with the Firebase project from this previous tutorial or create a new project. If you use the Firebase project of that previous tutorial, you can skip to section 4) Set up Realtime Database because the authentication methods are already set up.
Preparing Arduino IDE
For this tutorial, we’ll program the ESP8266 board using the Arduino core. So, make sure you have the ESP8266 add-on installed in your Arduino IDE:
If you want to program the ESP8266 boards using VS Code with the PlatformIO extension, follow the following tutorial instead:
1) Create Firebase Project
Follow the next instructions to create a new project on Firebase.
- Go to Firebase and sign in using a Google Account.
- Go to the Firebase Console and create a new project.
- Give a name to your project, for example: ESP-Project, and click Continue.
- Next, enable or disable AI assistance for your project. This is optional.
- Disable the option Enable Google Analytics for this project, as it is not needed. Then, click Create project.
- It will take a few seconds to set up your project. Click Continue when it’s ready.
- You’ll be redirected to your Project console page.
2) Set Authentication Methods
To allow authentication with email and password, first, you need to set authentication methods for your app.
“Most apps need to know the identity of a user. In other words, it takes care of logging in and identifying the users (in this case, the ESP8266). Knowing a user’s identity allows an app to securely save user data in the cloud and provide the same personalized experience across all of the user’s devices.” To learn more about the authentication methods, you can read the documentation.
- On the left sidebar, click on Build > Authentication and then on Get started.
- There are several authentication methods like email and password, Google Account, Facebook account, and others.
- Select Email/Password and enable that authentication method. Then, click Save.
- Then, at the top, click on the Users tab. Then, click on Add user.
- Create a new user with an email and password. The email can be your personal email. Create a password for that user (you need to remember the password later). Finally, click on Add user.
- The User will show up on the list of users. You can see information about the user, like when it was created, the last time it signed in, and its user UID.
Firebase creates a unique UID for each registered user. The user UID allows us to identify the user and keep track of the user to provide or deny access to the project or the database. There’s also a column that registers the date of the last sign-in. At the moment, it is empty because we haven’t signed in with that user yet.
3) Get Project API Key
To interface with your Firebase project using the ESP32 or ESP8266 boards, you need to get your project API key. Follow the next steps to get your project API key.
- To get your project’s API key, on the left sidebar click on Project Settings.
- Copy the API Key to a safe place because you’ll need it later.
To interface with your Firebase project using the ESP8266 board, you need to get your project API key. Follow the next steps to get your project API key.
4) Set up the Realtime Database
Now, let’s create a realtime database and set up database rules for our project.
1) On the left sidebar, click on Realtime Database and then click on Create Database.

2) Select your database location. It should be the closest to your location.

3) Set up security rules for your database. You can select Start in test mode. We’ll change the database rules in just a moment.

4) Your database is now created. You need to copy and save the database URL—highlighted in the following image—because you’ll need it later in your ESP8266 code.

5) Set up Database Security Rules
Now, let’s set up the database rules. On the Realtime Database tab, select the Rules tab at the top. Then, click on Edit rules, copy the following rules and then click Publish.
// These rules grant access to a node matching the authenticated
// user's ID from the Firebase auth token
{
"rules": {
"UsersData": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
}

These rules allow access only to the node that matches the authenticated user’s UID. This ensures that each user can access only their own data. In other words, a user can only read or write to the parts of the database located under their specific UID. Any data stored outside of their UID node will not be accessible to them.
For example, imagine our user UID is RjO3taAzMMXBB2Xmir2LQ. With our security rul
6) ESP8266 Datalogging (Firebase Realtime Database)
In this section, we’ll program the ESP8266 board to do the following tasks:
- Authenticate as a user with email and password (the user you set up in this section);
- Get BME280 readings: temperature, humidity, and pressure;
- Get epoch time (timestamp) from an NTP server;
- Send sensor readings and timestamp to the realtime database as an authorized user.
Parts Required
For this project, you need the following parts*:
- ESP8266 board (read best ESP8266 boards comparison);
- BME280 or any other sensor you’re familiar with;
- Breadboard;
- Jumper wires.
* you can also test the project with random values instead of sensor readings, or you can use any other sensor you’re familiar with.
You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!
Schematic Diagram
In this tutorial, we’ll send BME280 sensor readings to the Firebase Realtime Database. So, you need to wire the BME280 sensor to your board.
We’re going to use I2C communication with the BME280 sensor module. For that, wire the sensor to the default ESP8266 SCL (GPIO 5 (D1)) and SDA (GPIO 4 (D2)) pins, as shown in the following schematic diagram.

Not familiar with the BME280 with the ESP8266? Read this tutorial: ESP8266 with BME280 Sensor using Arduino IDE (Pressure, Temperature, Humidity).
Installing Libraries
For this project, you need to install the following libraries:
Installing Libraries – VS Code
Follow the next instructions if you’re using VS Code with the PlatformIO or pioarduino extension.
Install the FirebaseClient Library
Click on the PIO Home icon and select the Libraries tab. Search for “FirebaseClient“. Select the Firebase Client Library by Mobitz.
If you’re using VS Code with the PlatformIO extension, click on the PIO Home icon and then select the Libraries tab. Search for “FirebaseClient“. Select the Firebase Client Library by Mobitz.

Then, click Add to Project and select the project you’re working on.

Then, click Add to Project and select the project you’re working on.
Install the BME280 Library
In the Libraries tab, search for BME280. Select the Adafruit BME280 library.

Then, click Add to Project and select the project you’re working on.

Also, change the monitor speed to 115200 by adding the following line to the platformio.ini file of your project:
monitor_speed = 115200
Installation – Arduino IDE
Follow this section if you’re using Arduino IDE.
You need to install the following libraries:
Go to Sketch > Include Library > Manage Libraries, search for the libraries’ names, and install the libraries.

Now, you’re all set to start programming the ESP8266 boards to interact with the database.
Datalogging—Firebase Realtime Database Code
Copy the following code to your Arduino IDE or to the main.cpp file if you’re using VS Code.
You need to insert your network credentials, project API key, database URL, and the authorized user email and password.
/*
Rui Santos & Sara Santos - Random Nerd Tutorials
Complete project details at our blog: https://RandomNerdTutorials.com/esp8266-data-logging-firebase-realtime-database/
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <FirebaseClient.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include "time.h"
// Network and Firebase credentials
#define WIFI_SSID "REPLACE_WITH_YOUR_SSID"
#define WIFI_PASSWORD "REPLACE_WITH_YOUR_PASSWORD"
#define Web_API_KEY "REPLACE_WITH_YOUR_FIREBASE_PROJECT_API_KEY"
#define DATABASE_URL "REPLACE_WITH_YOUR_FIREBASE_DATABASE_URL"
#define USER_EMAIL "REPLACE_WITH_FIREBASE_PROJECT_EMAIL_USER"
#define USER_PASS "REPLACE_WITH_FIREBASE_PROJECT_USER_PASS"
// User functions
void processData(AsyncResult &aResult);
// Authentication
UserAuth user_auth(Web_API_KEY, USER_EMAIL, USER_PASS);
// Firebase components
FirebaseApp app;
WiFiClientSecure ssl_client;
using AsyncClient = AsyncClientClass;
AsyncClient aClient(ssl_client);
RealtimeDatabase Database;
// Timer variables for sending data every 10 seconds
unsigned long lastSendTime = 0;
const unsigned long sendInterval = 10000; // 10 seconds in milliseconds
// Variable to save USER UID
String uid;
// Database main path (to be updated in setup with the user UID)
String databasePath;
// Database child nodes
String tempPath = "/temperature";
String humPath = "/humidity";
String presPath = "/pressure";
String timePath = "/timestamp";
// Parent Node (to be updated in every loop)
String parentPath;
int timestamp;
const char* ntpServer = "pool.ntp.org";
// BME280 sensor
Adafruit_BME280 bme; // I2C
float temperature;
float humidity;
float pressure;
// Create JSON objects for storing data
object_t jsonData, obj1, obj2, obj3, obj4;
JsonWriter writer;
// Initialize BME280
void initBME(){
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
// Initialize WiFi
void initWiFi() {
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to WiFi ..");
while (WiFi.status() != WL_CONNECTED) {
Serial.print('.');
delay(1000);
}
}
// Function that gets current epoch time
unsigned long getTime() {
time_t now;
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) {
//Serial.println("Failed to obtain time");
return(0);
}
time(&now);
return now;
}
void setup(){
Serial.begin(115200);
initBME();
initWiFi();
configTime(0, 0, ntpServer);
// Configure SSL client
ssl_client.setInsecure();
ssl_client.setTimeout(1000); // Set connection timeout
ssl_client.setBufferSizes(4096, 1024); // Set buffer sizes
// Initialize Firebase
initializeApp(aClient, app, getAuth(user_auth), processData, "🔐 authTask");
app.getApp<RealtimeDatabase>(Database);
Database.url(DATABASE_URL);
}
void loop(){
// Maintain authentication and async tasks
app.loop();
// Check if authentication is ready
if (app.ready()){
// Periodic data sending every 10 seconds
unsigned long currentTime = millis();
if (currentTime - lastSendTime >= sendInterval){
// Update the last send time
lastSendTime = currentTime;
uid = app.getUid().c_str();
// Update database path
databasePath = "/UsersData/" + uid ;
//Get current timestamp
timestamp = getTime();
Serial.print ("time: ");
Serial.println (timestamp);
parentPath= databasePath + "/" + String(timestamp);
// Get sensor readings
temperature = bme.readTemperature();
humidity = bme.readHumidity();
pressure = bme.readPressure()/100.0;
// Create a JSON object with the data
writer.create(obj1, tempPath, temperature);
writer.create(obj2, humPath, humidity);
writer.create(obj3, presPath, pressure);
writer.create(obj4, timePath, timestamp);
writer.join(jsonData, 4, obj1, obj2, obj3, obj4);
Database.set<object_t>(aClient, parentPath, jsonData, processData, "RTDB_Send_Data");
}
}
}
void processData(AsyncResult &aResult){
if (!aResult.isResult())
return;
if (aResult.isEvent())
Firebase.printf("Event task: %s, msg: %s, code: %d\n", aResult.uid().c_str(), aResult.eventLog().message().c_str(), aResult.eventLog().code());
if (aResult.isDebug())
Firebase.printf("Debug task: %s, msg: %s\n", aResult.uid().c_str(), aResult.debug().c_str());
if (aResult.isError())
Firebase.printf("Error task: %s, msg: %s, code: %d\n", aResult.uid().c_str(), aResult.error().message().c_str(), aResult.error().code());
if (aResult.available())
Firebase.printf("task: %s, payload: %s\n", aResult.uid().c_str(), aResult.c_str());
}
How the Code Works
Continue reading to learn how the code works, or skip to the demonstration section.
Include Libraries
First, include the required libraries.
#include <Arduino.h>
#if defined(ESP32)
#include <WiFi.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#endif
#include <WiFiClientSecure.h>
#include <FirebaseClient.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include "time.h"
Network Credentials
Include your network credentials in the following lines so that your boards can connect to the internet using your local network.
// Insert your network credentials
#define WIFI_SSID "REPLACE_WITH_YOUR_SSID"
#define WIFI_PASSWORD "REPLACE_WITH_YOUR_PASSWORD"
Firebase Project API Key, Firebase User, and Database URL
Insert your Firebase project API key—the one you’ve gotten in this section.
#define Web_API_KEY "REPLACE_WITH_YOUR_PROJECT_API_KEY"
Insert the authorized email and the corresponding password—these are the details of the user you’ve added in this section.
// Insert Authorized Email and Corresponding Password
#define USER_EMAIL "REPLACE_WITH_THE_USER_EMAIL"
#define USER_PASSWORD "REPLACE_WITH_THE_USER_PASSWORD"
Insert your database URL in the following line:
// Insert RTDB URLefine the RTDB URL
#define DATABASE_URL "REPLACE_WITH_YOUR_DATABASE_URL"
Declaring Firebase Authentication and Components
The following line creates an authentication object using the project API key, the project user email, and password.
UserAuth user_auth(Web_API_KEY, USER_EMAIL, USER_PASS);
This creates a FirebaseApp instance called app that refers to the Firebase application.
FirebaseApp app;
The following lines set up the asynchronous communication framework for interacting with Firebase’s Realtime Database. Basically, you create an SSL client using the WiFiClientSecure library. Then, you instantiate an Asynchronous client called aClient that enables secure HTTPS. This will allow you to handle network operations asynchronously.
WiFiClientSecure ssl_client;
using AsyncClient = AsyncClientClass;
AsyncClient aClient(ssl_client);
The following line creates a RealtimeDatabase object called Database, which represents the Firebase Realtime Database.
RealtimeDatabase Database;
Timer and Data Variables
Then create variables to track the time. We’ll send sensor readings to the database every 10 seconds.
// Timer variables for sending data every 10 seconds
unsigned long lastSendTime = 0;
const unsigned long sendInterval = 10000;
Create a variable to save the user UID. The uid variable will be used to save the user’s UID. We can get the user’s UID after the authentication.
// Variable to save USER UID
String uid;
Create variables to save the database path and specific database nodes. We’ll update these variables later in the code when we get the user UID.
// Database main path (to be updated in setup with the user UID)
String databasePath;
// Database child nodes
String tempPath = "/temperature";
String humPath = "/humidity";
String presPath = "/pressure";
String timePath = "/timestamp";
// Parent Node (to be updated in every loop)
String parentPath;
We create a variable to save the timestamp and another to save the NTP server.
int timestamp;
const char* ntpServer = "pool.ntp.org";
BME280 Variables
Then, create an Adafruit_BME280 object called bme. This automatically creates a sensor object on the ESP8266 default I2C pins.
Adafruit_BME280 bme; // I2C
The following variables will hold the temperature, humidity, and pressure readings from the sensor.
float temperature;
float humidity;
float pressure;
JSON Variables
We’ll send all data to the database in a JSON object. The FirebaseClient library has its own JSON methods. You should use them instead of other JSON libraries. To do that, we need to create four jsonData objects called obj1, obj2, obj3, and obj4.
object_t jsonData, obj1, obj2, obj3, obj4;
Then, we need to create an instance of the JsonWriter class, in this case called writer, that provides methods to create and combine JSON objects for Firebase.
JsonWriter writer;
To learn more, we recommend reading this section of the documentation about the JsonWriter object.
initBME()
The initBME() function will initialize the BME280 sensor. We’ll call it later in the setup().
// Initialize BME280
void initBME(){
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
Serial.print("BME280 Initialized with success");
}
initWiFi()
The initWiFi() function will connect the ESP8266 to your local network using the SSID and password defined earlier.
// Initialize WiFi
void initWiFi() {
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to WiFi ..");
while (WiFi.status() != WL_CONNECTED) {
Serial.print('.');
delay(1000);
}
}
getTime()
The getTime() function returns the current epoch time.
// Function that gets current epoch time
unsigned long getTime() {
time_t now;
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) {
//Serial.println("Failed to obtain time");
return(0);
}
time(&now);
return now;
}
To learn more about getting epoch time with the ESP8266 board, you can check the following tutorial:
setup()
In the setup(), initialize the Serial Monitor, the BME280 sensor, WiFi, and configure the NTP server.
void setup(){
Serial.begin(115200);
initBME();
initWiFi();
configTime(0, 0, ntpServer);
Configure the SSL Client.
ssl_client.setInsecure();
#if defined(ESP32)
ssl_client.setConnectionTimeout(1000);
ssl_client.setHandshakeTimeout(5);
#elif defined(ESP8266)
ssl_client.setTimeout(1000); // Set connection timeout
ssl_client.setBufferSizes(4096, 1024); // Set buffer sizes
#endif
The following line initializes the Firebase app with authentication and sets the processData() as the callback function for async results (this means that any results from the initializeApp() function will be handled on the processData() callback function).
initializeApp(aClient, app, getAuth(user_auth), processData, "🔐 authTask");
Then, tell that you want to set the Database object defined earlier as a database for our Firebase app.
app.getApp<RealtimeDatabase>(Database);
Finally, set the database URL.
Database.url(DATABASE_URL);
loop()
The Firebase library we’re using works asynchronously and with callback functions. This means that when an event happens, the corresponding assigned callback functions will run. To keep the Firebase app running, handling authentication and asynchronous tasks, we need to add app.loop() at the start of our loop() function.
void loop(){
app.loop();
The app.ready() command checks if Firebase authentication is complete and ready, so that we can proceed with other Firebase operations (like writing to the database).
if (app.ready()){
The following lines check if 10 seconds (sendInterval) have passed. We’ll use this to send data periodically every 10 seconds.
// Periodic data sending every 10 seconds
unsigned long currentTime = millis();
if (currentTime - lastSendTime >= sendInterval){
// Update the last send time
lastSendTime = currentTime;
After a successful authentication, we’ll get the user UID and save it in the uid variable. Then, we’ll update the database path to UsersData/<USER_UID>.
uid = app.getUid().c_str();
The databasePath variable saves the database main path, which can now be updated with the user UID.
// Update database path
databasePath = "/UsersData/" + uid;
After this, we can get the current timestamp and update the path where the readings will be saved.
//Get current timestamp
timestamp = getTime();
Serial.print ("time: ");
Serial.println (timestamp);
parentPath= databasePath + "/" + String(timestamp);
To better understand how we’ll organize our data, here’s a diagram.

It might seem redundant to save the timestamp twice (in the parent node and the child node), however, having all the data at the same level of the hierarchy will make things simpler in the future, if we want to build a web app to display the data.
After getting the timestamp and updating all database nodes with the user UID and corresponding timestamp, we can get readings from the BME280 sensor.
// Get sensor readings
temperature = bme.readTemperature();
humidity = bme.readHumidity();
pressure = bme.readPressure()/100.0;
Creating the JSON Objects
We’ll send all the readings and corresponding timestamps to the realtime database at the same time by creating a JSON object that contains the values of those variables. The FirebaseClient library has its own JSON methods. We’ll use them to send data in JSON format to the database.
We use the create() method on the writer object to create a JSON object with a key (node) and corresponding value (sensor readings).
For example, the following line creates a JSON object with tempPath as the key and temperature as the value. It stores the result in obj1.
writer.create(obj1, tempPath, temperature);
An example of output would be in this case:
obj1 = {"UserData/<user_udi>/timestamp/temperature": 23.5}
We proceed similarly for the other readings and timestamp.
writer.create(obj2, humPath, humidity);
writer.create(obj3, presPath, pressure);
writer.create(obj4, timePath, timestamp);
Then, we use the join() method on the writer object to merge the four JSON objects (obj1, obj2, obj3, obj4) into a single JSON structure, stored in jsonData. The 4 indicates the number of objects to combine.
writer.join(jsonData, 4, obj1, obj2, obj3, obj4);
Sending the JSON Object
Finally, we can send the JSON object to the database using the set() method on the database object. We already explained how this works in this previous tutorial.
Database.set<object_t>(aClient, parentPath, jsonData, processData, "RTDB_Send_Data");
This uses the SSL client aClient and sends the jsonData variable to the parentPath path in the database. The results of this operation will be handled on the processData function. The last parameter RTDB_Send_Data identifies this task.
Finally, the processData() function logs the results of the asynchronous Firebase operations.
void processData(AsyncResult &aResult){
if (!aResult.isResult())
return;
if (aResult.isEvent())
Firebase.printf("Event task: %s, msg: %s, code: %d\n", aResult.uid().c_str(), aResult.eventLog().message().c_str(), aResult.eventLog().code());
if (aResult.isDebug())
Firebase.printf("Debug task: %s, msg: %s\n", aResult.uid().c_str(), aResult.debug().c_str());
if (aResult.isError())
Firebase.printf("Error task: %s, msg: %s, code: %d\n", aResult.uid().c_str(), aResult.error().message().c_str(), aResult.error().code());
if (aResult.available())
Firebase.printf("task: %s, payload: %s\n", aResult.uid().c_str(), aResult.c_str());
}
Demonstration
Upload the previous code to your ESP8266 NodeMCU board. Don’t forget to insert your network credentials, project API key, database URL, user email, and the corresponding password.
After uploading the code, press the board RST button so that it starts running the code. It should authenticate to Firebase, get the user UID, and immediately send new readings to the database.
Open the Serial Monitor at a baud rate of 115200 and check that everything is working as expected.

Aditionally, go to the Realtime Database on your Firebase project interface and check that new readings are saved. Notice that it saves the data under a node with the own user UID—this is a way to restrict access to the database.

Wait some time until you get some readings on the database. Expand the nodes to check the data.
Wrapping Up
In this tutorial, you learned how to log your sensor readings with timestamps to the Firebase Realtime Database using the ESP8266. This was just a simple example for you to understand how it works.
You can use other methods provided by the FirebaseClient library to log your data, and you can organize your database in different ways. We organized the database in a way that is convenient for another project that we’ll publish soon.
In PART 2, we’ll create a Firebase Web App to display all saved data in a table and the latest readings on charts:
We hope you’ve found this tutorial useful.
If you like Firebase projects, please take a look at our eBook. We’re sure you’ll like it:
Learn more about the ESP8266 with our resources:
Thanks for reading.
I wish this also had how to do this with deep sleep enabled
Great code, as long as the esp8266+BME280 of the device is placed in the detection environment, I can run Firebase real-time data anywhere, watch the detection: temperature/humidity/atmospheric pressure, thank you for sharing the code👍
Hi,
Excellent tutorial!
I tried replicating it on my NodeMCU (ESP8266), but I got an error.
../Arduino/libraries/Firebase_Arduino_Client_Library_for_ESP8266_and_ESP32/src/Utils.h:1301:68: error: ‘schedule_function’ was not declared in this scope
{ schedule_function(callback); });
I don’t know where this function was supposed to be declared.
Could you help me?
Thanks!
Hi.
Are you using Arduino IDE or VS Code?
What is the version of the library that you are using?
Regards,
Sara
Hi.
I am using the Arduino IDE 1.8.19 and Firebase Arduino Client Library for ESP8266 and ESP32 ver. 3.0.1
Try downgrading the library to version 2.5.5 and check if that solves the issue.
Regards,
Sara
It worked just fine with version 2.5.5!
Thank you!
Regards,
Ricardo
For me Firebase stops working after certain time, when i see usage in firebase dashboard it shows all requests in denies, my question is how to know exact reason for denies?
I want to use Arduino Nano 33 BLE sense for this project, just wondering if I can use Firebase Arduino Client Library for ESP8266 and ESP32 for this board ?
Hi.
I don’t think it is compatible.
But you can try it and then you’ll see.
Regards,
sara
Hi,
I want to get and post data to Firebase by using AT commands ESP01 via TCP/IP.
I connected to Firebase but I can’t get or post.
AT+CIPSTART=”TCP”,”XXXX.firebaseio.com”,80
–> CONNECT
OK
AT+CIPSEND=
Hi Great Code! I am not using an authentication for my project but i do need the timestamps in my sensor reading. How can i add it?
Hi,
I tried your project but I get the following error:
“no matching function for call to ‘NTPClient::NTPClient(WiFiUDP&, const char[13]’
any help?
Hi.
What ESP8266 boards version are you using?
Go to Tools > Boards > Boards Manager and search for ESP8266.
You probably need to downgrade.
Regards,
Sara
Works very well.Tnx for the great work
Thanks
Hello how can i use other sensors i have dht11 and other bunch of sensors, i dont get the BME object and its functions how can i do that thank you <3
HELP I tried changing it to another sensor this is i get
.192.168.100.118
Token info: type = id token, status = on request
Token info: type = id token, status = ready
Getting User UID
User UID: MiSXMHlYq4M0LVwWCWWK0lnEdEe2
time: 1663231102
Set json… not found
Hi.
I think you’re not using the setjson function correctly.
Regards,
Sara
Is this right ?
parentPath= databasePath + “/” + String(timestamp);
json.set(tempPath.c_str(), String(randNumber));
json.set(timePath, String(timestamp));
Serial.printf("Set json... %s\n", Firebase.RTDB.setJSON(&fbdo, parentPath.c_str(), &json) ? "ok" : fbdo.errorReason().c_str());
Is this right ?
parentPath= databasePath + “/” + String(timestamp);
json.set(tempPath.c_str(), String(randNumber));
json.set(timePath, String(timestamp));
Serial.printf(“Set json… %s\n”, Firebase.RTDB.setJSON(&fbdo, parentPath.c_str(), &json) ? “ok” : fbdo.errorReason().c_str());
Thanks for posting this project. I’m trying to replicate but I got this error message:
21:45:08.251 -> Token info: type = id token (GITKit token), status = on request
21:45:08.251 -> Token info: type = id token (GITKit token), status = error
21:45:08.251 -> Token error: code: -4, message: connection lost
21:45:08.251 -> Getting User UID
21:45:08.251 -> …………………………………………………
Do u know why?
I’m trying to make the same project but with Arduino UNO and ESP8266-01s. I have issues, firstly, I don’t know what is the proper way to upload sensors data to the firebase to be accessed by the website? Any help will be appreciated. Thanks.
I’m trying to make the same project but with Arduino UNO and ESP8266-01s. I have issues, firstly, I don’t know what is the proper way to upload sensors data to the firebase to be accessed by the website? Any help will be appreciated. Thanks.
Testing the connection with firebase the result in the monitor is:
snip
…..192.168.xx.xx
Token info: type = id token (GITKit token), status = on request
Token info: type = id token (GITKit token), status = error
Token error: code: 400, message: INVALID_PASSWORD
Token info: type = id token (GITKit token), status = error
Token error: code: 400, message: bad request
Getting User UID
…………………………………….
snip end
The “Getting User UID lasts forever.
What can be the cause of this?
Greetings,
René.
Hi.
On your error statement, you have the following:
Token error: code: 400, message: INVALID_PASSWORD
So, double-check your password and the other configuration settings.
Regards,
Sara
Hi,
Thank you Sara.
Resetting the password did the trick.
Regards,
René.
Great!
Hi Sara,
I used Firebase Arduino Client Library for ESP8266 and ESP32 v,2.3.7 as suggested, but I can not compile the sketch for ESP8266, only for ESP32.
Any suggestion.thanks
Renzo
Check if you need to update your ESP8266 boards version.
In your Arduino IDE, go to Tools > Board > Boards Manager, search for ESP8266 and check if there are any updates.
Regards,
Sara
Thank you Sara,
just to make sure PC and code is uptodate and running I added just a single line of code:
Serial.printf(“*** temp %4.1f°C hum %2.0f%% pres %4.0f hPa\n”, bme.readTemperature(), bme.readHumidity(), bme.readPressure()/100.0F);
As you can see from the output:
Token info: type = id token (GITKit token), status = nrequest
Token info: type = id token GITKit token), status = ready
Getting User UID
User UID: D9sViJpqCHRyBHgVEPtpaGwOq8H3
time: 1674822801 <===== epoch is exact
*** temp 19.1°C hum 34% pres 969 hPa <===== values are ok!
Set json… send request failed <===========
All output is ok, only the json.set(…….) commands fails with “send request failed”
However the reported User UID:D9sViJpqCHRyBHgVEPtpaGwOq8H3
is different from the one I got while setup the database
user-ID D9sViJpqCHRyBHgVEPtpaGwOq8H
Here the trailing “3” is missing
Thank you for taking time to help me
Joshen
Hi Sara,
thank you for this great and comprehensive tutorial. Following all the steps I ended up with this messages:
Token info: type = id token (GITKit token), status = on request
Token info: type = id token (GITKit token), status = ready
Getting User UID
User UID: D9sV*****GwOq8H3
time: 1674810307
*** temp 20.1°C hum 33% pres 969 hPa <= introduced by me
Set json… send request failed
time: 1674810316
*** temp 20.1°C hum 33% pres 969 hPa
Set json… send request failed
Maybe you have a hint what is wrong in my settings/code.
Thank you
Joschen
Hi.
What lines of code did you change?
Regards,
Sara
Hi, is there a way to read data that has been sent to another esp32? (as data reader)
or are there any tutorial on how to do that in this website?
Thank you.
Hi Sara,
im working with project to update data of mq135 from esp8266 to realtime database, so i connect A0 of mq135 to A0 of esp8266wifi. The only thing i couldn’t understand is i can find where you define gate D0, D1 as input in your code because i want to change it to A0. So please help me, thank you.
Thank you
Minh
Hi.
I’m sorry, but I didn’t understand your question.
If you have doubts about the ESP8266 pinout, you can take a look at this tutorial: https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/
Regards,
Sara
Hello Sara,
I am trying to understand how you are storing the data.
If the sensor has a float value for temperature, humidity and pressure, why does the JSON.SET command use String (bme.readTemperature) instead of storing the float values in the database?
When I click on the data in the database, it shows ABC which I am thinking is storing the data as text. If I go to use the data later – read it, do something with it, will I need to convert from string back to float?
Thank you
Is there a way to just update everytime and not create a new entry everytime?I want to use the data in an android aplication and just need it to update the values from sensors each time?
Everything works great but what if I have one user with different esp modules posting different sensor data and another user that also hase more than one esp posting data.How do I add a ID for the esp so that each user will only be able to read the data that was stored by his different ESPs