ESP32-C3 wifi network error

Breakout boards, sensors, Drawdio, Game of Life, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
JeremyLaurenson
 
Posts: 15
Joined: Tue Feb 08, 2022 12:13 pm

ESP32-C3 wifi network error

Post by JeremyLaurenson »

I have 10 QT PY ESP32-C3 boards and I have tried both Micropython and Arduino builds on them.
These boards seem unable to relibly connect or stay connected to Wifi:

Code: Select all

while True:
    try:
        np[0] = (128, 0, 0, 0)
        np.write()
        net.connect(ssid, password)
    except OSError as e:
        np[0] = (128, 0, 0, 0)
        np.write()
        print(e)
    sleep(1)
    if net.isconnected():
        print('Connected')
        np[0] = (0,128, 0, 0)
        np.write()
        break
and what I see is most times is:

Code: Select all

MPY: soft reboot
esp32, esp32, 1.19.1, v1.19.1 on 2022-06-18, ESP32C3 module with ESP32C3
Wifi Internal Error
Wifi Internal Error
Wifi Internal Error
Wifi Internal Error
Wifi Internal Error
Wifi Internal Error
Wifi Internal Error
Wifi Internal Error
Wifi Internal Error
Connected
('10.0.1.186', '255.255.255.0', '10.0.1.1', '208.67.222.222')
Sometimes, however (2 boards out of 10 as I type this) I see the board never connect until I re-upload the python file, and that *sometimes* fixes it.

This is a huge problem for me right now as I play whack-a-mole witht hese things falling off the network.

