Esp32 s2 details
In this article, I will present the esp32 s2 family of devices, these devices are under development and some parts may be modified in the future.
In the past 2019 new ESP32 board was born, the s2 family. At first, only the ESP-IDF platform was supported, but now the version for the Arduino ecosystem is also quite mature, although the official version for the Arduino IDE has not yet been released.
On the ESP32-S2, there is no Bluetooth or Ethernet MAC, but it includes new interesting features in order to be more attractive to the IoT device market.
It has a lower cost than the ESP32 and has USB-OTG, LCD, and camera support.
The ESP32-S2 can also dynamically turn off the Wi-Fi transceiver when not in use to save power.
It also now features a powerful single core, so many programming problems such as CPU resource management are solved.
Here the development modules ESP32 S2 Saola 1 - Ai-thinke ESP-12K - ESP32 S2 Mini
Specs
Remember that there are many variations of this device, some have specialized functions, but here we put a basic description of the specifications.
- CPU and Memory
- Xtensa® single-core 32-bit LX7 microprocessor, up to 240 MHz
- 128 KB ROM
- 320 KB SRAM
- 16 KB SRAM in RTC
- Embedded flash (None, 2Mb or 4Mb)
- SPI/QSPI/OSPI supports multiple flash and external RAM chips
- Wi-Fi
- IEEE 802.11 b/g/n-compliant
- Supports 20 MHz, 40 MHz bandwidth in 2.4 GHz band
- Single-band 1T1R mode with data rate up to 150 Mbps
- WMM
- TX/RX A-MPDU, RX A-MSDU
- Immediate Block ACK
- Fragmentation and defragmentation
- Advanced Peripheral Interfaces
- 43 × programmable GPIOs
- 2 × 12-bit SAR ADCs, up to 20 channels
- 2 × 8-bit DAC
- 14 × touch sensing IOs
- 4 × SPI
- 1 × I2S
- 2 × I2C
- 2 × UART
- RMT (TX/RX)
- LED_PWM, up to 8 channels
- 1 × full-speed USB OTG
- 1 × temperature sensor
- 1 × DVP 8/16 camera interface, implemented using the hardware resources of I2S
- 1 × LCD interface (8-bit serial RGB/8080/6800), implemented using the hardware resources of SPI2
- 1 × LCD interface (8/16/24-bit parallel), implemented using the hardware resources of I2S
- Security
- Secure boot
- Flash encryption
- 4096-bit OTP, up to 1792 bits for users
- Cryptographic hardware acceleration:
- AES-128/192/256 (FIPS PUB 197)
- Hash (FIPS PUB 180-4)
- RSA
- Random Number Generator (RNG)
- HMAC
- Digital signature
Pinouts
This device is very powerful, and you can see there are capacitive touch pins, more than one UART, and various analog pins.
ESP32 S2 Saola 1MI
Equipped with ESP32-S2-WROVER-I, there is 2 version of this board, the 1M and 1MI. The only difference is that the 1MI has an IPEX antenna.
This board has three add-ons to the basic configuration: 4MB SPI flash, 2MB PSRAM and an addressable RGB LED (WS2812).
ESP32 S2 Saola 1MI detail and high resolution pinout image
Ai-thinker ESP-12K
Ai-thinker uses an SoC from Ensink Technology that has the same specs as ESP32-S2-WROVER, this board has a simple status led.
There are 2 versions of this board:
- ESP-12K(00) without PSRAM
- ESP-12K(08) with 8MByte PSRAM
Ai-thinker ESP 12K ESP32 S2 pinout high resolution image
Arduino IDE configuration (Using the updated JSON dev)
Add boards to the Arduino IDE
First, you need to add the esp32 URL descriptor to your IDE
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
Go to File -> Preferences
and add the URL to “Additional Boards Manager URLs
“
Then you have to add the new board to the Board Manager
The card to select is esp32
It is important that you choose a version of the esp32 core> = 2.
Arduino IDE configuration (manual installation of esp32s2 branch) (Deprecated)
The branch was changed in esp32c3 or Master no more esp32s2.
As you can understand from the title, there is not yet a simplified procedure, so we will have to take several steps to be able to use our esp32 s2 on the Arduino IDE.
Install standard ESP32 cards from the IDE card manager
First, you must add the esp32 URL descriptor to your IDE
http://arduino.esp8266.com/stable/package_esp8266com_index.json
https://dl.espressif.com/dl/package_esp32_index.json
Go to File –> Preferences and add the URL on “Additional Boards Manager URLs”
Then you must add a new board in Boards Manager
The board to select is esp32
Download the manager from the ESP32s2 branch
The branch was changed in esp32c3 and master no more esp32s2.
But now we have installed the stable branch of the master on the IDE and there is no esp32 s2 implementation.
So you must download this branch
ESP32s2 GitHub branch or Master
then you have to open the path where the Arduino IDE stores its preferences:
Now find the esp32 implementation. In my case it’s the folder
<Arduino IDE preferences path>\packages\esp32\hardware\esp32\1.0.4
the result becomes
C:\Users\renzo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4
First create a copy of the folder packages\esp32 if you want revert the operation in the future.
Than open the zip of the branch and copy the same file and folder to the esp32 path
Now you can find the ESP32s2 Dev Kit implementation on your Arduino IDE:
But you can’t compile and upload nothing because you need 2 other updated tool.
Download xtensa-esp32s2-elf
But nothing can work this because this board not use xtensa-esp32-elf but xtensa-esp32s2-elf, you must download It from here:
The version for my operating system, Windows 10, is win64.
Download ESPTools
And you need the lastest version of esptool, and you can check the last version from here.
The first version that support ESP32 s2 is 3.0.0, and we are going to download that version from this link.
Put all togeder
Now you must copy in the
<Arduino IDE preferences folder>\packages\esp32\hardware\esp32\1.0.4\tools
this two tools.
Now your IDE work correctly, I’m moved.
Your first ESP32 s2 sketch
ESP32 S2 Saola 1MI
Now we are going to manage the addressable RGB led (Addressable RGB LED (WS2812), driven by GPIO18) installed on the board.
You need to install Adafruit_NeoPixel.h
library from libraries manager.
Here is the simple sketch:
/*
* Here a simple sketch to test the upload of ESP32 S2 Saola 1MI.
* The addressable RGB LED (WS2812), driven by GPIO18 need
* Adafruit NeoPixel library
* by Mischianti Renzo <https://mischianti.org>
*
* https://mischianti.org/
*
*/
#include <Adafruit_NeoPixel.h>
#define PIN 18
#define NUMPIXELS 1
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
enum {NONE, RED, GREEN, BLUE};
int ledColor = NONE;
void setup()
{
pixels.begin();
}
void loop()
{
switch (ledColor) {
case NONE:
pixels.setPixelColor(0, pixels.Color(0, 0, 0));
pixels.show();
break;
case RED:
pixels.setPixelColor(0, pixels.Color(20, 0, 0));
pixels.show();
break;
case GREEN:
pixels.setPixelColor(0, pixels.Color(0, 20, 0));
pixels.show();
break;
case BLUE:
pixels.setPixelColor(0, pixels.Color(0, 0, 20));
pixels.show();
break;
default:
break;
}
ledColor++;
if (ledColor == 4) {
ledColor = NONE;
}
delay(1000);
}
Ai-thinker ESP-12K
Now a blink sketch for this microcontroller:
/*
* Here a simple sketch to test the upload of Ai-thinker ESP-12K.
* by Mischianti Renzo <https://mischianti.org>
*
* https://mischianti.org/
*
*/
#define LED_BUILTIN 2
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Both custom and standard installations running on your Arduino IDE
Many people ask me how to switch between the new and old installation easily. Here is a small guide.
Rename the new esp32s2 installation inside <Arduino IDE preferences folder>/preferences
from esp32
in esp32s2
and the “old” standard directory in esp32
.
Now you have the previous installation in esp32
(like normal) and esp32s2
the GitHub installation.
Add to “Additional Boards Manager URLs” a fake URL like
https://dl.espressif.com/dl/package_esp32s2_index.json
Now duplicate from <Arduino IDE preferences folder>
the file package_esp32_index.json
and rename It in package_esp32s2_index.json
.
In the new file change name
in esp32s2
like so:
{
"packages": [
{
"name": "esp32s2",
"maintainer": "Espressif Systems",
Now go to
<Arduino IDE preferences folder>\packages\esp32s2\hardware\esp32\1.0.4
open file platform.txt and change the first line from name=ESP32 Arduino
in name=ESP32s2 Arduino
. Restart the IDE.