lightbulb A. Introduction & Core Concept
Welcome! If you are new to microcontrollers, you're in the right place. Dynamic IoT works completely offline by leveraging the Wi-Fi chip built into your board.
How it works: The board creates its own local Wi-Fi network (Access Point Mode, usually at 192.168.4.1) and listens for simple HTTP requests (like visiting a website: http://192.168.4.1/open). When you tap a button in the Dynamic IoT app, it simply sends this request behind the scenes. No cloud servers, no internet connection required!
check_circle Prerequisites
1. An ESP32 or NodeMCU (ESP8266) board + Data cable.
2. Arduino IDE installed on your PC.
3. ESP32 / ESP8266 Board Package installed in Arduino IDE.
build B. Step 1: Setting Up Arduino IDE
Before writing code, Arduino needs to know how to talk to your board.
- Open Arduino IDE. Go to File > Preferences.
- In the "Additional Boards Manager URLs" field, paste this URL:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json - Go to Tools > Board > Boards Manager...
- Search for esp32 or esp8266 and install the latest version.
- Connect your board via USB. Go to Tools > Board and select your exact board model.
- Go to Tools > Port and select the COM port your board is connected to.
code C. Step 2: Code Templates
Copy and paste the appropriate code for your microcontroller into the Arduino IDE, then click the Upload button.
ESP32 Template
#include <WiFi.h>
#include <WebServer.h>
const char* ssid = "ESP32_Dynamic_IoT";
const char* password = "12345678";
WebServer server(80);
const int ledPin = 2; // Onboard LED
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
// Start Access Point
WiFi.softAP(ssid, password);
Serial.println("Access Point Started.");
Serial.print("IP Address: ");
Serial.println(WiFi.softAPIP());
// Define Endpoints
server.on("/open", []() {
digitalWrite(ledPin, HIGH);
server.send(200, "text/plain", "Opened");
});
server.on("/close", []() {
digitalWrite(ledPin, LOW);
server.send(200, "text/plain", "Closed");
});
server.on("/temperature", []() {
server.send(200, "text/plain", "24.5"); // Simulated Data
});
server.on("/status", []() {
String state = digitalRead(ledPin) ? "ON" : "OFF";
server.send(200, "text/plain", state);
});
server.begin();
}
void loop() {
server.handleClient();
}
NodeMCU (ESP8266) Template
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char* ssid = "ESP32_Dynamic_IoT";
const char* password = "12345678";
ESP8266WebServer server(80);
const int ledPin = 2; // Onboard LED (Note: active LOW on some NodeMCU)
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
// Start Access Point
WiFi.softAP(ssid, password);
Serial.println("Access Point Started.");
Serial.print("IP Address: ");
Serial.println(WiFi.softAPIP());
// Define Endpoints
server.on("/open", []() {
digitalWrite(ledPin, LOW); // Turning LED on
server.send(200, "text/plain", "Opened");
});
server.on("/close", []() {
digitalWrite(ledPin, HIGH); // Turning LED off
server.send(200, "text/plain", "Closed");
});
server.on("/temperature", []() {
server.send(200, "text/plain", "24.5"); // Simulated Data
});
server.begin();
}
void loop() {
server.handleClient();
}
menu_book D. Step 3: Understanding the Code
WiFi.softAP(ssid, password): This forces your microcontroller to broadcast a Wi-Fi network that your phone can connect to directly.server.on("/endpoint", ...): This maps directly to the "Endpoint" fields in the Dynamic IoT app. When the app makes a request to/open, this block of code executes to toggle your hardware pins.server.send(200, "text/plain", "OK"): The200means "Success". This tells the mobile app that the action was performed without error.
bug_report E. Step 4: Testing Before Using the App
You can test if the board is working perfectly using just your web browser!
- Open your laptop or phone's Wi-Fi settings.
- Connect to the new network called ESP32_Dynamic_IoT (Password:
12345678). - Open a web browser (Chrome, Safari, etc.) and type:
http://192.168.4.1/open. - If the page loads displaying "Opened" and your board's LED turns on, you have successfully set up your hardware!
dashboard_customize F. Step 5: Connecting to Dynamic IoT
Now that your hardware works, it's time to build a beautiful UI for it.
- Go to the Dynamic IoT Dashboard.
- Create a new project. Enter the SSID
ESP32_Dynamic_IoT, Password12345678, and Base URLhttp://192.168.4.1. - Add a Button component. Set its endpoint to
/open. - Save the layout! The Dynamic IoT mobile app will automatically fetch this layout and give you instant local control.