IoT/ESP32 B.Tech/Diploma Intermediate

ESP32 Data Logging to Firebase Realtime Database

Learn how to log data with the ESP32 to the Firebase Realtime Database with timestamps (data logging) so that you have a record of your data history temperature, humidity, and pressure from a BME280 sensor

  • Suitable forB.Tech/Diploma IoT/ESP32 students
  • Build time1-2 weeks
  • LevelIntermediate
  • Available atAjvika Labs, Kakinada

About this project

In this guide, you’ll learn how to log data with the ESP32 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 May 8, 2026
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:
ESP32: Getting Started with Firebase (Realtime Database)
ESP8266 NodeMCU: Getting Started with Firebase (Realtime Database)
ESP32 with Firebase – Creating a Web App
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 ESP32 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 ESP32 gets temperatrure, humidity and pressure from the BME280 sensor.
It gets epoch time right after gettings the readings (timestamp).
The ESP32 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
ESP32 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 from 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 ESP32 board using the Arduino core. So, make sure you have the ESP32 add-on installed in your Arduino IDE:
Installing the ESP32 Board in Arduino IDE (Windows, Mac OS X, Linux)
If you want to program the ESP32/ESP8266 boards using VS Code with the pioarduino or PlatformIO extensions, follow these tutorials instead:
VS Code and pioarduino IDE: Programming the ESP32 (Windows, Mac OS X, Linux)
Getting Started with VS Code and PlatformIO IDE for ESP32 and ESP8266

Create a 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 ESP32). 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) Creating a Web App for Your Project (and API key)
To interface with your Firebase project using the ESP32, you need to get your project API key. To get an API key for your project, you need to create a web app first. Follow the next steps.
On the left sidebar, click on
Settings
Scroll down on that page to the
Your apps
section. Then, click on the web icon
</>
to create and add a web app to your Firebase project.
Give your app a name. Then, check the box next to
√ Also set up Firebase Hosting for this App
. Click
Register app
Then, in the
firebaseConfig
object, you can find your API key. Save it because you’ll need it later.
After this, you can also access the
firebaseConfig
object if you go to your Project settings in your Firebase console and scroll down to the
Your apps
section.
Click Next on the preceding steps, and finally on
Continue to console
4) Set up the Realtime Database
Now, let’s create a realtime database and set up database rules for our project.

On the left sidebar, click on
Realtime Database
and then click on
Create Database

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

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

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 ESP32/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 rules, it can read and write data to the database under the node
UsersData/RjO3taAzMMXBB2Xmir2LQ
6) ESP32 Datalogging (Firebase Realtime Database)
In this section, we’ll program the ESP32 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 epoc

Technologies used

ESP32ESP8266ArduinoFirebaseBLEBME280AndroidArduino IDE

Hardware components

  • ESP32
  • ESP8266
  • Arduino
  • BME280

Software & tools

  • Arduino IDE
  • VS Code
  • PlatformIO
  • Firebase
  • PlatformIO

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.