Back to blog
ESP32 28 May 2025 7 min

ESP32 for Beginners: From Blink to Connected

A practical path to your first Wi-Fi-connected ESP32 project, including OTA updates and MQTT basics.

By PB Lab

The ESP32 is the microcontroller that made hobbyist IoT genuinely practical. For a couple of hundred rupees you get a dual-core processor, Wi-Fi, Bluetooth, plenty of GPIO, and a mature toolchain. This guide takes you from the classic blinking LED to a connected device that reports data and updates its own firmware over the air.

Step 1: Blink — proving the toolchain

Every embedded journey starts with blinking an LED, and for good reason: it proves your board, cable, drivers, and IDE all work together before you add any complexity. Whether you use the Arduino core or ESP-IDF, get a GPIO toggling on and off before anything else. If blink works, your foundation is solid.

Step 2: Connecting to Wi-Fi

The ESP32's headline feature is Wi-Fi. Connecting is a few lines of code, but the real skill is handling reality: networks drop, credentials change, and routers reboot. A production device should reconnect automatically, avoid blocking the main loop while connecting, and never hard-code credentials in a way that can't be changed.

  • Use a non-blocking connection pattern so sensors keep running
  • Store Wi-Fi credentials in NVS (flash), not source code
  • Provide a fallback: a captive-portal setup mode when it can't connect

Step 3: Talking to the world with MQTT

HTTP is fine for occasional requests, but for IoT the better default is MQTT — a lightweight publish/subscribe protocol built for unreliable networks and many small messages. Your ESP32 publishes readings to a topic like home/livingroom/temperature, and any number of dashboards, automations, or apps subscribe to it. A broker such as Mosquitto sits in the middle.

MQTT's retained messages and last-will-and-testament features make it easy to know a device's current value and to detect when a device goes offline — both essential for real deployments.

Step 4: Over-the-air (OTA) updates

Once a device is installed inside a wall or on a roof, plugging in a USB cable to update it is not an option. OTA updates let the ESP32 download and flash new firmware over Wi-Fi. This single capability is what separates a toy from a product — you can fix bugs and add features to devices already in the field.

Where to go next

From here, add deep sleep for battery-powered sensors, TLS for secure connections, and a proper home-automation hub like Home Assistant to tie everything together. The ESP32 scales from a weekend blink to a genuinely professional connected product — which is exactly why it has become the default choice for makers and companies alike.