The ESP32 is arguably the most powerful microcontroller you can buy for under ₹500. With dual-core processing, built-in WiFi, Bluetooth 4.2/BLE, 34 GPIO pins, hardware ADC and DAC, touch sensing, and multiple sleep modes — it has made complex IoT projects accessible to every maker in India. This complete guide takes you from unboxing to writing your first WiFi-enabled program.
Table of Contents
What Is the ESP32?
The ESP32 is a low-cost, low-power System-on-Chip (SoC) designed by Espressif Systems. It was released in 2016 as the successor to the popular ESP8266, adding a second processor core, more GPIO, Bluetooth, better ADC hardware, and many more peripherals while keeping the price remarkably low.
The most common module you will encounter in India is the ESP-WROOM-32 — a small metal-shielded module containing the ESP32-D0WDQ6 chip, 4 MB of Flash, 520 KB of SRAM, and an integrated PCB antenna. This module is what most breakout development boards (NodeMCU-32, DevKitC, DOIT ESP32) are built around.
The ESP32 is used worldwide for IoT sensors, smart home devices, industrial automation, wearables, and even retro gaming consoles. In India, it has become the default choice for college engineering projects, smart home automation, and small-scale product development.
ESP32 Specifications
| Feature | Specification |
|---|---|
| CPU | Dual-core Xtensa LX6, up to 240 MHz |
| Co-processor | Ultra-low-power (ULP) co-processor |
| RAM | 520 KB SRAM (+ optional PSRAM) |
| Flash | 4 MB (module dependent) |
| WiFi | 802.11 b/g/n (2.4 GHz), up to 150 Mbps |
| Bluetooth | Bluetooth 4.2 Classic + BLE |
| GPIO | 34 programmable GPIO pins |
| ADC | Two 12-bit SAR ADCs, 18 channels |
| DAC | Two 8-bit DAC channels (GPIO 25, 26) |
| PWM | 16 channels, up to 40 MHz |
| Touch Pins | 10 capacitive touch pins |
| Interfaces | 3x UART, 3x SPI, 2x I2C, 2x I2S, 1x CAN |
| Operating Voltage | 3.3 V (most dev boards have onboard 3.3V regulator) |
| Deep Sleep Current | ~10 µA |
Pinout Overview
The ESP32 DevKitC / NodeMCU-32 development boards expose most of the chip’s pins on two rows of headers (19 pins per side). Key pin groups to know:
- Power pins: VIN (5V from USB), 3V3 (3.3V regulated output), GND
- Digital GPIO (3.3V logic): GPIO 0–39. Important: GPIOs 34, 35, 36, 39 are input-only — they have no internal pull-up/down and cannot drive outputs.
- ADC channels: ADC1 (GPIO 32–39), ADC2 (GPIO 0, 2, 4, 12–15, 25–27). Note: ADC2 is unavailable when WiFi is active — use ADC1 for analog reads in WiFi projects.
- DAC: GPIO 25 (DAC1) and GPIO 26 (DAC2) — true analog output
- Touch pins: GPIO 4, 0, 2, 15, 13, 12, 14, 27, 33, 32
- SPI (VSPI default): MOSI=23, MISO=19, CLK=18, CS=5
- I2C default: SDA=21, SCL=22
- UART0 (USB): TX=1, RX=3 — used for programming and Serial monitor
- Boot-sensitive pins: GPIO 0, 2, 12, 15 affect boot mode. Avoid connecting sensors to these if possible, or ensure they are at the correct level at power-up.
A PDF pinout diagram for the ESP32 DevKitC is available free from Espressif’s official documentation site — search for “ESP32 DevKitC pinout” on espressif.com.
Setting Up Arduino IDE for ESP32
The Arduino IDE is the easiest way to start programming the ESP32. Follow these steps:
- Download and install Arduino IDE 2.x from arduino.cc
- Open File → Preferences
- In the Additional Boards Manager URLs field, add:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json - Go to Tools → Board → Boards Manager, search for esp32, and install the esp32 by Espressif Systems package (version 3.x recommended)
- Connect your ESP32 board via USB. If Windows does not recognise it, install the CP2102 or CH340 driver (depends on which USB chip your board uses)
- Select your board under Tools → Board → ESP32 Arduino (e.g. ESP32 Dev Module)
- Set the correct COM port under Tools → Port
- For most boards: Flash Frequency=80MHz, Flash Mode=DIO, Upload Speed=115200
First Program: WiFi Network Scanner
This sketch scans for nearby WiFi networks and prints them to the Serial monitor — a perfect first test to confirm your ESP32 is working correctly.
#include <WiFi.h>
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
Serial.println("ESP32 WiFi Scanner ready");
}
void loop() {
Serial.println("Scanning for networks...");
int n = WiFi.scanNetworks();
if (n == 0) {
Serial.println("No networks found");
} else {
Serial.printf("%d networks found:
", n);
for (int i = 0; i < n; ++i) {
Serial.printf("%2d. %-32s RSSI: %4d dBm CH: %2d %s
",
i + 1,
WiFi.SSID(i).c_str(),
WiFi.RSSI(i),
WiFi.channel(i),
WiFi.encryptionType(i) == WIFI_AUTH_OPEN ? "OPEN" : "SECURED"
);
}
}
delay(5000); // Scan again every 5 seconds
}
Upload this sketch, open the Serial Monitor at 115200 baud, and you should see a list of all WiFi networks in range within a few seconds.
GPIO Modes
Use pinMode(pin, mode) to configure GPIO pins:
- OUTPUT — drive pin HIGH (3.3V) or LOW (0V). Max 40 mA per pin, 1200 mA total for all GPIO combined.
- INPUT — read digital voltage level. GPIO is floating — connect external pull-up or pull-down resistor.
- INPUT_PULLUP — enables internal ~45 kΩ pull-up resistor. Pin reads HIGH when nothing connected, LOW when pulled to GND.
- INPUT_PULLDOWN — enables internal pull-down resistor. Pin reads LOW when floating, HIGH when pulled to 3.3V.
Unlike Arduino Uno (5V tolerant), ESP32 GPIO pins are 3.3V only. Never connect 5V signals directly to GPIO pins — use a level shifter or a 10k/20k voltage divider.
ADC, DAC, and PWM
ADC (Analog-to-Digital Conversion)
Use analogRead(pin) to read analog voltages. The ESP32 has a 12-bit ADC (values 0–4095) measuring 0–3.3V. Important caveats:
- ADC accuracy is not great — there is known non-linearity near 0V and 3.3V. For precision measurements, use an external ADC (ADS1115).
- ADC2 pins are unavailable when WiFi is active. Always use ADC1 pins (GPIO 32–39) for analog reads in connected projects.
- Use
analogSetAttenuation(ADC_11db)for full 0–3.3V range; lower attenuation settings give better accuracy in smaller voltage ranges.
DAC (Digital-to-Analog Conversion)
GPIO 25 and 26 are true 8-bit DAC outputs (0–255 → 0–3.3V). Use dacWrite(25, value) to output a voltage. Useful for generating audio tones, variable voltage references, or analog control signals.
PWM
The ESP32’s LEDC peripheral gives you 16 independent PWM channels. Use ledcSetup(channel, freq, resolution) and ledcAttachPin(pin, channel). Example: 5 kHz PWM at 8-bit resolution for LED brightness control.
// Simple LED fade using PWM
const int ledPin = 2;
const int pwmChannel = 0;
const int pwmFreq = 5000;
const int pwmResolution = 8;
void setup() {
ledcSetup(pwmChannel, pwmFreq, pwmResolution);
ledcAttachPin(ledPin, pwmChannel);
}
void loop() {
for (int duty = 0; duty <= 255; duty++) {
ledcWrite(pwmChannel, duty);
delay(10);
}
for (int duty = 255; duty >= 0; duty--) {
ledcWrite(pwmChannel, duty);
delay(10);
}
}
Touch-Sensitive Pins
The ESP32 has 10 capacitive touch-sensing pins. Simply touch the pin with your finger and the reading drops — no external components needed. Use touchRead(pin) to get a reading (lower = touched).
void setup() {
Serial.begin(115200);
}
void loop() {
int val = touchRead(4); // GPIO 4 is T0
Serial.println(val);
// Typical: ~60 untouched, ~10 when touched
if (val < 20) {
Serial.println("TOUCHED!");
}
delay(100);
}
Touch pins can also be used as wake-up sources from deep sleep, enabling touchpad-activated IoT devices.
Deep Sleep and Power Saving
The ESP32’s deep sleep mode draws only ~10 µA — compared to ~160 mA when fully active with WiFi. This makes battery-powered IoT sensors viable. The ESP32 can wake from deep sleep via:
- Timer (e.g., wake up every 10 minutes, read a sensor, send data, sleep again)
- External GPIO signal (e.g., a PIR motion sensor triggers wake-up)
- Touch pin capacitance change
- ULP co-processor (reads sensors without waking the main cores)
#include <esp_sleep.h>
void setup() {
Serial.begin(115200);
Serial.println("Awake! Taking sensor reading...");
delay(1000); // Simulate reading a sensor
// Configure timer wake-up: 30 seconds
esp_sleep_enable_timer_wakeup(30 * 1000000ULL);
Serial.println("Going to deep sleep for 30 seconds...");
esp_deep_sleep_start();
}
void loop() {
// This never runs — device sleeps after setup()
}
Note: Variables stored in RTC_DATA_ATTR persist through deep sleep (up to 8 KB available in RTC slow memory).
ESP32 vs ESP8266
| Feature | ESP8266 | ESP32 |
|---|---|---|
| CPU Cores | 1 (Xtensa LX106) | 2 (Xtensa LX6) |
| Max Clock | 160 MHz | 240 MHz |
| RAM | ~50 KB usable | 320 KB usable |
| Bluetooth | None | Classic BT + BLE 4.2 |
| ADC | 1 channel, 10-bit | 18 channels, 12-bit |
| DAC | None | 2 channels, 8-bit |
| Touch Pins | None | 10 pins |
| Price (India) | ₹150–250 (NodeMCU) | ₹280–500 (DevKit) |
| Best For | Simple WiFi-only projects, ultra-budget | Complex IoT, BT projects, data processing |
The ESP32 is the better choice for almost all new projects — the small cost difference is easily justified by the massive performance and feature advantage. Use the ESP8266 only if you have existing code or stock, or need the absolute lowest component cost.
Popular ESP32 Development Boards
- ESP32 DevKitC / DOIT DevKit V1: The standard 30-pin or 38-pin breadboard-compatible board. Best for learning and prototyping.
- NodeMCU-32S: NodeMCU form factor with the ESP32-S chip. Familiar layout for those coming from the ESP8266 NodeMCU.
- ESP32-S3: Upgraded chip with USB OTG, AI acceleration (vector instructions), more GPIO, and USB-native programming. Great for camera and audio projects.
- ESP32-C3/C6: RISC-V based, single core, lower cost. C6 adds WiFi 6 (802.11ax) and Zigbee/Thread support for next-gen smart home.
- ESP32-CAM: Has an OV2640 2MP camera module and microSD card slot built in — perfect for security cameras, time-lapses, and computer vision projects.
ESP32 Project Ideas
- WiFi Weather Station: Read DHT22 temperature and humidity, display on a web page served from the ESP32
- Home Automation Relay Controller: Control lights and fans via a web dashboard or Telegram bot
- BLE Proximity Lock: Auto-lock/unlock a door when your phone’s Bluetooth is detected
- ESP32-CAM Doorbell: Motion-triggered photo sent to your WhatsApp via Telegram bot
- MQTT Smart Sensor Node: Publish temperature, humidity, and motion data to an MQTT broker for Home Assistant integration
- Spectrum Analyser: Audio FFT via I2S microphone, displayed on an SSD1306 OLED or TFT display
- Smart Plant Watering: Soil moisture sensor + relay-controlled pump, watering schedule over WiFi
Frequently Asked Questions
Q: Can ESP32 run on a battery?
Yes, and it works very well with deep sleep. A 3.7V 18650 Li-ion cell (2600 mAh) can power an ESP32 sensor node reading and transmitting data once per minute for several months. Connect the battery through a TP4056 charging module for rechargeable setups.
Q: Can I use 5V sensors with ESP32?
Only with a level shifter or voltage divider. ESP32 GPIO pins are 3.3V tolerant — connecting 5V signals directly will damage the chip over time. For I2C sensors, use a bidirectional logic level converter (TXS0102 or similar). For simple digital signals, a 10k/20k resistor voltage divider works fine.
Q: Why does my ESP32 reset randomly?
The most common cause is insufficient power supply current. The ESP32 can draw 250–340 mA peak during WiFi transmission. If your power source (USB cable, weak regulator) cannot supply this, the voltage drops below the minimum and triggers a brownout reset. Use a quality USB cable and charger, or add a 100 µF decoupling capacitor between 3V3 and GND near the ESP32.
Q: Is MicroPython or Arduino better for ESP32?
Arduino (C++) gives better performance and access to the full hardware, and has more libraries available. MicroPython is easier to learn and iterate quickly with (no compile step), but runs slower and uses more RAM. For beginners, start with Arduino. If you are comfortable with Python and building quick IoT scripts, MicroPython is excellent.
Q: Does the ESP32 work with Home Assistant?
Absolutely — this is one of the most popular use cases. ESPHome is a firmware framework that integrates ESP32 devices directly into Home Assistant with zero custom code. You define your sensor configuration in YAML and flash it over-the-air. It is the recommended approach for home automation with ESP32 in India.
Start Building with ESP32 Today
Shop the full range of ESP32 development boards and IoT components at Zbotic.in — genuine products, fast delivery across India.
Add comment