Showing posts with label ESP32. Show all posts
Showing posts with label ESP32. Show all posts

Wednesday, 13 August 2025

Controlling ESP32 GPIO using Firebase

🚀 Ever tried connecting an embedded application to a cloud database?

If not, here's a fun weekend project: Connect your ESP32/ESP8266 to Google Firebase and explore the power of real-time IoT!

I recently worked on a project where I controlled the GPIOs of an ESP32 by reading data directly from a Firebase database using Arduino Firebase client—and it worked like a charm! 🔌✨

With this setup, you can:
✅ Update Firebase from your ESP32 (send sensor data, etc.)
✅ Control your ESP32 remotely by updating Firebase via a mobile or web app
✅ Build an IoT dashboard that reflects real-time data updates

Whether you're building smart home projects or learning about cloud-connected devices, Firebase + ESP32 is a powerful combo.

💡 It’s a great hobby project to understand how embedded systems and cloud platforms can work together.

Give it a try—and let me know if you’d like the link to the tutorial I followed!

Link to the tutorial is as below

https://bokfive.com/getting-started-with-esp32-and-firebase-realtime-database/?srsltid=AfmBOoqpRdJlXAHtQO-PQKYZjYaUst6EPDzp-l1Iz2KjHIjtEd0mYUh0 

#IoT #ESP32 #Firebase #EmbeddedSystems #CloudComputing #Makers #TechHobby #DIYProjects #LinkedInTech


Saturday, 12 April 2025

Ethernet based Webserver using ESP32 and W5500 modules

Have ever wondered how your routers get configured using a IP address on a web browser? The answer is simple, there is an embedded web server hosted on the router and when you connect to the computer using an Ethernet connection, the web server is accessed on the router using the IP address provided by the manufacturers for further configuration process.

I wanted to replicate this technology for evaluation purposes and using an IOT gateway development board, I could configure the ESP32 as Ethernet based web server attached to W5500 Ethernet module. I used a Arduino IDE to upload a sketch provided by a git hub repository maintained in the link https://github.com/Networking-for-Arduino/EthernetESP32/blob/master/examples/HelloServer/HelloServer.ino by https://forum.arduino.cc/u/juraj/summary

The code was uploaded after successful compilation but when connecting Ethernet module to my linux system, my linux was not allocating IP address to the Ethernet web server, a prerequisite for accessing the webserver through the web browser. There was some configuration problem in dhcp server installed in the linux system.

After consulting my friends working in the networking domain, I was suggested to use router which has an inbuilt dhcp server to allocate IP address to dhcp clients. As per suggestion from one of my friend I purchased TP link archer C6 router and connected IOT gateway to the same. Router allocated IP address to the Ethernet web server at ease and hence made web server accessible from the web browser of linux sytsem which was also connected to the router establishing a two terminal LAN.

Using this methodology you can connect your IOT gateway to local LAN for accessing the Sensor information dash board designed into Web server on getting a alert for a event notification to your mobile device by the gateway using cellular technology.

Monday, 3 March 2025

ESP32 GPIO control using Webserver technique

I was on my way to understand the operation of the IOT gateways which bridge the gap between IOT sensors and cloud which led me to buy a IOT development board from Vajruino.

The IOT gateway had a ESP32 wifi module, SIMCOM LTE module with a ethernet port. But one drawback about the gateway was that it was necessary to code the ESP32 in order to configure the IOT gateway. But nowadays IOT gateways are smart enough with a remote configuration option through web browser.

This made me to understand the basic concept of remote access of IOT gateway through web browser. A simple google search led me to an experiment wherein it is possible to control the ESP32 GPIO using webserver technique from a web browser over a local network.

It basically requires a node mcu esp32 board available over any robotic e-commerce website. A little bit of coding on the Arduino IDE can help you to control the onboard GPIO connected LED from a mobile web browser connected on a local network.

I am appending the Arduino code as below 

#include <WiFi.h>

#include <ESPAsyncWebServer.h>


// WiFi credentials

#define WIFI_SSID "Redmi"

#define WIFI_PASSWORD "19521952"


// LED pin

#define LED_PIN 2


// Web server object

AsyncWebServer server(80);


// LED state

int LED_state = LOW;


// Function to generate the HTML and CSS code for the web page

String getHTML() {

String html = "<!DOCTYPE HTML>";

html += "<html>";

html += "<head>";

html += "<style>";

html += "body {background-color: #F0F0F0; font-family: Arial, Helvetica, sans-serif;}";

html += "h1 {color: #333333; text-align: center;}";

html += "button {width: 150px; height: 50px; font-size: 20px; margin: 10px;}";

html += "</style>";

html += "</head>";

html += "<body>";

html += "<h1>ESP32 Web Server</h1>";

html += "<p>LED state: <span style='color: red;'>";

if (LED_state == LOW) html += "OFF";

else html += "ON";

html += "</span></p>";

html += "<button onclick=\"window.location.href='/led/on'\">Turn ON</button>";

html += "<button onclick=\"window.location.href='/led/off'\">Turn OFF</button>";

html += "</body>";

html += "</html>";

return html;

}


// Function to connect to WiFi network

void connectWiFi() {

Serial.print("Connecting to WiFi...");

WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

while (WiFi.status() != WL_CONNECTED) {

delay(500);

Serial.print(".");

}

Serial.println();

Serial.println("WiFi connected");

Serial.println("IP address: ");

Serial.println(WiFi.localIP());

}


// Function to handle HTTP requests

void handleRequest(AsyncWebServerRequest *request) {

// Get the request path

String path = request->url();

// Check if the request is to turn the LED on

if (path == "/led/on") {

// Set the LED pin to HIGH

digitalWrite(LED_PIN, HIGH);

// Update the LED state

LED_state = HIGH;

// Send a confirmation message

request->send(200, "text/plain", "LED turned on");

}

// Check if the request is to turn the LED off

else if (path == "/led/off") {

// Set the LED pin to LOW

digitalWrite(LED_PIN, LOW);

// Update the LED state

LED_state = LOW;

// Send a confirmation message

request->send(200, "text/plain", "LED turned off");

}

// Otherwise, send the web page

else {

// Get the HTML and CSS code

String html = getHTML();

// Send the web page

request->send(200, "text/html", html);

}

}


void setup() {

// Initialize the serial monitor

Serial.begin(115200);


// Initialize the LED pin

pinMode(LED_PIN, OUTPUT);

digitalWrite(LED_PIN, LED_state);


// Connect to WiFi network

connectWiFi();


// Start the web server

server.onNotFound(handleRequest);

server.begin();

}


void loop() {

// Nothing to do here

}


Source: https://www.instructables.com/Led-Control-With-ESP-Webserver/