Overview
The Firebase RTDB module enables ESP32 devices to interact with Firebase Realtime Database. It supports authentication, real-time data synchronization, and structured data storage.Basic Firebase Operations
This example demonstrates connecting to Firebase and performing basic read/write operations.Complete Basic Example
Sensor Data Logger
A complete example for logging sensor data to Firebase with timestamps.Setup Time Synchronization
Collect and Upload Sensor Data
Complete Logger Example
Database Operations
Set (Write/Update)
Push (Create with auto-generated key)
Get (Read)
Remove (Delete)
Exists (Check)
Data Structure Best Practices
Flat Structure (Recommended)
Avoid Deep Nesting
Don’t create structures more than 3-4 levels deep for better performance.Error Handling
Key Methods
| Method | Description |
|---|---|
begin(client, url, key, email, pass) | Initialize Firebase |
ready() | Check if ready for operations |
loop() | Maintain connection (call in loop) |
set(path, value) | Write/update data |
push(path, value) | Create with auto key |
getString(path) | Read string value |
getInt(path) | Read integer value |
getBool(path) | Read boolean value |
getFloat(path) | Read float value |
exists(path) | Check if path exists |
remove(path) | Delete data |
getError() | Get last error message |
Hardware Requirements
- ESP32 (required for WiFiClientSecure)
- WiFi connection
- Firebase project with Realtime Database
Firebase Setup
- Create Firebase project at console.firebase.google.com
- Enable Email/Password authentication
- Create Realtime Database
- Get API key from Project Settings
- Note your database URL
Source Files
Example files located at:- Basic:
example/modules/wifi/firebase/firebasev2/EXAMPLE-firebase-rtdbv2/basic-operations.ino - Logger:
example/modules/wifi/firebase/firebasev2/EXAMPLE-firebase-rtdbv2/sensor-data-logger.ino