Getting Started with ESP32: Build Your First IoT Project
Technical Tutorials · 2026-10-17
A beginner-friendly guide to the ESP32: what it is, what you need, and how to read a temperature sensor and see the value on your phone over Wi-Fi.
The ESP32 is a small, low-cost microcontroller with built-in Wi-Fi and Bluetooth. It is one of the best boards for learning the Internet of Things (IoT), because you can read sensors and put the data online with a single chip. In this tutorial you will build a tiny web server that shows the room temperature on your phone.
What you need
- 1 × ESP32 development board (ESP32-WROOM-32 or similar)
- 1 × DHT11 or DHT22 temperature and humidity sensor
- A breadboard and 3 jumper wires
- A USB cable and a computer with the Arduino IDE
Step 1: Set up the Arduino IDE
- Install the Arduino IDE.
- Open File → Preferences and add the ESP32 board manager URL from Espressif's documentation.
- Open Tools → Board → Boards Manager, search for esp32, and install it.
- From Library Manager, install the DHT sensor library by Adafruit.
Step 2: Wire the sensor
| DHT pin | ESP32 pin | | --- | --- | | VCC | 3V3 | | DATA | GPIO 4 | | GND | GND |
Step 3: Upload the code
Replace the Wi-Fi name and password, then upload:
#include <WiFi.h>
#include <WebServer.h>
#include <DHT.h>
const char* ssid = "YOUR_WIFI";
const char* password = "YOUR_PASSWORD";
DHT dht(4, DHT11);
WebServer server(80);
void handleRoot() {
float t = dht.readTemperature();
float h = dht.readHumidity();
String page = "<h1>Room monitor</h1><p>Temperature: " + String(t) +
" °C</p><p>Humidity: " + String(h) + " %</p>";
server.send(200, "text/html", page);
}
void setup() {
Serial.begin(115200);
dht.begin();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) delay(500);
Serial.println(WiFi.localIP());
server.on("/", handleRoot);
server.begin();
}
void loop() {
server.handleClient();
}Step 4: Open it on your phone
Open the Serial Monitor (115200 baud). The ESP32 prints its IP address, for example 192.168.0.105. Type that address into your phone's browser while connected to the same Wi-Fi. You will see the live temperature and humidity.
Where to go next
- Add a relay to switch a fan on when it gets hot.
- Send data to a cloud dashboard to see history from anywhere.
- Use the same pattern for soil moisture, water level or gas sensors: the basis of smart agriculture and safety systems.
Conclusion
With one board and one sensor, you have built a real IoT device. Every connected system, from smart farms to factory monitors, starts from this same idea: sense, process, and share.
Want to learn hands-on with a mentor? Check our robotics and IoT programs.
Topics
- ESP32
- IoT
- Arduino
- Robotics Education