MakerLab
ESP32ESP32-S2

ESP32-S2: The Wi-Fi-Centric Microcontroller for Connected Projects

The ESP32-S2 is a versatile, low-power Wi-Fi microcontroller with a single-core processor, designed for IoT applications requiring robust wireless connectivity and enhanced security.

ESP32-S2

The ESP32-S2 is a member of Espressif Systems' popular ESP32 family of microcontrollers, distinguished by its focus on Wi-Fi connectivity and improved security features. Unlike its dual-core predecessors, the ESP32-S2 features a single-core Tensilica LX7 processor, making it an excellent choice for applications where power efficiency and a streamlined processing core are paramount, while still delivering ample performance for many IoT tasks.

At its heart, the ESP32-S2-Mini-1 module, or the ESP32-S2 chip itself, offers a compelling blend of processing power and peripheral capabilities. It boasts integrated Wi-Fi 802.11 b/g/n connectivity, a variety of GPIOs, ADCs, and support for standard communication protocols like I2C, SPI, and UART. Its design prioritizes security with features like secure boot and flash encryption, making it suitable for sensitive applications.

Released as an evolution of the original ESP32, the ESP32-S2 targets makers and engineers looking for a cost-effective and power-efficient solution for connected devices. It excels in scenarios where a dedicated Wi-Fi interface is needed without the complexity or power draw of a dual-core system. This makes it ideal for battery-powered sensors, smart home devices, and simple IoT gateways that primarily need to communicate wirelessly.

This microcontroller is particularly well-suited for projects that leverage its Wi-Fi capabilities for data logging, remote control, or web server applications. Its single-core architecture simplifies development for certain tasks and can lead to lower power consumption compared to dual-core variants, extending battery life in portable projects. Makers who need a reliable and secure Wi-Fi connection without requiring heavy computational tasks will find the ESP32-S2 a strong contender.

Watch

Related video, embedded from YouTube.

Specifications

Microcontroller / SoCESP32-S2 (Xtensa® 32-bit LX7 single-core processor)
Architecture32-bit RISC-V (Note: The ESP32-S2 uses a Tensilica LX7 core, not RISC-V. This is a common point of confusion, but the S2 is LX7)
Clock speedUp to 240 MHz
Flash / Storage4MB to 16MB external SPI flash (module dependent)
RAM / SRAM520 KB SRAM
Operating voltage3.0V - 3.6V (typically 3.3V)
Digital I/O pins34 (depending on module and configuration)
Analog / ADC20 Analog-to-Digital Converter (ADC) channels (12-bit resolution)
PWMUp to 16 channels (general purpose PWM)
ConnectivityWi-Fi 802.11 b/g/n (2.4 GHz)
USBNative USB OTG (On-The-Go) interface (can act as a USB device or host)
Power inputVia USB or VIN pin (typically 5V, regulated onboard)
DimensionsVaries by module (e.g., ESP32-S2-WROOM-1: 18.0 x 25.5 x 2.8 mm)

Pinout & pin functions

PinFunction
3V33.3V Power Output
GNDGround
ENEnable/Reset Pin
GPIO0Boot mode selection, General Purpose Input/Output
GPIO1UART0 TX, General Purpose Input/Output
GPIO2General Purpose Input/Output
GPIO3UART0 RX, General Purpose Input/Output
GPIO4General Purpose Input/Output
GPIO5General Purpose Input/Output
GPIO6SPI Flash CS, General Purpose Input/Output
GPIO7SPI Flash HD, General Purpose Input/Output
GPIO8SPI Flash WD, General Purpose Input/Output
GPIO9SPI Flash CS, General Purpose Input/Output
GPIO10SPI Flash CLK, General Purpose Input/Output
GPIO11SPI Flash D0, General Purpose Input/Output
GPIO12General Purpose Input/Output
GPIO13General Purpose Input/Output
GPIO14General Purpose Input/Output
GPIO15General Purpose Input/Output
GPIO16General Purpose Input/Output
GPIO17General Purpose Input/Output
GPIO18General Purpose Input/Output
GPIO19General Purpose Input/Output
GPIO20General Purpose Input/Output
GPIO21I2C SDA, General Purpose Input/Output
GPIO22I2C SCL, General Purpose Input/Output
GPIO23General Purpose Input/Output
GPIO24General Purpose Input/Output
GPIO25ADC1_CH8, General Purpose Input/Output
GPIO26ADC1_CH9, General Purpose Input/Output
GPIO27ADC1_CH10, General Purpose Input/Output
GPIO28ADC1_CH11, General Purpose Input/Output
GPIO29ADC1_CH12, General Purpose Input/Output
GPIO30ADC1_CH13, General Purpose Input/Output
GPIO31ADC1_CH14, General Purpose Input/Output
GPIO32ADC1_CH15, General Purpose Input/Output
GPIO33ADC1_CH16, General Purpose Input/Output
GPIO34ADC1_CH17, General Purpose Input/Output
GPIO35ADC1_CH18, General Purpose Input/Output
GPIO36ADC1_CH0, General Purpose Input/Output
GPIO37ADC1_CH1, General Purpose Input/Output
GPIO38ADC1_CH2, General Purpose Input/Output
GPIO39ADC1_CH3, General Purpose Input/Output
USB_D-USB Data Minus
USB_D+USB Data Plus
VINVoltage Input (typically 5V, regulated onboard)

