ESP32S2 WiFI connection problems

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
vrbataj
Posts: 3
Joined: Wed Jun 09, 2021 1:15 pm

ESP32S2 WiFI connection problems

Post by vrbataj » Wed Jun 09, 2021 1:33 pm

Hi,
I have problems with WiFi connection on boards with ESP32S2. I have two types of ESP boards, Espressif ESP32-S2-Saola-1R and my own boards (custom design). I use fresh version of Micropython GENERIC-S2 (clone from Github) compiled with IDF 4.3. All technologies that need SPI, I2C, GPIO inputs/outpust work well, but I have problems with Wifi comunication. Connection to wifi works fine, but subsequent communication does not work.

Simple log with upip install for example :

connecting to network...
network config: ('192.168.1.109', '255.255.255.0', '192.168.1.1', '192.168.1.1')
7c:df:a1:17:a9:b8
Installing to: /lib/
Error: Unable to resolve micropython.org (no Internet?)


on all my ESP8266, ESP32 boards the same code works fine :shock:

Do you have any idea, please ???

User avatar
Roberthh
Posts: 2758
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32S2 WiFI connection problems

Post by Roberthh » Wed Jun 09, 2021 1:57 pm

It could be a RAM exhaustion problem. That was reported earlier. Try to reduce the size of RAM allocated for the heap. That happens in main.c at about line 123. Change that to:

size_t mp_task_heap_size = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT) - (12 * 1024);

There is a similar code at line 118, which is excuted by a SPIRAM build on a non-SPIRAM device.

vrbataj
Posts: 3
Joined: Wed Jun 09, 2021 1:15 pm

Re: ESP32S2 WiFI connection problems

Post by vrbataj » Wed Jun 09, 2021 2:38 pm

Thank you very much !
With this memory heap setting the program collapsing after interface was activate ....

import network
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)


crash.....

User avatar
Roberthh
Posts: 2758
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32S2 WiFI connection problems

Post by Roberthh » Wed Jun 09, 2021 3:57 pm

That's strange. I had to do exactly that to get it running. What is reported by gc.mem_free()? Maybe now the heap os too small. You could try other reduction sizes, like 8 * 1024. This change just leaves some more RAM for the non-heap malloc, which is required by the IP stack. If malloc fails, it just silently refuses to work.

vrbataj
Posts: 3
Joined: Wed Jun 09, 2021 1:15 pm

Re: ESP32S2 WiFI connection problems

Post by vrbataj » Thu Jun 10, 2021 11:01 am

Value 10*1024 seems to be ok. I have to do more tests, but the current situation looks much better. ESP is connected to WiFi, ESP is connected a subscribbed to MQTT broker, sends and receives MQTT messages ;)

davef
Posts: 303
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP32S2 WiFI connection problems

Post by davef » Thu Jun 10, 2021 7:58 pm

Roberthh,
That was reported earlier
I had a look for specific ESP32S2 issues and couldn't find one about RAM exhaustion.

Does this only affect the ESP32S2?

Thanks

User avatar
Roberthh
Posts: 2758
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32S2 WiFI connection problems

Post by Roberthh » Thu Jun 10, 2021 8:16 pm

It affects only the ESP32S2, because it has less RAM than the standard ESP32.
The discussion took place at the MicroPython Git repository, e.g. https://github.com/micropython/micropython/issues/7214 or https://github.com/micropython/micropython/pull/7163

davef
Posts: 303
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP32S2 WiFI connection problems

Post by davef » Thu Jun 10, 2021 9:16 pm

Thank you.

Post Reply