Typical IoT data path
Common roles include node, gateway, message broker, server and client.
Connect embedded devices to networks. Understand wireless links, network roles, data protocols and security, then build a local sensor dashboard with an ESP32.
An Internet of Things system connects physical devices that measure, report or act on information. A typical node combines sensors, a microcontroller, communication hardware, firmware and a power source. Data may travel to a local computer, gateway or remote service.
Common roles include node, gateway, message broker, server and client.
Connectivity alone does not make a product useful. A connected system must also handle missing data, stale readings, power loss and unauthorised commands.
Wireless technologies trade range, data rate, power use, cost, infrastructure and complexity differently. No single radio is best for every project.
Connects devices to local IP networks and often the internet. Useful for dashboards, updates and moderate-to-high data rates. Usually consumes more energy than low-power sensor links.
Classic supports continuous links and serial-style modules. Bluetooth Low Energy is designed for lower average power and short bursts, such as nearby phone configuration or sensor readings.
Low-power networking for distributed sensor and home-automation nodes. Mesh routing can extend coverage but introduces ecosystem, coordinator or border-router considerations.
LoRa supports long-range, low-data-rate telemetry; LoRaWAN adds a network architecture. Cellular offers wide-area connectivity where coverage and a service plan exist, with energy and recurring-cost trade-offs.
| Technology | Typical role | Important trade-off |
|---|---|---|
| Wi-Fi | Local IP, dashboards, updates | Power and access-point dependence |
| BLE | Nearby phone / sensor links | Range and data model |
| Zigbee / Thread | Low-power distributed nodes | Network ecosystem |
| LoRaWAN | Small messages over long distances | Low throughput and gateway |
| Cellular | Wide-area remote assets | Coverage, energy and subscription |
Qualitative comparisons only. Actual performance depends on radio, antenna, region, interference and site conditions.
An ESP32 can serve a dashboard reachable only by devices on the same Wi-Fi network. This is useful for a workshop and does not require publishing the device to the public internet.
Remote access requires additional routing, firewall, service and authentication decisions. A private local IP address is not automatically reachable from outside.
A Wi-Fi connection does not prove internet availability. DNS, routing or a remote server may still be unavailable.
A client requests a resource and a server responds with a status and data. HTTP is common for web dashboards and REST APIs.
Devices publish messages to topics on a broker. Clients subscribe to topics and receive matching messages. Publishers and subscribers do not need to know each other.
Maintains a two-way connection so server and client can exchange updates without a new HTTP request for every message. Useful for live dashboards.
JSON is readable and easy to debug. Compact binary formats can reduce bandwidth. Include units, timestamps, device identity and data-quality information where useful.
Telemetry reports what a device measures. A command asks it to change something. Authenticate command senders, validate values, enforce limits, acknowledge outcomes and log important actions.
Change the simulated sensor value and reporting interval. The model creates a JSON message and estimates payload data rate. It is not a Wi-Fi throughput or battery-life prediction.
{
"device": "node-01",
"sensor": "demo",
"value": 42,
"unit": "%",
"sequence": 1
}Counts this JSON payload only. Excludes Wi-Fi, TCP/IP, encryption, retries and acknowledgements.
The ESP32 reads a potentiometer and serves a small web page over local Wi-Fi. A phone or laptop on the same network opens the ESP32's local IP address and sees live readings. The ESP32 is both sensor controller and HTTP server.
ESP32 variants differ. Confirm the exact pinout and ADC-capable pins for your board. GPIO34 is input-only on the original ESP32 family and may not exist or map identically on other variants. Keep inputs within the board's specified voltage range.
Install ESP32 board support, select the correct board and port, enter your own Wi-Fi credentials locally, then upload. Never publish real credentials in a public repository.
#include <WiFi.h>
#include <WebServer.h>
// Keep real credentials private and out of public source control.
const char* WIFI_SSID = "YOUR_WIFI_NAME";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";
const int SENSOR_PIN = 34; // Verify for your exact board.
WebServer server(80);
const char PAGE[] PROGMEM = R"HTML(
<!doctype html><html><head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>ESP32 Sensor</title></head><body>
<h1>ESP32 Local Sensor</h1>
<p>ADC: <strong id="adc">--</strong></p>
<p>Voltage estimate: <strong id="volts">--</strong> V</p>
<script>
async function updateReading() {
try {
const response = await fetch('/api/reading', {cache:'no-store'});
if (!response.ok) throw new Error('HTTP ' + response.status);
const data = await response.json();
document.getElementById('adc').textContent = data.adc;
document.getElementById('volts').textContent = data.voltage.toFixed(2);
} catch (error) {
document.getElementById('adc').textContent = 'Connection lost';
}
}
updateReading();
setInterval(updateReading, 1000);
</script></body></html>
)HTML";
void handleRoot() { server.send_P(200, "text/html", PAGE); }
void handleReading() {
int raw = analogRead(SENSOR_PIN);
// Nominal scale only; not a calibrated measurement.
float voltage = (raw / 4095.0f) * 3.3f;
String json = "{\"adc\":" + String(raw) +
",\"voltage\":" + String(voltage, 3) + "}";
server.send(200, "application/json", json);
}
void setup() {
Serial.begin(115200);
analogReadResolution(12);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting");
unsigned long started = millis();
while (WiFi.status() != WL_CONNECTED &&
millis() - started < 20000UL) {
delay(300);
Serial.print(".");
}
if (WiFi.status() != WL_CONNECTED) {
Serial.println("\nWi-Fi connection failed. Check credentials and network.");
return;
}
Serial.println("\nConnected. Open this address on the same network:");
Serial.println(WiFi.localIP());
server.on("/", HTTP_GET, handleRoot);
server.on("/api/reading", HTTP_GET, handleReading);
server.begin();
}
void loop() {
if (WiFi.status() == WL_CONNECTED) server.handleClient();
}Threat modelling, secure provisioning, logging, maintenance and recovery are engineering requirements, not finishing touches.
Explore these open lessons at your own pace. For personalised explanations, project-specific troubleshooting, guided practical training or masterclasses, EazyLife offers paid support tailored to your learning goals.
Free or sponsored lesson referrals may be available through active programmes; they are not guaranteed.