IoT/ESP32 B.Tech/Diploma Intermediate

Firebase: Control ESP32 GPIOs from Anywhere

Control the ESP32 GPIOs from anywhere using Firebase. Create nodes on the Firebase Realtime Database to save the current GPIO states. Whenever there's a change in the database nodes, the ESP32 updates its GPIOs accordingly.

  • 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 control the ESP32 GPIOs from anywhere using Firebase. We’ll create nodes on the Firebase Realtime Database to save the current GPIO states. Whenever there’s a change in the database nodes, the ESP32 updates its GPIOs accordingly. You can change the GPIOs states by writing on the database yourself, or you can create a web app to do that (
check this tutorial
).
Updated May 8, 2026
PART 2:
Control ESP32/ESP8266 GPIOs from Anywhere (Firebase Web App)
We have a similar tutorial for the ESP8266 board:
Firebase: Control ESP8266 NodeMCU GPIOs from Anywhere
Other Firebase Tutorials with the ESP32/ESP8266 that you might be interested in:
ESP32: Getting Started with Firebase (Realtime Database)
ESP32 with Firebase – Creating a Web App
ESP32 Firebase Authentication (Email and Password)
ESP32 Firebase: Send BME280 Sensor Readings to the Realtime Database
ESP32: Firebase Web App to Display Sensor Readings (with Authentication)
ESP32 Data Logging to Firebase Realtime Database
ESP32: Firebase Data Logging Web App (Gauges, Charts, and Table)
ESP32-CAM Save Picture in Firebase Storage
ESP32-CAM: Display Pictures in Firebase Web App
What is Firebase?
Firebase is Google’s mobile application development platform that helps you build, improve, and grow your app. Firebase provides
free
services like
hosting
authentication
, and
realtime database
that allow you to build a fully-featured web app to control and monitor the ESP32 and ESP8266 boards that would be much more difficult and laborious to build and set up on your own.
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 to be able to access the database (that user must be added to the Firebase authentication methods);
The database is protected using database rules. We’ll add the following rule: only authenticated users can access the database;
The database has several nodes that save the ESP32 GPIO states. As an example, we’ll control three GPIOs (12, 13, and 14). You can add or remove nodes to control more or fewer GPIOs.
The ESP32 will listen for changes on the GPIOs database nodes. Whenever there’s a change, it will update the GPIO states accordingly.
You can change the GPIO states manually on the database using the Firebase console, or you can create a web page (accessible from anywhere) with buttons to control the GPIOs and show the current GPIO states (
check PART 2
).
These are the main steps to complete this project:
Create a Firebase Project
Set Authentication Methods
Get Project API Key
Set up the Realtime Database
Set up Database Security Rules
Organizing your Database Nodes
ESP32: Listening for Database Changes (control GPIOs)
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
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 ESP32 or 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.
Copy the User UID because you’ll need it later.
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.
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 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
, and add the following rules.
{
\"rules\": {
\".read\": \"auth.uid === '
REPLACE_WITH_YOUR_USER_UID
'\",
\".write\": \"auth.uid === '
REPLACE_WITH_YOUR_USER_UID
'\"
}
}
Insert the UID of the user you created previously. Then, click
Publish
These database rules determine that:
Only the user with that specific UID can read and write to the database (change the GPIO states).
Add More Users
To add more users, you can simply go to the
Authentication
tab and click
Add user
. Add an email and password for the new user, and finally click on
Add user
to create the user.
Copy the user UID of that new user and add it to the database rules, as follows:
{
\"rules\": {
\".read\": \"auth.uid === 'REPLACE_WITH_YOUR_USER_UID' || auth.uid === 'REPLACE_WITH_USER_UID2'\",
\".write\": \"auth.uid === 'REPLACE_WITH_YOUR_USER_UID' || auth.uid === 'REPLACE_WITH_USER_UID2'\"
}
}
For exam

Technologies used

ESP32ESP32-CAMESP8266ArduinoFirebaseBLEBME280Arduino IDE

Hardware components

  • ESP32
  • ESP32-CAM
  • 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.