S2 Mini based on ESP32-S2 with the same footprint as the Wemos D1 Mini

Finally, had some spare time to solder some pins and headers onto a ESP32-S2 Mini.
Then to see if it worked... lashed up a SSD1306 OLED panel driven via the I2C bus.

5 Likes

I have just ordered a handful from AliExpress. I am hoping to use them with node-red-mcu-plugin. I have been using D1 Minis, but they can only cope with a very few node red nodes. Not surprisingly.

That sounds interesting, although for me there is a limit as to how many projects I can handle at once - I think it's called "bandwidth". I've decided to try using Micropython for the last set of S2s I bought from AE.

Have you seen the Brachiograph in the Raspberry Pi blog today Dave?
A pen plotter from 2 lollipop sticks, 3 servos and a Pi zero.
It looks great fun but it's lacking a little something ... A Node-red dashboard perhaps.

2 Likes

Hi Dave, I am glad you get your devices working. Although I have had mine for a week or two I haven't had time to 'play' with them. I prefer to use platformIO over Arduino and I have managed to load a basic sketch that blinks the LED. For the life of me I cannot get the serial to work, when I connect and press GPIO0 / RST I get a com port to load code, once loaded I reset again and the basic code runs but I haven't found anyway to get serial output nor have I managed to get it to connect to WiFi. The serial port I used to upload code seems to have dissappeared. Is there anything that needs to be done to get serial over the USB link or maybe on the Tx/Rx pins once code is loaded? I would appreciate any suggestions or maybe code snippets.

Hi Bob,
I've used Thonny 4.0.2 for my initial experiments with the ESP32-S2 Mini.
https://thonny.org/
I reflashed the devices I received from China with the latest version of Micro-Python. There is an option to help you do this when you click the 'Configure interpreter' button/option.

I can just plug the S2-Mini in a USB port and find the port in the 'Configure interpreter' option.

I've not tried to get serial comms working yet - but I have managed to get WiFi and MQTT working.

S2_mini_A

S2_mini_C

Here's a very basic Python script to connect to a home network...

import network

# set up WiFi connection
wifi_ssid = "xxxx"
wifi_password = "xxx"
wifi = network.WLAN(network.STA_IF)
wifi.active(True)
wifi.connect(wifi_ssid, wifi_password)

# wait for connection
while not wifi.isconnected():
    pass

# print connection details
print(wifi.ifconfig())
print("Connected to WiFi network with IP address:", wifi.ifconfig()[0])

print("Disconnecting from WiFi")
wifi.disconnect()

Hi Dave, thanks for the reply. I have never used Python but what you have provided should be enough for me to give it a try. TBH as I am comfortable with C/C ++ and a bit of Javascript in Node-RED I am a bit reluctant to learn another language. That said I must confess it doesn't loo kthat difficult to get the WiFi set up.

Dave,
did you consider CircuitPython? Much easier to include device drivers for a lot of sensors.

This is a listing from ChatGBT of my Python script converted to Arduino code. It looks like just what I've used on some of my Wemos D1 Mini devices in the past. Please let me know if it works for you on the S2.

#include <WiFi.h>

// set up WiFi connection
const char* wifi_ssid = "xxxx";
const char* wifi_password = "xxx";
WiFiClient wifi;

