Getting Started with the ESP32: the short answer
The ESP32 is a low-cost microcontroller with Wi-Fi and Bluetooth built in, and it is the most popular board for connected projects in India. 3 V, has two cores at up to 240 MHz, plenty of memory, and many pins with ADC, PWM, touch, I2C, SPI and UART functions. Example: Strapping pins (0, 2, 12, 15) must be in their default state at reset. Keep sensors off them or make sure they idle in the right state.
- Level
- Beginner
- Time
- About 6 min
- Topic
- Microcontrollers
Install ESP32 support in the Arduino IDE, upload your first sketch and avoid the pins that cause boot problems.
Before this: Arduino and ESP32 Basics
The ESP32 is a low-cost microcontroller with Wi-Fi and Bluetooth built in, and it is the most popular board for connected projects in India. It runs at 3.3 V, has two cores at up to 240 MHz, plenty of memory, and many pins with ADC, PWM, touch, I2C, SPI and UART functions. The common ESP32 DevKit V1 board adds a USB-serial chip (CP2102 or CH340), a 3.3 V regulator and BOOT and EN (reset) buttons.
To set it up, open the Arduino IDE, go to Boards Manager, search for esp32 by Espressif Systems and install it. Choose ESP32 Dev Module as the board, pick the COM port that appears when you plug it in, and upload the Blink example (many boards have an LED on GPIO2). If no port appears, install the CP210x or CH340 driver and try a different cable: many cheap USB cables carry power only. If the upload hangs at 'Connecting...', hold the BOOT button until it starts.
Some pins need care. GPIO 6 to 11 connect to the board's flash memory and must not be used. GPIO 34 to 39 are inputs only and have no internal pull-ups. GPIO 0, 2, 12 and 15 are strapping pins that the chip reads at reset; a sensor pulling GPIO12 high, for example, can stop the board from booting. ADC2 pins cannot be read while Wi-Fi is on, so use ADC1 pins (GPIO 32 to 39) for analog sensors. And remember the pins are 3.3 V only.
Set up the toolchain
Install the ESP32 board support in the Arduino IDE or use PlatformIO, select the exact board type, and choose the correct port. If the port does not appear, the usual causes are a charge-only USB cable or a missing USB-serial driver. Some boards need the BOOT button held while uploading starts.
The ESP32 runs at 3.3 V, and its pins are not 5 V tolerant. It has Wi-Fi and Bluetooth built in, which is a big part of its appeal.
Know the pins
Not all pins are equal. Some are used at boot to decide the startup mode, so pulling them to the wrong level at reset stops it booting. Some pins are input-only, and on the original ESP32 the ADC2 pins do not work while Wi-Fi is on. Check the pinout of your exact board before wiring.
Start with the built-in LED blink, then serial printing, then connecting to Wi-Fi, which makes the board useful on a network.
Power and good practice
Wi-Fi transmission causes current peaks of a few hundred milliamps, so a weak supply or a long thin cable causes random resets. Use a good USB supply and cable, and add a capacitor near the module if you power it from a battery regulator. Keep Wi-Fi passwords out of code that you share.
- Using a charge-only USB cable and not seeing the port.
- Connecting a pin that affects boot to a circuit that pulls it the wrong way.
- Powering it from a weak supply and getting resets when Wi-Fi turns on.
The board will not boot after adding a sensor
- The ESP32 worked alone but now resets or shows no output after wiring a sensor.
- The sensor's output is on GPIO12, and the sensor holds it HIGH at power-up.
- GPIO12 sets the flash voltage at reset; HIGH selects 1.8 V and the flash cannot start.
- Move the sensor to a safe pin such as GPIO25 or GPIO26.
Result. Strapping pins (0, 2, 12, 15) must be in their default state at reset. Keep sensors off them or make sure they idle in the right state.
Install the ESP32 core, upload Blink to GPIO2, then change it to read a push button on GPIO4 with INPUT_PULLUP and print the state to the Serial Monitor at 115200 baud.
3 quick questions
Which pins must never be used on a common ESP32 module?
An analog sensor reads nothing while Wi-Fi is on. Why?
The upload hangs at 'Connecting...'. What do you try?
