Wemos S2 Mini ( Esp32S2 ) Platformio example

If you recently bought the awesome Wemos S2 Mini with this specs:

  • based ESP32-S2FN4R2 WIFI IC
  • Type-C USB
  • 4MB Flash
  • 2MB PSRAM
  • 27x IO
  • ADC, DAC, I2C, SPI, UART, USB OTG
  • Compatible with LOLIN D1 mini shields
  • Compatible with MicroPython, Arduino and ESP-IDF
  • Default firmware: MicroPython

A good solution is to use the Platformio ecosystem if you don’t want to use micropython or the Arduino IDE to program it, the only problem being that it doesn’t have native support to this board yet.

But this is easy to fix this once you know how to do it.
We first start by creating a project with platformio ( could be using visual studio code or the jetbrains clion IDE ), as a board we choose the esp generic dev board “Espressif ESP32 Dev Module”, in the end it doesn’t matter as we are going to overwrite the platformio config file

After you initialize the project, go to the platformio.ini file and change the contents to the following:


[env:esp32dev]
platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32#master
# DARDUINO_USB_CDC_ON_BOOT = 1 enables usb serial port
# DARDUINO_USB_MSC_ON_BOOT = 1 enables usb mass storage device
build_flags =
    -DBOARD_HAS_PSRAM
    -mfix-esp32-psram-cache-issue
    -DARDUINO_USB_CDC_ON_BOOT=1
    -DARDUINO_USB_MSC_ON_BOOT=0
board = esp32-s2-saola-1
board_build.mcu = esp32s2
framework = arduino

Now clean the project and rebuild, your binaries should be compatible with the Wemos S2 Mini Board now.

As we are using a “fake” board, the defines and pins need to be addressed by number and not by constants like “PIN_5”, you can find the diagrams on hte wemos.cc website

Sources

https://www.wemos.cc/en/latest/s2/s2_mini.html
https://platformio.org/
https://github.com/espressif/arduino-esp32
https://github.com/sharandac/My-TTGO-Watch/issues/328
https://github.com/platformio/platform-espressif32/issues/679
https://docs.platformio.org/en/latest/platforms/espressif32.html
https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html