void setup() {
  Serial.begin(9600);

  // Connect to Wi-Fi network
  WiFi.begin(wifi_ssid, wifi_password);
  Serial.print("Connecting to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }
  Serial.println("");

  // Print connection details
  Serial.print("Connected to WiFi network with IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  // Disconnect from Wi-Fi network
  Serial.println("Disconnecting from WiFi");
  WiFi.disconnect();
  
  // Wait 5 seconds before reconnecting
  delay(5000);

  // Reconnect to Wi-Fi network
  Serial.println("Reconnecting to WiFi");
  WiFi.begin(wifi_ssid, wifi_password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }
  Serial.println("");
}

This code uses the WiFi library in Arduino, which is similar to the network module in MicroPython. The code connects to a WiFi network, waits for the connection to be established, prints the IP address, and then disconnects from the network. The loop() function then waits for 5 seconds before reconnecting to the network and repeating the process.

Hi Dave, thanks for the effort you have put in to help me, and yes the code snippet does work. In my inital attempts I had erroneously loaded what I recalled was a basic WiFi, OTA and MQTT set up code. In fact it wasn't it was an overly complicated mess!!!
I have tried the basic snippet several times and it has loaded without having to press any buttons so hopefully I can now develop projects on these devices.

Really pleased to hear it is working for you now.

I've just completed some Python code for one of my ESP32-S2 Minis that does a WiFi scan and then looks through the list to find the AP with the best signal. It ignores any APs that are not in my list, so foreign networks are rejected.

Once it finds the best network it sends details via MQTT to a remote broker (that Node-RED is subscribed to). It repeats this sequence at regular intervals and if a better network is found, then it disconnects from the current one and connects to the better one.

I'll probably published it in "Share Your Projects" once I'm happy with its operation.

2 Likes

That sounds like a useful thing to do. I haven't seen 'share your projects' before.
There does seem to be some odd behaviour on these S2 modules, I can upload code via COM 8 but the serial output appears on COM 3. I know some S2 break out boards have seperate serial comms chips too. I can load code via OTA on one board but not on a second one so I guess I should test all10 of the batch I bought.

Found a bit of a "niggle" that needs further investigation.

For some reason the Python code I've written doesn't connect to all my home networks even though some of them have high signal strength. This morning I used the same Python script on a Wemos D1 Mini and it connects to ALL my networks (as it was intended).

So either there is something different with 'network' in the MicroPython firmware or the design of the radio circuitry is different bwteen the Wemos D1 Mini and the ESP32-S2 Mini.

It will be interesting to hear if anyone else has noticed this issue.

This is the firmware I'm using...
MicroPython v1.19.1-938-g0359aac10 on 2023-03-08; LOLIN_S2_MINI with ESP32-S2FN4R2

MicroPython v1.19.1 on 2022-06-18; ESP module with ESP8266

Edit: I might try a Raspberry Pi Pico W and see how that handles the WiFi detection.

Here's the link (if you need it)...

A bit of bed time reading! Thanks for the link. I had hoped these S2 modules could be my new prefered device and I certainly need to do much more testing to see how reliable they are.

Just lashed-up a RPi-Pico-W and can report it can "see" all my networks, so it behaves just like the Wemos D1 Mini as far as WiFi is concerned.

Firmware is... MicroPython v1.19.1-782-g699477d12 on 2022-12-20; Raspberry Pi Pico W with RP2040

1 Like

Finally I can post a reply on something I know a little bit about :slight_smile:
Did you use ‘Serial.begin(115200);’ in setup() and ‘monitor_speed=115200’ in platformio.ini?

Until now I use all kinds of esp8266, mostly esp12 and for simple things esp01, but for developing I connect a nodeMCU (on a small breadboard) to my laptop and use vscode/platformio on the couch.

All sending/receiving data to/from Node Red via a broker, from light switches, intelligent energy meters to brewing vessel and bubble meter.

Hi, thanks for your reply. I do use the settings you mention. I have used Platform IO for a couple of years without any problems. I have also used all manner of ESP8266 and ESP32's, again, without problems I couldn't solve. However, these ESP32-S2 Mini's I have are different in that they don't have an onboard dedicated serial coms processor like a cp2102. They are also not genuine Wemos/Lolin devices.
I have tried two different boards on the same USB cable, to load ('flash') code PIO uses COM8, however, to see the serial output I have to use COM3 and that is what shows up in device manager on my Windows 10 PC. I have never seen a device use dua lserial port like that before. Additionally one device will flash by OTA, one won't. The initial code I loaded broke something because the serial port, COM3, would oscillate between connected / disconnected. I will investiage further but I think it was some fancy WiFi connect code that broke them. The code Dave provided worked perfectly as does my normal WiFi connect code.