If you have been exploring the world of microcontrollers and IoT, you have almost certainly come across the ESP32. It is everywhere -- from hobbyist forums to commercial products, from weather stations on rooftops to smart locks on front doors. There is a good reason for that. The ESP32 packs WiFi, Bluetooth, a powerful dual-core processor, and dozens of GPIO pins into a board that costs less than a cup of fancy coffee.
This guide walks you through everything you need to go from unboxing your first ESP32 to controlling an LED from your phone over WiFi. No prior microcontroller experience required.
What Is the ESP32?
The ESP32 is a low-cost, low-power system-on-chip (SoC) designed by Espressif Systems, a Shanghai-based semiconductor company. It is the successor to the wildly popular ESP8266, and it improves on its predecessor in virtually every dimension -- more processing power, more memory, Bluetooth support, more GPIO pins, and better power management.
What makes ESP32 the go-to choice for IoT projects:
- Built-in WiFi and Bluetooth -- no external modules needed
- Dual-core processor running at up to 240 MHz -- fast enough for real-time applications
- Ultra-low power consumption -- supports deep sleep modes drawing as little as 10 microamps
- Rich peripheral set -- ADC, DAC, I2C, SPI, UART, PWM, capacitive touch, and more
- Massive community -- thousands of tutorials, libraries, and open-source projects
- Arduino IDE compatible -- write code in the same environment you already know
- Affordable -- the ESP32-DevKitC-32E starts at just Rs.399
Whether you want to build a home automation system, a portable weather station, a Bluetooth-controlled robot, or a mesh network of sensors, the ESP32 is an excellent starting point.
ESP32-DevKitC-32E: What Is on the Board?
The ESP32-DevKitC-32E is the official development board from Espressif. It breaks out all the ESP32 pins onto a breadboard-friendly form factor and includes a USB-to-serial converter for easy programming.
Here are the key specifications:
| Specification | Detail |
|---|---|
| Processor | Dual-core Xtensa LX6 at 240 MHz |
| WiFi | 802.11 b/g/n, 2.4 GHz, up to 150 Mbps |
| Bluetooth | Bluetooth 4.2 BR/EDR + BLE |
| SRAM | 520 KB |
| Flash | 4 MB (onboard) |
| GPIO Pins | 34 programmable pins |
| ADC | 12-bit, 18 channels |
| DAC | 8-bit, 2 channels |
| Interfaces | SPI, I2C, I2S, UART, CAN, PWM, capacitive touch |
| Operating Voltage | 3.3V logic (5V USB power input) |
| USB Connector | Micro-USB (for power and programming) |
| Dimensions | Approximately 55 x 28 mm |
The board has a Boot button (GPIO0) and an EN (Enable/Reset) button. You will use both during development.
What You Need to Get Started
Before writing any code, gather these items:
Essential
- ESP32-DevKitC-32E -- the development board itself
- Micro-USB cable -- make sure it is a data cable, not a charge-only cable (this is the most common beginner mistake)
- Computer -- Windows, macOS, or Linux
Recommended for Hands-on Projects
- Breadboard (830-point) -- for prototyping without soldering
- Jumper wires (male-to-male) -- to connect components on the breadboard
- LEDs (5mm, any colour) -- for visual output
- Resistors (220 ohm or 330 ohm) -- current limiting for LEDs
- Push buttons -- for input experiments
All of these components are available at wavtron.in. If you are in Bengaluru, you can get same-day dispatch with a proper GST invoice -- handy if you are purchasing for a company or educational institution.
Step 1: Install the Arduino IDE
The Arduino IDE is the easiest way to program the ESP32, especially if you are a beginner.
Download and Install
- Go to https://www.arduino.cc/en/software
- Download Arduino IDE 2.x for your operating system
- Install it using the default settings
Add ESP32 Board Support
The Arduino IDE does not include ESP32 support out of the box. You need to add it:
- Open Arduino IDE
- Go to File > Preferences (on macOS: Arduino IDE > Settings)
- In the Additional Board Manager URLs field, paste this URL:
https://espressif.github.io/arduino-esp32/package_esp32_index.json
- Click OK
- Go to Tools > Board > Boards Manager
- Search for esp32
- Find esp32 by Espressif Systems and click Install
- Wait for the installation to complete (it downloads around 200 MB)
Select Your Board
- Go to Tools > Board > esp32
- Select ESP32 Dev Module
- Connect your ESP32 via USB
- Go to Tools > Port and select the port that appeared (usually
/dev/cu.usbserial-*on macOS,COM3or similar on Windows,/dev/ttyUSB0on Linux)
If no port appears, you likely need to install a USB driver. See the troubleshooting section below.
Step 2: Your First Blink Sketch
The "Hello World" of microcontrollers is blinking an LED. The ESP32-DevKitC-32E has a built-in LED connected to GPIO 2 on most boards.
The Code
Create a new sketch and paste this code:
// Blink the onboard LED on ESP32-DevKitC-32E
// The built-in LED is typically on GPIO 2
#define LED_PIN 2
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(115200);
Serial.println("ESP32 Blink sketch started!");
}
void loop() {
digitalWrite(LED_PIN, HIGH);
Serial.println("LED ON");
delay(1000);
digitalWrite(LED_PIN, LOW);
Serial.println("LED OFF");
delay(1000);
}
Upload and Run
- Click the Upload button (right arrow icon) in the Arduino IDE
- Watch the output console at the bottom. You will see "Connecting..."
- Important: On some ESP32 boards, you need to hold down the Boot button while the IDE shows "Connecting..." and release it once upload starts
- After a successful upload, you will see "Hard resetting via RTS pin..."
- The onboard LED should now blink on and off every second
Open the Serial Monitor (Tools > Serial Monitor, set baud rate to 115200) to see the "LED ON" and "LED OFF" messages printing in real time.
Try This: Blink an External LED
Connect an external LED to the breadboard:
- Connect GPIO 4 to a 220-ohm resistor
- Connect the other end of the resistor to the anode (longer leg) of an LED
- Connect the cathode (shorter leg) of the LED to GND on the ESP32
Change #define LED_PIN 2 to #define LED_PIN 4 and upload again. Now your external LED blinks.
Step 3: Connect to WiFi
This is where the ESP32 really shines. Connecting to a WiFi network takes just a few lines of code.
#include <WiFi.h>
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("Connecting to WiFi...");
WiFi.begin(ssid, password);
int attempts = 0;
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
attempts++;
if (attempts > 40) {
Serial.println("\nFailed to connect. Check credentials and restart.");
return;
}
}
Serial.println("\nConnected!");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
Serial.print("Signal Strength (RSSI): ");
Serial.print(WiFi.RSSI());
Serial.println(" dBm");
}
void loop() {
// Nothing here yet
}
Replace YOUR_WIFI_NAME and YOUR_WIFI_PASSWORD with your actual WiFi credentials. Upload, open Serial Monitor at 115200 baud, and you should see something like:
Connecting to WiFi...
......
Connected!
IP Address: 192.168.1.42
Signal Strength (RSSI): -45 dBm
Note: The ESP32 only supports 2.4 GHz WiFi. If your router broadcasts separate 2.4 GHz and 5 GHz networks, make sure you use the 2.4 GHz SSID. If your router uses a combined SSID, the ESP32 will automatically connect to the 2.4 GHz band.
Step 4: Build a Web Server to Control an LED
Now let us combine everything into a practical project. We will create a web server running on the ESP32 that lets you toggle an LED on and off from any browser on your phone or laptop.
#include <WiFi.h>
#include <WebServer.h>
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
#define LED_PIN 2
WebServer server(80);
bool ledState = false;
const char* htmlPage = R"rawliteral(
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ESP32 LED Control</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
background: #0F1A2E;
color: #f1f5f9;
}
h1 { margin-bottom: 30px; }
.btn {
display: inline-block;
padding: 16px 40px;
font-size: 18px;
font-weight: bold;
border: none;
border-radius: 8px;
cursor: pointer;
text-decoration: none;
color: white;
margin: 8px;
}
.on { background: #10B981; }
.off { background: #dc3545; }
.status {
margin-top: 20px;
font-size: 14px;
color: #64748B;
}
</style>
</head>
<body>
<h1>ESP32 LED Control</h1>
<div>
<a href="/on" class="btn on">Turn ON</a>
<a href="/off" class="btn off">Turn OFF</a>
</div>
<p class="status">LED is currently: %STATE%</p>
</body>
</html>
)rawliteral";
String getPage() {
String page = String(htmlPage);
page.replace("%STATE%", ledState ? "ON" : "OFF");
return page;
}
void handleRoot() {
server.send(200, "text/html", getPage());
}
void handleOn() {
ledState = true;
digitalWrite(LED_PIN, HIGH);
server.send(200, "text/html", getPage());
Serial.println("LED turned ON via web");
}
void handleOff() {
ledState = false;
digitalWrite(LED_PIN, LOW);
server.send(200, "text/html", getPage());
Serial.println("LED turned OFF via web");
}
void setup() {
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected!");
Serial.print("Open this URL in your browser: http://");
Serial.println(WiFi.localIP());
server.on("/", handleRoot);
server.on("/on", handleOn);
server.on("/off", handleOff);
server.begin();
Serial.println("Web server started.");
}
void loop() {
server.handleClient();
}
How to Use It
- Upload the sketch to your ESP32
- Open Serial Monitor -- note the IP address printed (e.g.,
192.168.1.42) - On your phone or laptop (connected to the same WiFi), open a browser
- Navigate to
http://192.168.1.42(use your actual IP) - Tap Turn ON or Turn OFF to control the LED
You just built a web-controlled IoT device. The same pattern scales to controlling relays (for mains appliances), motors, servos, and more.
Understanding the ESP32 Pin Map
Not all GPIO pins on the ESP32 behave the same way. Here is a quick reference:
| Pins | Notes |
|---|---|
| GPIO 0 | Boot button. Pulling LOW during reset enters flash mode. Avoid for general use. |
| GPIO 1, 3 | TX/RX for Serial. Do not use if you need Serial Monitor. |
| GPIO 2 | Onboard LED on most DevKitC boards. Safe for output. |
| GPIO 4, 5, 12-33 | General-purpose. Safe for most applications. |
| GPIO 6-11 | Connected to onboard flash. Never use these. |
| GPIO 34, 35, 36, 39 | Input-only. No internal pull-up/pull-down. Good for analog reads. |
| GPIO 12 | Affects flash voltage on boot. Be careful with pull-up/pull-down on this pin. |
Rule of thumb: Stick to GPIO 4, 5, 13-27, and 32-33 for your projects. These are the safest and most versatile pins.
Common Troubleshooting
"No port detected" or "Failed to connect to ESP32"
Cause: Missing USB-to-serial driver or a charge-only USB cable.
Fix:
- Try a different USB cable. Many cheap cables only carry power, not data.
- Install the CP2102 driver if your board uses a CP2102 chip (most DevKitC-32E boards do): Silicon Labs CP210x driver
- On some boards with the CH340 chip, install the CH340 driver
- On Linux, you may need to add your user to the
dialoutgroup:sudo usermod -aG dialout $USERthen log out and back in
Upload gets stuck at "Connecting..."
Cause: The ESP32 is not entering bootloader mode.
Fix:
- Hold down the Boot button on the ESP32
- Click Upload in the Arduino IDE
- When you see "Connecting..." in the console, release the Boot button
- The upload should proceed
If this happens every time, check if GPIO 0 or GPIO 2 are connected to something on your breadboard that might be holding them in an unexpected state.
"Brownout detector was triggered"
Cause: Insufficient power supply. The ESP32 can draw up to 500 mA during WiFi transmission.
Fix:
- Use a USB port directly on your computer, not a passive hub
- Try a different USB cable (thin cables have high resistance)
- For battery-powered projects, use a regulator that can supply at least 500 mA at 3.3V
WiFi keeps disconnecting
Fix:
- Move the ESP32 closer to your router for testing
- Make sure you are using the 2.4 GHz band
- Add a reconnection routine in your
loop():
void loop() {
if (WiFi.status() != WL_CONNECTED) {
Serial.println("WiFi lost. Reconnecting...");
WiFi.disconnect();
WiFi.begin(ssid, password);
int retries = 0;
while (WiFi.status() != WL_CONNECTED && retries < 20) {
delay(500);
Serial.print(".");
retries++;
}
if (WiFi.status() == WL_CONNECTED) {
Serial.println("\nReconnected!");
}
}
server.handleClient();
}
Sketch uploads but nothing happens
- Open Serial Monitor and set the baud rate to 115200 (must match
Serial.begin(115200)) - Press the EN (reset) button on the board to restart the sketch
- Check for compilation warnings you might have missed
What to Build Next
Once you are comfortable with the basics, here are project ideas that build on what you have learned:
Temperature and Humidity Monitor
Connect a DHT22 sensor to the ESP32 and display readings on a web dashboard. Add a 0.96-inch OLED display (I2C, SSD1306) to show readings locally. Both components are available at Wavtron.
Home Automation with Relays
Use a 4-channel relay module to control fans, lights, or appliances from your phone. Combine with the web server code from this guide. Safety warning: mains voltage (230V AC) is dangerous. Only attempt this if you understand electrical safety or work with a qualified electrician.
Weather Station
Combine a BMP280 (pressure + temperature), DHT22 (humidity), and an LDR (light level) to build a full weather station. Log data to ThingSpeak or Google Sheets over WiFi.
Bluetooth-Controlled Robot
Use ESP32's Bluetooth to control a two-motor robot chassis from a phone app. The L298N motor driver and a robot chassis kit make this straightforward.
LoRa Long-Range Communication
Pair your ESP32 with a LoRa module (like the SX1276) for communication over kilometres without WiFi or cellular. Perfect for farm monitoring, remote sensors, or mesh networks. Wavtron stocks LoRa modules that pair directly with ESP32 boards.
MQTT and Home Assistant Integration
Connect your ESP32 to an MQTT broker and integrate it with Home Assistant for a proper smart home setup. This is how many commercial smart devices work under the hood.
Alternative Development Frameworks
While this guide uses the Arduino IDE for simplicity, you should know about other options as you advance:
| Framework | Best For |
|---|---|
| Arduino IDE | Beginners, quick prototyping |
| PlatformIO (VS Code extension) | Serious development, library management, debugging |
| ESP-IDF (Espressif's official SDK) | Production firmware, maximum control, FreeRTOS |
| MicroPython | Python developers, rapid prototyping |
| ESPHome | Home Assistant integrations with zero code |
PlatformIO is the natural next step once you outgrow the Arduino IDE. It offers proper code completion, a library manager, and support for multiple boards in a single project.
Quick Reference: Useful Libraries
These Arduino libraries work well with the ESP32 and cover the most common use cases:
| Library | Purpose | Install via |
|---|---|---|
WiFi.h |
WiFi connectivity | Built-in with ESP32 board package |
WebServer.h |
Simple HTTP server | Built-in |
HTTPClient.h |
Make HTTP requests | Built-in |
BluetoothSerial.h |
Classic Bluetooth serial | Built-in |
BLEDevice.h |
Bluetooth Low Energy | Built-in |
DHT.h |
DHT11/DHT22 sensors | Library Manager: "DHT sensor library" |
Adafruit_SSD1306.h |
OLED displays | Library Manager: "Adafruit SSD1306" |
PubSubClient.h |
MQTT client | Library Manager: "PubSubClient" |
ArduinoJson.h |
JSON parsing/creation | Library Manager: "ArduinoJson" |
ESPAsyncWebServer.h |
Async web server | GitHub: me-no-dev/ESPAsyncWebServer |
Wrapping Up
The ESP32 sits at a remarkable intersection of power, versatility, and affordability. For under Rs.400, you get a dual-core processor with WiFi and Bluetooth that can run a web server, read sensors, drive motors, and communicate over long distances with the right modules. It is no wonder this chip has become the backbone of the maker and IoT community worldwide.
In this guide you have:
- Set up the Arduino IDE with ESP32 board support
- Uploaded your first blink sketch
- Connected the ESP32 to WiFi
- Built a web server that controls an LED from your phone
That web server pattern -- reading inputs, running logic, serving a page -- is the foundation of almost every IoT project. Once you have it working, you are limited only by the sensors and actuators you connect.
All the boards, sensors, modules, and components mentioned in this guide are available at wavtron.in. Orders ship same-day from Bengaluru, and every order includes a GST invoice. If you are stocking up for a workshop, college lab, or just your next weekend project, Wavtron has you covered.
Happy building.



