FireEsp is a lightweight C++ library that simplifies the integration of Firebase services into your Arduino projects. It provides classes to interact with Firebase Authentication, Realtime Database, and Server Configuration. This library is designed for ease of use and aims to make Firebase integration seamless for IoT and embedded projects using Arduino-compatible boards.
- Firebase Authentication: Sign up, sign in, reset passwords, verify email addresses, delete users, and refresh ID tokens.
- Firebase Realtime Database: Perform basic CRUD operations (create, read, update, delete) on Firebase's Realtime Database.
- Server Configuration: Set and manage Firebase project details such as API key, auth domain, and database URL.
- HTTP Requests: Send HTTP requests to Firebase's REST API to perform authentication and database operations.
- Debugging Support: Easily switch between production and debugging modes with a configurable debug level.
- Token Management: Full support for refresh tokens and ID token renewal.
- Arduino IDE: To compile and upload code to your Arduino or compatible board.
- Firebase Project: You need a Firebase project with Authentication and Realtime Database enabled.
- Arduino-Compatible Board: Supports boards like ESP8266, ESP32, etc.
git clone https://github.com/Init-io/FireEsp.git
- Open the Arduino IDE.
- Go to Sketch > Include Library > Add .ZIP Library....
- Select the
FireESP
folder.
FbServer server("YOUR_API_KEY", "YOUR_AUTH_DOMAIN", "YOUR_DATABASE_URL");
server.initialize();
FbAuthentication auth(server);
bool success = auth.signUp("user@example.com", "password123");
bool success = auth.signIn("user@example.com", "password123");
bool success = auth.refreshIdToken(auth.getRefreshToken());
String idToken = auth.getIdToken();
String refreshToken = auth.getRefreshToken();
bool success = auth.resetPassword("user@example.com");
bool success = auth.verifyEmail(auth.getIdToken());
bool verified = auth.checkEmailVerified(auth.getIdToken());
bool success = auth.deleteUser(auth.getIdToken());
FbDatabase database(server);
bool success = database.put("/path/to/data", "key", "value", auth.getIdToken());
bool success = database.put("/path/to/data", "key", 123, auth.getIdToken());
bool success = database.putJson("/path/to/data", "{\"name\":\"John\",\"age\":25}", auth.getIdToken());
bool success = database.update("/path/to/data", "key", "new_value", auth.getIdToken());
String value = database.get("/path/to/data", auth.getIdToken());
String json = database.getJson("/path/to/data", auth.getIdToken());
bool success = database.remove("/path/to/data", auth.getIdToken());
Enable or disable debugging globally.
#define DEBUG 1 // 1 = Debug Mode, 0 = Production Mode
#include <FireEsp.h>
- Debug Mode: Prints HTTP requests, responses, and errors.
- Production Mode: No sensitive data is printed.
#define DEBUG 1
#include <FireEsp.h>
FbServer server("YOUR_API_KEY", "YOUR_AUTH_DOMAIN", "YOUR_DATABASE_URL");
FbAuthentication auth(server);
FbDatabase database(server);
void setup() {
Serial.begin(115200);
server.initialize();
if (auth.signIn("user@example.com", "password123")) {
Serial.println("User signed in!");
// Save Data
database.put("/users/user1", "name", "John Doe", auth.getIdToken());
// Refresh Token Example
if (auth.refreshIdToken(auth.getRefreshToken())) {
Serial.println("Token refreshed successfully!");
}
}
}
void loop() {
// Your code here
}
- WiFi Instability: Unstable networks may cause requests to fail intermittently.
- Firebase Delays: Occasionally, Firebase may delay response, especially during refresh or sign-in.
This project is licensed under the MIT License. See the LICENSE file for details.
We welcome contributions! Please:
- Fork the repo
- Create a feature branch
- Submit a pull request
Follow coding style and document your changes properly.
- GitHub: FireEsp Repository
- Email: developers.init.io@gmail.com