Wiring & circuit basics

The ESP32-S2 operates at a logic level of 3.3V. Connecting 5V devices directly to its GPIO pins can cause permanent damage. Always use a logic level shifter or voltage divider if interfacing with 5V components like many standard Arduino shields or older sensors. Powering the board is typically done via its USB port, which supplies 5V. Alternatively, the VIN pin can be used for external power sources, also typically 5V. The onboard voltage regulator will step this down to the 3.3V required by the chip. Ensure your power supply can provide sufficient current, generally at least 500mA for stable operation, especially when Wi-Fi is active.

When connecting an LED, always use a current-limiting resistor to protect both the LED and the ESP32-S2's GPIO pin. A common value for an LED with a 3.3V supply is around 220-330 ohms. For example, to blink an LED connected to GPIO2, you would wire the LED's anode to GPIO2, the cathode to one end of the resistor, and the other end of the resistor to a GND pin.

For I2C communication, the ESP32-S2 uses GPIO21 for SDA and GPIO22 for SCL. These pins often require pull-up resistors (typically 4.7k ohm) to 3.3V, which are sometimes included on development boards. When connecting an I2C sensor, connect its VCC to 3V3, GND to GND, SDA to GPIO21, and SCL to GPIO22. Ensure the sensor is also a 3.3V device or use level shifting if it's a 5V sensor.

Programming & getting started

The ESP32-S2 can be programmed using several popular development environments. The Arduino IDE is a common choice, requiring the installation of the ESP32 board support package. This allows you to write C++ code using the familiar Arduino framework. Alternatively, MicroPython and CircuitPython offer Python-based programming, which can be more accessible for beginners. For advanced users, Espressif's official ESP-IDF (Espressif IoT Development Framework) provides a comprehensive C/C++ SDK for maximum control and performance.

To upload your first program (a 'Blink' sketch) using the Arduino IDE: 1. Install the ESP32 board support in the Arduino IDE. 2. Connect your ESP32-S2 board to your computer via USB. 3. Select the correct ESP32-S2 board and COM port from the Tools menu. 4. Paste the Blink sketch into the IDE. 5. Click the Upload button. The board will typically enter bootloader mode automatically, or you may need to hold down the BOOT (GPIO0) button while pressing RESET (EN) and then releasing them to initiate the upload.

Project ideas

Wi-Fi Connected Weather StationBuild a device that reads temperature and humidity from sensors (e.g., DHT22) and transmits the data over Wi-Fi to a web server or cloud service. Uses ADC for sensors, GPIO for control, and Wi-Fi for communication. Learns about sensor interfacing and network protocols.
Smart Home Light ControllerCreate a device that can be controlled remotely via a web interface hosted on the ESP32-S2 itself, turning an LED or relay on/off. Uses GPIO for output and Wi-Fi for web server functionality. Teaches web server development on microcontrollers.
Bluetooth Low Energy (BLE) BeaconConfigure the ESP32-S2 to broadcast sensor data or identification information using BLE. While the S2 primarily focuses on Wi-Fi, it has BLE capabilities. Uses GPIO and BLE stack. Explores low-power wireless communication.
USB HID Device (Keyboard/Mouse)Leverage the ESP32-S2's native USB OTG capabilities to emulate a USB keyboard or mouse, sending pre-programmed keystrokes or movements. Uses the USB interface. Introduces human interface device emulation.
IoT Data Logger to CloudCollect data from multiple sensors (e.g., soil moisture, light levels) and send it periodically to a cloud platform like ThingSpeak or Adafruit IO using Wi-Fi. Uses ADC, GPIO, and Wi-Fi. Focuses on data acquisition and cloud integration.
Secure Wi-Fi Access PointSet up the ESP32-S2 as a small Wi-Fi access point, allowing other devices to connect to it and access a local web server or limited network. Uses Wi-Fi in AP mode. Teaches network configuration and access point functionality.

Buying tips & gotchas

When purchasing an ESP32-S2 board, look for modules like the ESP32-S2-WROOM or ESP32-S2-WROVER, which come pre-flashed with antenna and are easier to work with. Be aware of the 3.3V logic level; using 5V components without proper level shifting is a common pitfall. Ensure your power supply can handle the current spikes associated with Wi-Fi transmission (can exceed 300mA). The native USB OTG feature is a significant advantage for projects requiring direct USB connectivity without an external USB-to-serial chip, but it requires specific libraries and handling. Consider boards with integrated USB-to-serial for easier programming if you don't plan to use the native USB extensively.