Connect your ESP32 Firebase with this beginner-friendly guide. Learn realtime database, authentication, data logging, and cloud control step by step.
If you’ve ever wanted to connect your ESP32 to the cloud without dealing with complicated servers, Firebase is one of the easiest places to start. In this beginner-friendly guide, we’ll walk through everything you need to know about esp32 firebase, including setup, authentication, real-time data, storage, data logging, app integration, and common errors like esp32 firebase permission denied.
Think of this as learning over coffee with a smart friend. No jargon. No corporate buzzwords. Just real, simple talk to help you actually understand how ESP32 and Firebase work together.
Let’s start from the basics.
What Is Firebase and Why Use It With ESP32?
Firebase is a cloud platform from Google that makes IoT projects easier. Instead of creating your own server or hosting APIs, Firebase gives you:
- Real-time database
- Authentication
- Cloud Storage
- Web apps
- Hosting
- Analytics
- Easy APIs
You don’t need to be an expert to connect ESP32 + Firebase. That’s why so many beginners search for esp32 firebase tutorial, and why the community has tons of examples on the esp32 firebase github repositories.
Why ESP32 works perfectly with Firebase
- Built-in WiFi
- Fast dual-core processor
- Low-cost
- Perfect for IoT systems
- Supports libraries like the firebase esp32 by Mobizt
If your goal is to build smart home systems, sensor dashboards, IoT apps, or remote monitoring, esp32 firebase arduino is one of the best paths.
Setting Up Firebase for ESP32 (Step-by-Step)
Before writing esp32 firebase code, you need a Firebase project ready. Here’s the simplest flow:
Step 1: Go to Firebase Console
Create a new project from the Firebase website.
Step 2: Enable Firebase Realtime Database
Choose Realtime Database, then click Create Database, and set the mode to Test Mode if you’re a beginner.
This is the database that will store your ESP32 sensor values, logs, or app data.
Step 3: Get Database URL
It will look like:
https://your-project-name.firebaseio.com/
Step 4: Add Web App (We will use it later)
This will help if you want to build a firebase web app with the esp32 and esp8266.
Step 5: Generate API Keys or Service Credentials
You will need:
- API Key
- Database URL
- Project ID
- Authentication token (if using custom auth)
That’s all you need before moving to coding.
Installing ESP32 Firebase Library (The Mobizt Client)
The most popular library is the Firebase ESP32 Client by Mobizt, often called:
- firebase-esp32
- firebase-arduino
- firebase esp32 by mobizt
This library makes everything easy: reading, writing, file upload, authentication, and storage.
If you’re also exploring cloud-based IoT workflows, you can check out this ESP32 MQTT guide that covers practical publish–subscribe examples in a simple way: ESP32 MQTT
It fits perfectly when you want to combine Firebase with MQTT for scalable IoT projects..
How to Install:
- Open Arduino IDE
- Go to Sketch → Include Library → Manage Libraries
- Search:
“firebase esp32” - Install:
Firebase ESP32 Client by Mobizt
This library is well-documented, and you can find firebase esp32 documentation on GitHub.
First ESP32 Firebase Code
Let’s start with the simplest esp32 firebase examples: writing data.
#include <WiFi.h>
#include <FirebaseESP32.h>
#define WIFI_SSID "your_wifi"
#define WIFI_PASSWORD "your_pass"
#define API_KEY "your_api_key"
#define DATABASE_URL "your_database_url"
FirebaseData fbData;
void setup() {
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(300);
}
Serial.println("\nConnected.");
Firebase.begin(DATABASE_URL, API_KEY);
Firebase.setInt(fbData, "/test/value", 123);
}
void loop() {}
This makes your ESP32 push an integer to your Firebase realtime database.
This is the first small step before building any real esp32 firebase app.
ESP32 Firebase Realtime Database (Read and Write)
Once basic writing is working, you can expand:
Writing Data
- Temperature
- Humidity
- Status values
- Device ON/OFF
- Motion detection
Reading Data
- Control LEDs from Firebase
- Trigger buzzer
- Remote control from mobile app
- Change system settings
Example to read data:
if (Firebase.getInt(fbData, "/control/led")) {
int ledvalue = fbData.intData();
digitalWrite(2, ledvalue);
}
Now your Firebase becomes your remote dashboard.
ESP32 Firebase DHT11 Sensor Project
One of the most popular tutorials is esp32 firebase dht11.
Why? Because everyone loves to log temperature and humidity.
What You Need
- ESP32
- DHT11 (or DHT22)
- Firebase Realtime Database
The ESP32 reads sensor values and uploads them to Firebase every few seconds.
From Firebase, you can display it in a firebase esp32 web app, mobile app, or dashboard.
ESP32 Firebase Data Logging (Perfect for IoT Dashboards)
Once you start sending temperature, humidity, motion, or voltage, you naturally want to log data.
Firebase makes this simple.
Example path:
/logs/2025-11-23/time/value
You can log:
- Timestamp
- Sensor values
- Device status
- Errors
- Usage patterns
This helps you build real IoT systems.
ESP32 CAM: Sending Images to Firebase Storage
A big part of esp32 examples online includes ESP32 CAM + Firebase.
Two popular use cases are:
1. esp32 cam send image to firebase
You capture a picture and upload it as a base64 string.
2. esp32 cam save picture in firebase storage
You upload .jpg files directly into Firebase Cloud Storage.
This is perfect for:
- Security cameras
- Doorbell systems
- Motion alert cameras
- Wildlife monitoring
Firebase automatically creates secure URLs for your images.
ESP32 Firebase Authentication
If you want controlled access, Firebase Authentication lets you use:
- Email/password
- Custom token
- Anonymous login
- API token
This prevents unauthorized devices from writing to your database.
You will use:
Firebase.setAuthToken()
or custom JWT.
This is important when building real-world esp32 firebase app projects.
ESP32 Firebase Web App (Dashboard + Controls)
A esp32 firebase web app is simply a webpage connected to your Firebase database.
You can display:
- Live temperature
- Humidity
- Device logs
- Alerts
- Status
- Charts
And you can control:
- LEDs
- Relays
- Appliances
- Fan/AC
- Smart home devices
You can even integrate:
firebase web app with the esp32 and esp8266
using the same database.
ESP32 + Firebase + MIT App Inventor (Mobile App Control)
MIT App Inventor beginners love Firebase because it has built-in blocks for:
- Store value
- Get value
- Real-time updates
This is where esp32 firebase app inventor with esp32 firebase mit app inventor becomes very popular.
Your ESP32 listens for changes.
The app sends commands.
Everything updates instantly.
You can build:
- Smart home remote
- Light control
- Fan speed control
- Appliance automation
- Security dashboard
All without writing a single line of Android code.
ESP32 Firebase and App Development
When you make an esp32 firebase app, you have two major choices:
1. Web App
- Runs in browser
- Simple HTML/JS
- Hosted on Firebase
2. Mobile App
- MIT App Inventor
- Flutter
- React Native
- Android Studio
Every app can read/write to Firebase, and the ESP32 will sync instantly.
ESP32 Firebase GitHub Projects You Should Explore
Search for:
- esp32 firebase github
- esp32 con firebase
- esp32 com firebase
You will find projects like:
- Sensor logger
- Smart home apps
- Security cameras
- Realtime dashboards
- Access control
These examples help you master esp32 firebase client faster.
Common Error: ESP32 Firebase Permission Denied
One of the most frustrating issues beginners face is:
esp32 firebase permission denied
This happens when:
- Wrong database URL
- Wrong API key
- No read/write permission
- Wrong path
- Authentication disabled
Fix
Go to Rules:
{
"rules": {
".read": true,
".write": true
}
}
Or use an authentication token.
Once fixed, your ESP32 starts reading/writing instantly.
Firebase ESP32 Documentation (Why It Helps)
The official firebase esp32 documentation from Mobizt explains:
- API usage
- Reading/writing data
- Uploading files
- Using storage
- Using authentication
- Using streaming
- Using callbacks
Beginners learn faster when they refer to real documentation instead of random blogs.
Advanced ESP32 + Firebase Use Cases
Here are real-world applications you can build:
1. Home Automation Dashboard
Control lights, fans, AC using a Firebase web app.
2. Security Camera
Use ESP32 CAM to upload motion-triggered images.
3. Weather Station
Use DHT11 and log daily temperature.
4. Smart Agriculture
Soil moisture + pump control.
5. Industrial Monitoring
Machines send live data to Firebase.
6. GPS Tracking
Send location coordinates to Realtime Database.
ESP32 Firebase in Arduino IDE (Beginner Friendly Setup)
If you’re using firebase esp32 arduino ide, here’s how your workflow goes:
- Install ESP32 board package
- Install Firebase ESP32 library
- Configure WiFi
- Add API key
- Add database URL
- Write read/write commands
This is the simplest setup for beginners.
Full Project Example (Temperature Upload + LED Control)
This combines:
- esp32 firebase
- esp32 firebase realtime database
- esp32 firebase client
- esp32 firebase get data
- esp32 firebase data logging
Your ESP32 will:
- Upload temperature
- Upload humidity
- Read remote LED control
- Log values
This is the core of most IoT systems.
Troubleshooting ESP32 Firebase Issues
Here are common problems and fixes:
Problem: Permission Denied
Fix rules or auth token.
Problem: API Key Incorrect
Copy fresh key.
Problem: ESP32 Not Connecting
Check WiFi.
Problem: Data Not Updating
Check data path in Firebase.
Problem: esp32 firebase get data returning empty
Fix database child path.
Problem: Storage Upload Failing
Check Storage rules.
Firebase errors are easy once you understand the basics.
Final Thoughts: Why ESP32 Firebase Is the Best IoT Starting Point
If you’re new to IoT, esp32 firebase is the easiest path to building real cloud projects.
It gives you:
- Real-time updates
- Secure authentication
- Cloud storage
- Web apps
- Mobile apps
- Simple APIs
You can start with:
- esp32 firebase tutorial
- Look at esp32 firebase examples
- Use firebase esp32 documentation
- Explore esp32 firebase github
Whether you’re building smart homes, dashboards, or automation apps, Firebase and ESP32 make everything simple, fast .
Frequently Asked Questions : ESP32 & Firebase
Quick answers and practical steps for real projects.
1. What is ESP32 Firebase and why should I use it?
ESP32 Firebase refers to using the ESP32 microcontroller together with Google Firebase services (Realtime Database, Authentication, Cloud Storage, etc.). It’s ideal for beginners because Firebase removes the need to maintain a server: your ESP32 can read/write JSON data in real time, authenticate securely, and upload files such as images from an ESP32-CAM. Use it when you want quick cloud connectivity for sensors, dashboards, or control apps.
2. How do I set up a Firebase project for my ESP32?
Create a Firebase project at the Firebase Console, enable Realtime Database (or Firestore if you prefer), and note the Database URL and API key. In short:
- Create project → Project settings → Add web app (to get config if needed).
- Realtime Database → Create database → start in test mode while learning.
- Copy your
https://your-project.firebaseio.com/URL and API key for your esp32 firebase code.
After this you can use libraries such as the Firebase ESP32 client by Mobizt inside Arduino IDE to connect easily.
3. Which library should I use: firebase esp32 by Mobizt or something else?
For Arduino-style development the firebase esp32 client by Mobizt (search “firebase esp32” in Library Manager) is the most complete and actively used option. It supports realtime database read/write, streaming, storage uploads, and authentication. If you need an example-rich repo, check esp32 firebase github projects for concrete code snippets and project patterns.
4. How do I write and read values from the ESP32 Realtime Database?
Use the Firebase client’s set and get methods. Basic flow:
// pseudocode
Firebase.begin(databaseURL, apiKey);
Firebase.setInt(fbData, "/sensors/temperature", 27);
Firebase.getInt(fbData, "/control/led"); // read remote control value
Your ESP32 can push sensor values (DHT11, DHT22) and read control flags the web app or mobile app writes. Use structured paths (e.g. /devices/deviceId/metrics) for clean logging and easy queries.
5. I keep getting “permission denied” — how do I fix it?
esp32 firebase permission denied is common. Causes & fixes:
- Database rules: For testing set:
Then tighten to authenticated rules for production.{ "rules": { ".read": true, ".write": true } } - Wrong URL / API key: Double-check the Database URL and API key in your code.
- Using Storage: Storage has separate rules — allow authenticated uploads or public buckets temporarily while developing.
- Authentication mismatch: If rules require auth, make sure the ESP32 sends a valid token or uses authenticated sign-in.
6. Can I use Firebase Authentication with ESP32?
Yes. For simple projects you can use anonymous authentication or create a custom token. Typical flows:
- Enable the desired sign-in method in Firebase Console (Email/Password, Anonymous).
- If using email/password, create tokens on a secure server or use Firebase REST endpoints from a secure environment.
- Use the library’s auth methods or pass the service token (JWT) in your ESP32 code.
Authentication lets you secure read/write rules, which is critical for production access control.
7. How do I send images from ESP32-CAM to Firebase?
There are two common patterns:
- Upload to Firebase Storage: Capture a JPEG, create a multipart upload or upload base64 bytes using the Firebase Storage API. Storage will give you a downloadable URL.
- Save base64 in Realtime DB (not recommended): Convert image to base64 and write to DB — works for small images but can be slow and expensive. Prefer Cloud Storage for images.
Example flow: capture → compress → connect to WiFi → authenticate → upload to storage → store URL in Realtime Database for the web/mobile app to display.
8. How do I log sensor history (data logging) to Firebase?
Design a path like /logs/deviceId/YYYY-MM-DD/HH:MM:SS and push JSON entries:
{
"time": "2025-11-24T10:00:00Z",
"temp": 27.2,
"hum": 45
}
Use esp32 firebase data logging to keep rolling history. For heavy datasets consider exporting to BigQuery or using Firestore with queries, but for most hobby projects Realtime Database is fine.
9. Can I build a web dashboard (a firebase web app) that talks to ESP32?
Absolutely. A simple stack:
- Host an HTML/JS page (you can even use Firebase Hosting).
- Use Firebase Web SDK to listen to the same Realtime Database paths your ESP32 uses.
- Show charts, live values, and controls that write back to the DB (e.g.,
/control/led).
This makes a responsive esp32 firebase web app where changes show up in real time on both device and browser.
10. How do I connect MIT App Inventor to Firebase and control my ESP32?
MIT App Inventor has Firebase components that let your app read/write to Realtime Database. Typical flow:
- Configure Firebase URL and token in App Inventor blocks.
- App writes a command (e.g.,
/devices/deviceId/commands). - ESP32 listens to that path and executes commands (switch relay, toggle LED).
This approach is perfect for people who want a mobile app without native development—search for esp32 firebase mit app inventor examples for block code templates.
11. Where can I find reliable code examples and repositories?
Search GitHub for keywords like esp32 firebase, firebase esp32 arduino ide, or firebase esp32 by mobizt. Look for repos that:
- Have recent commits
- Include clear README with wiring and setup
- Use the library you plan to use (Mobizt’s client is popular)
Always test small examples (read/write) before copying large projects into your own codebase.
12. My ESP32 keeps disconnecting or timing out with Firebase — what should I check?
Possible causes and fixes:
- WiFi instability: strengthen signal or use a stable AP; use reconnection logic in code.
- Large payloads: uploading big images without chunking causes timeouts; use Storage with resumable uploads or reduce size.
- Streaming limits: if you use streaming, ensure you handle events and reconnect gracefully.
- Power issues: ESP32 brownout can disconnect WiFi — use proper power supply and decoupling caps.
13. Should I use Realtime Database or Firestore with ESP32?
For simple IoT telemetry and two-way control the Realtime Database is often easier and more real-time friendly. Firestore provides richer queries and structure but has different pricing and SDKs. If your project needs complex queries or heavy offline behavior on mobile, consider Firestore; otherwise Realtime Database keeps things simple for most esp32 firebase projects.
14. How can I reduce cost and bandwidth when using Firebase with ESP32?
Practical tips:
- Send only deltas or summaries instead of raw high-frequency data.
- Aggregate data on the device (e.g., average temperature per minute) and send summaries.
- Limit storage retention in the database; purge old logs or export them periodically.
- Compress or resize images before uploading from an ESP32-CAM.
15. Any quick starter checklist for a successful ESP32 + Firebase project?
Yes — a short checklist:
- Decide DB: Realtime Database vs Firestore.
- Create Firebase project and copy database URL & API key.
- Install firebase esp32 library (Mobizt) into Arduino IDE.
- Test WiFi connectivity and basic read/write to DB.
- Secure rules with Authentication before going public.
- Use Cloud Storage for images (ESP32-CAM).
- Implement reconnect & power stability checks on the ESP32.
Follow this and you’ll avoid most beginner pitfalls when building an esp32 firebase project.
Mr. Raj Kumar is a highly experienced Technical Content Engineer with 7 years of dedicated expertise in the intricate field of embedded systems. At Embedded Prep, Raj is at the forefront of creating and curating high-quality technical content designed to educate and empower aspiring and seasoned professionals in the embedded domain.
Throughout his career, Raj has honed a unique skill set that bridges the gap between deep technical understanding and effective communication. His work encompasses a wide range of educational materials, including in-depth tutorials, practical guides, course modules, and insightful articles focused on embedded hardware and software solutions. He possesses a strong grasp of embedded architectures, microcontrollers, real-time operating systems (RTOS), firmware development, and various communication protocols relevant to the embedded industry.
Raj is adept at collaborating closely with subject matter experts, engineers, and instructional designers to ensure the accuracy, completeness, and pedagogical effectiveness of the content. His meticulous attention to detail and commitment to clarity are instrumental in transforming complex embedded concepts into easily digestible and engaging learning experiences. At Embedded Prep, he plays a crucial role in building a robust knowledge base that helps learners master the complexities of embedded technologies.
