How to Start IoT
Your complete guide to building your first IoT project — from zero experience to a working smart device
What is IoT?
The Internet of Things (IoT) connects physical devices to the internet, allowing them to collect and share data. From smart thermostats to industrial sensors, IoT is transforming how we interact with technology.
How IoT Works
Every IoT system has four main components:
- Sensors — Collect data from the environment (temperature, motion, light)
- Connectivity — Send data via WiFi, Bluetooth, LoRa, or cellular networks
- Processing — Microcontrollers or cloud services analyze the data
- User Interface — Apps, dashboards, or automation rules act on the data
Why Start IoT in 2026?
- Affordable hardware — ESP32 boards cost under $5 with built-in WiFi and Bluetooth
- Mature ecosystem — Arduino IDE, PlatformIO, and thousands of libraries
- Real-world impact — Build smart home devices, environmental monitors, or industrial sensors
- Career opportunities — IoT skills are in high demand across industries
Choose Your Hardware
The ESP32 is the best microcontroller for IoT beginners. It is powerful, affordable, and has built-in WiFi and Bluetooth.
What You Need
ESP32 Development Board
Recommended: ESP32-DevKitC or ESP32-WROOM-32
- Dual-core 240MHz processor
- 520KB SRAM + 4MB Flash
- Built-in WiFi 802.11 b/g/n
- Bluetooth 4.2 + BLE
- 30+ GPIO pins
Essential Accessories
- Micro-USB or USB-C cable (for power and programming)
- Breadboard (830 tie points recommended)
- Jumper wires (male-to-male, male-to-female)
- DHT22 temperature and humidity sensor
- LEDs and 220-ohm resistors
Software Setup
- Download and install Arduino IDE or PlatformIO
- Install ESP32 board package (via Board Manager)
- Install USB drivers (CH340 or CP2102, depending on your board)
- Select ESP32 Dev Module and choose the correct COM port
Your First Program: Blink an LED
Start with the classic Hello World of embedded systems:
void setup() {
pinMode(2, OUTPUT); // Built-in LED on GPIO 2
}
void loop() {
digitalWrite(2, HIGH); // Turn LED on
delay(1000); // Wait 1 second
digitalWrite(2, LOW); // Turn LED off
delay(1000); // Wait 1 second
} Upload this code, and you should see the LED blink every second. Congratulations — you are now an embedded developer!
Understand Sensors
Sensors are the eyes and ears of your IoT device. They convert physical phenomena into electrical signals your microcontroller can read.
Common IoT Sensors
Temperature and Humidity
DHT22 / SHT30
- Measure: -40 to 80 C, 0-100% RH
- Interface: Digital (1-wire or I2C)
- Use cases: Weather stations, smart home, greenhouse
Ambient Light
BH1750
- Measure: 1-65535 lux
- Interface: I2C
- Use cases: Auto-dimming displays, smart lighting
Distance
HC-SR04
- Measure: 2-400 cm
- Interface: Digital (pulse width)
- Use cases: Obstacle detection, level measurement
Motion / Presence
RCWL-0516 / PIR
- Measure: Motion detection (microwave or infrared)
- Interface: Digital (HIGH/LOW)
- Use cases: Security systems, automatic lighting
Reading a Sensor: DHT22 Example
#include <DHT.h>
#define DHTPIN 4 // GPIO pin
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
dht.begin();
}
void loop() {
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
Serial.print("Temp: ");
Serial.print(temperature);
Serial.print(" C, Humidity: ");
Serial.print(humidity);
Serial.println("%");
delay(2000);
} Learn Communication Protocols
IoT devices need to communicate — with each other, with gateways, and with the cloud. Understanding protocols is key to building reliable systems.
Wireless Protocols Comparison
| Protocol | Range | Power | Data Rate | Best For |
|---|---|---|---|---|
| WiFi | 50-100m | High | Up to 600 Mbps | High-bandwidth, mains-powered devices |
| Bluetooth (BLE) | 10-50m | Very Low | 1-3 Mbps | Wearables, beacons, short-range control |
| Zigbee / Thread | 10-100m (mesh) | Low | 250 kbps | Smart home, mesh networks |
| LoRa | 2-15 km | Very Low | 0.3-50 kbps | Agriculture, environmental monitoring |
| NB-IoT / LTE-M | Cellular coverage | Low-Medium | Up to 1 Mbps | Remote assets, smart meters |
Application Layer: MQTT
MQTT (Message Queuing Telemetry Transport) is the most popular protocol for IoT communication. It is lightweight, efficient, and designed for unreliable networks.
How MQTT Works
- Publish/Subscribe model — Devices publish messages to topics, other devices subscribe to receive them
- Broker — A central server (like Mosquitto) routes messages between devices
- QoS levels — Choose delivery guarantees (at most once, at least once, exactly once)
Example: Publish Temperature Data
#include <PubSubClient.h>
#include <WiFi.h>
const char* mqtt_server = "192.168.1.100";
const char* topic = "home/livingroom/temperature";
WiFiClient espClient;
PubSubClient client(espClient);
void setup() {
WiFi.begin("YourSSID", "YourPassword");
client.setServer(mqtt_server, 1883);
while (!client.connected()) {
client.connect("esp32-client");
}
}
void loop() {
float temp = readTemperature();
char payload[10];
sprintf(payload, "%.1f", temp);
client.publish(topic, payload);
delay(60000); // Publish every minute
} Build Your First IoT Project
Let us combine everything you have learned into a complete IoT project: a WiFi-connected temperature and humidity monitor that sends data to your phone.
Project: Smart Temperature Monitor
What You Will Build
- ESP32 reads temperature and humidity from DHT22 sensor
- Data is sent via WiFi to an MQTT broker
- You can view real-time data on your phone using a dashboard app
Wiring
- DHT22 VCC to ESP32 3.3V
- DHT22 GND to ESP32 GND
- DHT22 DATA to ESP32 GPIO 4 (with 10k pull-up resistor to VCC)
Complete Code
#include <WiFi.h>
#include <PubSubClient.h>
#include <DHT.h>
// WiFi credentials
const char* ssid = "YourSSID";
const char* password = "YourPassword";
// MQTT settings
const char* mqtt_server = "192.168.1.100";
const char* temp_topic = "home/livingroom/temperature";
const char* humid_topic = "home/livingroom/humidity";
// DHT sensor
#define DHTPIN 4
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
WiFiClient espClient;
PubSubClient client(espClient);
void setup() {
Serial.begin(115200);
dht.begin();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi connected");
client.setServer(mqtt_server, 1883);
while (!client.connected()) {
if (client.connect("esp32-monitor")) {
Serial.println("MQTT connected");
} else {
delay(5000);
}
}
}
void loop() {
if (!client.connected()) {
client.reconnect();
}
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
if (isnan(temperature) || isnan(humidity)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
char tempPayload[10];
char humidPayload[10];
sprintf(tempPayload, "%.1f", temperature);
sprintf(humidPayload, "%.1f", humidity);
client.publish(temp_topic, tempPayload);
client.publish(humid_topic, humidPayload);
Serial.printf("Temp: %.1f C, Humidity: %.1f%%
", temperature, humidity);
client.loop();
delay(60000);
} View Data on Your Phone
Install an MQTT dashboard app like IoT MQTT Panel (Android) or MyMQTT (iOS). Configure it to connect to your broker and subscribe to the temperature and humidity topics. You will see real-time data from your ESP32!
Go Advanced
Once you have mastered the basics, explore these advanced topics to take your IoT skills to the next level.
Advanced Topics to Explore
TinyML: AI on Microcontrollers
Run machine learning models directly on your ESP32. Detect anomalies, recognize gestures, or predict equipment failures — all without cloud connectivity.
Matter Protocol
The new standard for smart home interoperability. Build devices that work seamlessly with Apple Home, Google Home, and Amazon Alexa.
Low-Power Design
Optimize your devices for battery operation. Learn deep sleep modes, solar charging, and energy harvesting techniques.
Industrial IoT (IIoT)
Explore protocols like Modbus, CAN bus, and OPC UA. Build robust systems for manufacturing, energy, and logistics.
Ready to Start Your IoT Journey?
You now have everything you need to build your first IoT project. The best way to learn is by doing — grab an ESP32, follow the tutorials, and start experimenting!