During my search for a small and cheap ESP32 board to use with ESPHome IoT projects, I stumbled upon the amazing ESP32-S2 Mini. This board is the compact and low budget option I was looking for, and while it is available on AliExpress from various sellers, there are a few details to consider.
Hardware Features
The ESP32-S2 Mini boards (aka WEMOS LOLIN S2 Mini) are based on the ESP32-S2FN4R2 that runs at 240Mhz and come with an impressive 27 IO pins and 4MB of flash on a 34.3 x 25.4mm purple PCB. The full details, including schematics, can be found here and here.
A full resolution poster with the detailed board pinout is also available here.
Hardware Pin Definitions
According to the Arduino libraries and the datasheet these are the optimal hardware pin definitions for this board:
// I2C
SDA -> 33
SCL -> 35
// SPI
SS / CS -> 12
MOSI / COPI / SDI -> 11
MISO / CIPO / SDO -> 9
SCK -> 7
// UART
TX -> 39
RX -> 37
// DAC
DAC1 -> 17
DAC2 -> 18
Note that this board is capable of reconfiguring the pins above to any GPIO however the performance may not be as good as with native hardware pins.
Flashing with ESPHome
Unlike most ESP32 boards this one doesn’t usually come with a bootloader pre-flashed so you’ll have to do it yourself. The first flash is the trickiest and it must be done using a USB cable. Later on you may upgrade the firmware over Wi-Fi.
ESP32 boards can usually be flashed with ESPHome at web.esphome.io, however, in this case it fails due to a bug in esptool-js
described here. Fortunately we can get around this with the official ESP32 flashing tool and the generic firmware image:
- ESP32 Flash Tool
- CP210x drivers
- Generic ESPHome firmware image and download
esphome-web
artifact and extractesphome-web-esp32s2.bin
To start the process place the board in “download mode”:
- Connect the board to your computer;
- Hold the button labeled as
0
(don’t release it); - Press the
RST
button for about a second and release it; - Now release the
0
button.
After the last sequence a new serial port will appear in your computer. Now launch the tool and flash the board with esphome-web-esp32s2.bin
at the address 0x0
and with DoNotChgBin
checked:
After the flashing is complete power cycle the board and you’ll find the usual ESPHome Wi-Fi hotspot.
ESPHome Configuration
Your ESPHome yaml file for this board should look like this:
esp32:
board: lolin_s2_mini
variant: ESP32S2
framework:
type: arduino
This board usually run hot and disabling logging, web server etc. will help but won’t fix the issue completely. You may also lower the CPU clock and disable USB CDC:
esphome:
# ...
platformio_options:
board_build.f_cpu = 160000000L # 160 Mhz instead of the default 240 Mhz.
board_build.extra_flags:
- "-DARDUINO_USB_CDC_ON_BOOT=0"
Here’s an example of this board running the Bosch BME680 sensor and publishing environmental information to Home Assistant:
Board Revisions
Be aware that there are different versions of the board on AliExpress and some have a design issue that causes random reboots when the Wi-Fi is in use. Here is an analysis by vettel:
I bought dozens of those boards and the only reliable store seems to be this one as most sellers seem to ship mixed batches boards and you never know what you’ll get.
Closing Remarks
I consider this to be a good ESP32 board when a lot of I/O and a fast chip is required. It may be a very good modern replacement for Arduino Mega boards as well.
However, if you’re looking for a small board to run a single sensor or a relay with ESPHome then the ESP32-C3 Super Mini (seller here) is most likely a better option as it can be flashed much faster with web.esphome.io from any browser.
All files linked in this article are mirrored here for future reference and preservation.