(see: https://github.com/orgs/micropython/discussions/10524)

User avatar
bidrohini
 
Posts: 196
Joined: Thu Oct 20, 2022 10:03 am

Re: ESP32-C3 wifi network error

Post by bidrohini »

That's really not expected from adafruit boards. Hope they will test the QT PY ESP32-C3 boards and solve this problem.

User avatar
JeremyLaurenson
 
Posts: 15
Joined: Tue Feb 08, 2022 12:13 pm

Re: ESP32-C3 wifi network error

Post by JeremyLaurenson »

Code: Select all

try:
    import usocket as socket
except:
    import socket

from time import sleep
import machine
import neopixel
import time
import os
import network

import esp
esp.osdebug(None)

import gc
gc.collect()



print(', '.join(os.uname()))

np = neopixel.NeoPixel(machine.Pin(2), 1)

np[0] = (128, 128, 0, 0)
np.write()
time.sleep(3)
np[0] = (128, 0, 0, 0)
np.write()



ssid = 'LAURENSON'
password = 'mypasswordgoeshere'

net = network.WLAN(network.STA_IF)
net.active(False)
sleep(5)
net.active(True)
if (net.isconnected()): #  maybe not necessary
    net.disconnect()


while True:
    try:
        np[0] = (128, 0, 0, 0)
        np.write()
        netstat=net.status()
        if netstat==1000:
            net.connect(ssid, password)
        else:
            print("Net status is " + str(netstat))
    except OSError as e:
        np[0] = (128, 0, 0, 0)
        np.write()
        print(e)
    sleep(1)
    if net.isconnected():
        print('Connected')
        np[0] = (0,128, 0, 0)
        np.write()
        break

print(net.ifconfig())


And the output:

Code: Select all

MPY: soft reboot
esp32, esp32, 1.19.1, v1.19.1 on 2022-06-18, ESP32C3 module with ESP32C3
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001
Net status is 1001

I really need some help nailing this or I have to switch to different boards.

User avatar
adafruit_support_mike
 
Posts: 65812
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32-C3 wifi network error

Post by adafruit_support_mike »

For Wifi connections, the question isn't "will the connection drop?" but "when will the connection drop?"

If you need long-term connections, you need to add tests to your code that check the network status and reconnects if necessary before doing anything that will hang or fail without a working network connection.

User avatar
JeremyLaurenson
 
Posts: 15
Joined: Tue Feb 08, 2022 12:13 pm

Re: ESP32-C3 wifi network error

Post by JeremyLaurenson »

Understood - I have a watchdog that resets the board if I dont get network traffic for 10 minutes... but let me be clear as to my issue:

I have several (10) Adafruit QT Py ESP32-C3 WiFi Dev Boards and when they don't connect, they don't connect with gusto - in fact the one I have on my bench now NEVER connects. When they disconnect there seems to be a 30% chance that they'll need to be monkeyed with (re-flash, re-upload- disconnect power and futs in general till it comes back). Theyre horrifically unreliable connecting, and the one I have here is 8 feet from an AP.

Code: Select all

import network
import utime
import machine

sta_if = network.WLAN(network.STA_IF)

def connect():
    count = 0

    sta_if.active(True)

    utime.sleep(0.1) #  this could be important, recent posting by robert-hh

 #  seems more reliable to start with a fresh connect()
    if sta_if.isconnected():
        sta_if.disconnect()
        print (f'started in the connected state, but now disconnected')
    else:
        print (f'started in the disconnected state')

    utime.sleep(0.1) #  this could be important

    if not sta_if.isconnected():
        print (f'connecting to hotspot...')
        utime.sleep(0.1)

        try:
#            sta_if.ifconfig((config.WiFi_device, '255.255.255.0', config.gateway, '8.8.8.8'))
#  another recent posting suggest that this should go after the call to sta_if.connect()
            sta_if.connect("LAURENSON", "sekret is here")
        except OSError as error:
            try:
                with open('errors.txt', 'a') as outfile:
                    outfile.write(str(error) + '\n')
            except OSError:
                pass

        while (count < 10):
            count += 1

            if (sta_if.isconnected()):
                count = 0

                print (f'network config: {sta_if.ifconfig()}')

                break

            print (f'. ')
            utime.sleep(1)


    if (count == 10):
        try:
            with open('errors.txt', 'a') as outfile:
                outfile.write('failed to connect after 10 tries' + '\n')
        except Exception as e:
            pass

        disconnect() # or you could get errors
        print (f'machine reset')
        utime.sleep(0.1)

        machine.reset() #  start from scratch


    rssi = sta_if.status('rssi')
    print (f'RSSI =  {rssi} dBm')
    utime.sleep(0.1)

    if ((rssi < -95) or (rssi == 0)):
        print (f'signal level is below -95dBm')
        utime.sleep(0.1)

        disconnect() # or you could get errors
        print (f'machine reset')
        utime.sleep(0.1)

        machine.reset() #  start from scratch


def disconnect():

    sta_if.disconnect()
    sta_if.active(False)
    

connect()
and the result (with known good code, running [for the moment] on 8 other devices) is that this device never connects.

Code: Select all


MPY: soft reboot
started in the disconnected state
connecting to hotspot...
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
machine reset
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0xc (RTC_SW_CPU_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
Saved PC:0x403806e6
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0xe3c
load:0x403ce000,len:0x6dc
load:0x403d0000,len:0x28ac
entry 0x403ce000
started in the disconnected state
connecting to hotspot...
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
machine reset
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0xc (RTC_SW_CPU_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
Saved PC:0x403806e6
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0xe3c
load:0x403ce000,len:0x6dc
load:0x403d0000,len:0x28ac
entry 0x403ce000
started in the disconnected state
connecting to hotspot...
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
machine reset
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0xc (RTC_SW_CPU_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
Saved PC:0x403806e6
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0xe3c
load:0x403ce000,len:0x6dc
load:0x403d0000,len:0x28ac
entry 0x403ce000
started in the disconnected state
connecting to hotspot...
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
machine reset
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0xc (RTC_SW_CPU_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
Saved PC:0x403806e6
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0xe3c
load:0x403ce000,len:0x6dc
load:0x403d0000,len:0x28ac
entry 0x403ce000



User avatar
JeremyLaurenson
 
Posts: 15
Joined: Tue Feb 08, 2022 12:13 pm

Re: ESP32-C3 wifi network error

Post by JeremyLaurenson »

FWIW, some feedback I got:

On my ESP32 _WROOM dev boards I always do two mods:

a 10uF electro across the EN button, which is not relevant to this issue and
a 1000uF LowESR electro on the 3V3 supply, after the regulator.

current pulses during WiFi init can drop the 3V3 enough to cause issues. I noticed several comments about the regulator chips, ie different parts.

C8 22uF won't do much for current peaks.

User avatar
adafruit_support_mike
 
Posts: 65812
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32-C3 wifi network error

Post by adafruit_support_mike »

JeremyLaurenson wrote: Wed Jan 25, 2023 12:38 pm When they disconnect there seems to be a 30% chance that they'll need to be monkeyed with (re-flash, re-upload- disconnect power and futs in general till it comes back).
None of those measures have any obvious connection to the chip's ability to make a Wifi connection. The radios are managed by firmware vwritten in ROM and running in parallel with your code by the built-in operating system.

I don't dispute your experience, but there's no obvious reason why re-uploading working code would change the way the radios work. And since re-uploading doesn't seem to work deterministically, there's a strong chance the actual problem is something else.

It's more likely there's some radio interference at the location where you're working. Try moving the boards to other locations and see if they behave differently there.

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”