Oserror wifi internal error

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting a MQTTClient with an already working wifi connection fails with Wifi internal error. #59

Starting a MQTTClient with an already working wifi connection fails with Wifi internal error. #59

Comments

I discovered this while having the webrepl start in my boot.py, earlier than the MQTTClient start.
Running on micropython 1.16-135 on ESP32.

mac --> 24:0a:c4:ec:ab:1c connecting to network. ('192.168.0.28', '255.255.255.0', '192.168.0.1', '12.123.123.123') WebREPL daemon started on ws://192.168.0.28:8266 Started webrepl in normal mode E (4600131) wifi:sta is connecting, return error WebREPL daemon started on ws://192.168.0.28:8266 Started webrepl in normal mode Traceback (most recent call last): File "main.py", line 69, in File "uasyncio/core.py", line 1, in run File "uasyncio/core.py", line 1, in run_until_complete File "uasyncio/core.py", line 1, in run_until_complete File "main.py", line 50, in main File "mqtt_as.py", line 485, in wifi_connect OSError: Wifi Internal Error MicroPython v1.16-135-gaecb697c7-dirty on 2021-07-28; ESP32 module with ESP32 Type "help()" for more information. >>> 

If I override the default wifi_connect, it works fine:

class MyMQTTClient(MQTTClient): async def wifi_connect(self): if not self._sta_if.isconnected(): return await super().wifi_connect() 

The text was updated successfully, but these errors were encountered:

Источник

MicroPython Forum (Archive)

Have been trying to get an application to continue running even when the WiFi
fails to connect. v1.18 Generic.
Error message is:

OSError: WiFi internal error (something like this as I can't repeat it)

If I run the following connect() and the WiFi does not connect I make
sta_if.active(False), but this still seems to leave the WiFi in limbo . sometimes.

Only a hard-reset allows me to run the application again.

import network import utime import machine import config sta_if = network.WLAN(network.STA_IF) # create station interface ap_if = network.WLAN(network.AP_IF) # create access-point interface def connect(): count = 0 # disconnects AP if it is up ap_if.active(False) # de-activate the AP interface utime.sleep(1) if not sta_if.isconnected(): print('connecting to hotspot. ') sta_if.active(True) sta_if.ifconfig((config.WiFi_device, '255.255.255.0', config.gateway, '8.8.8.8')) sta_if.connect(config.hotspot, config.password) while (count < 5): count += 1 if (sta_if.isconnected()): count = 0 print (' network config:', sta_if.ifconfig()) break print ('.', end = '') utime.sleep(1) if (count == 5): # disconnect or you get errors if (sta_if.isconnected()): # maybe not necessary sta_if.disconnect() sta_if.active(False) # this is necessary count = 0 # reset count utime.sleep(1)

Is there something else I can do to make sure that the WiFi is ready to try and reconnect
say one minute later?

Читайте также:  Установщик вай фай номер

Re: WiFi re-connect problem

Post by tepalia02 » Thu Apr 21, 2022 9:44 am

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

Re: WiFi re-connect problem

Post by davef » Thu Apr 21, 2022 10:24 am

My only half-baked theory is that machine.reset() does not do as good a job as a hard-reset, ie the EN button, for getting the WiFi to its initial or default state.

Shards Posts: 39 Joined: Fri Jun 25, 2021 5:14 pm Location: Milton Keynes, UK

Re: WiFi re-connect problem

Post by Shards » Thu Apr 21, 2022 11:09 am

If you want the program to continue to run you need to trap the 'Wifi Internal Error' with a try: except: block. you can then ignore the error and try connecting again. Certainly not best practice but I fairly consistently get the error, sometimes multiple times, and the code below gets it connected. Once connected it seems reasonably stable. This is my basic test code:

import network from net_config import SSID, PSWD from time import sleep net = network.WLAN(network.STA_IF) net.active(True) while True: try: net.connect(SSID,PSWD) except OSError as e: print(e) sleep(1) if net.isconnected(): print('Connected') break 

Re: WiFi re-connect problem

Post by marcidy » Thu Apr 21, 2022 4:56 pm

I would explicitly call disconnect() before calling active(False). disconnect() resets some internal micropython state, and stops the interface from making connection attempts.

what you have will never run if the station never connects:

 if (sta_if.isconnected()): # maybe not necessary sta_if.disconnect() 

so just get rid of the "if" statement. "isconnected()" doesn't cover "trying to connect but not yet connected".

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

Re: WiFi re-connect problem

Post by davef » Thu Apr 21, 2022 8:04 pm

Thank you. I will modify it as you suggest. My real connect() method has some error logging in it so I will be able to see if it improves the situation.

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

Re: WiFi re-connect problem

Post by davef » Sun Apr 24, 2022 8:53 pm

Think I finally nailed this problem.

import network from wifi_functions import connect from wifi_functions import disconnect import utime sta_if = network.WLAN(network.STA_IF) # create station interface while True: connect() utime.sleep(5) disconnect() print ('disconnected') utime.sleep(5) 
import network import utime import machine import config sta_if = network.WLAN(network.STA_IF) # create station interface ap_if = network.WLAN(network.AP_IF) # create access-point interface def connect(): count = 0 # disconnects AP if it is up ap_if.active(False) # de-activate the AP interface utime.sleep(1) if not sta_if.isconnected(): print('connecting to hotspot. ') sta_if.active(True) sta_if.ifconfig((config.WiFi_device, '255.255.255.0', config.gateway, '8.8.8.8')) sta_if.connect(config.hotspot, config.password) while (count < 5): count += 1 if (sta_if.isconnected()): count = 0 print (' network config:', sta_if.ifconfig()) break print ('.', end = '') utime.sleep(1) if (count == 5): try: with open('errors.txt', 'a') as outfile: outfile.write('failed to connect' + '\n') except OSError: pass # disconnect or you get errors disconnect() count = 0 # reset count utime.sleep(1) def disconnect(): # disconnects STA, even if it is not connected sta_if.disconnect() # This is line 59 sta_if.active(False) utime.sleep(1)
MPY: soft reboot connecting to hotspot. . Traceback (most recent call last): File "main.py", line 2, in File "test.py", line 12, in File "wifi_functions.py", line 59, in disconnect OSError: Wifi Not Started MicroPython v1.18 on 2022-01-17; ESP32 module with ESP32 Type "help()" for more information.

I guess it is not a surprise that trying to disconnect when you are NOT connected
might be an issue. Re-reading Shards response I thought I would put line 59
in a try . except block.

def disconnect(): try: # disconnects STA, even if it is not connected sta_if.disconnect() except: pass sta_if.active(False) utime.sleep(1)

Voila!! No more . OSError: Wifi Not Started

Читайте также:  Настроить вай фай подключение виндовс 10

When running test.py if you do a Ctrl C during the connection attempt, then another
CtrlD I get:

MPY: soft reboot connecting to hotspot. E (63083) wifi:sta is connecting, return error Traceback (most recent call last): File "main.py", line 2, in File "test.py", line 10, in File "wifi_functions.py", line 24, in connect OSError: Wifi Internal Error MicroPython v1.18 on 2022-01-17; ESP32 module with ESP32 Type "help()" for more information
sta_if.connect(config.hotspot, config.password)

should be a try . except block. But that was what Shards recommended in the first place!!

I hope this is another step towards getting reliable WiFi access.

Thanks to both of you for your suggestions.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 "OSError: Wifi Internal Error" #2713

ESP32 "OSError: Wifi Internal Error" #2713

Comments

Hello, after several hours of testing without results, I turn to you, it is impossible for me to connect my esp32 (micropython) to my wifi network. Everything was working a few days ago, but I modified my script, it didn't didn't work anymore, and since then, even putting back my original script, it doesn't work anymore.

Here is my original script:

import socket from machine import Pin import network import esp esp.osdebug(None) import gc gc.collect() sta_if = network.WLAN(network.STA_IF); sta_if.active(True) sta_if.scan() # Scan for available access points sta_if.connect(". ", ". ")# Connect to an AP sta_if.isconnected() # Check for successful connection print('network config:', sta_if.ifconfig()) led = Pin(2, Pin.OUT) 
import socket from machine import Pin import network import esp esp.osdebug(None) import gc gc.collect() ssid = '. ' password = '. ' sta_if = network.WLAN(network.STA_IF) if not sta_if.isconnected(): print('connecting to network. ') sta_if.active(True) sta_if.connect(ssid, password) while not sta_if.isconnected(): pass print('network config:', sta_if.ifconfig()) led = Pin(2, Pin.OUT) 

I always have the OSError: Wifi Internal Error

Читайте также:  Yota точка доступа wifi со смартфона

MPY: soft reboot E (781062) wifi:sta is connecting, return error Traceback (most recent call last): File "boot.py", line 14, in OSError: Wifi Internal Error
MPY: soft reboot E (781062) wifi:sta is connecting, return error Traceback (most recent call last): File "boot.py", line 19, in OSError: Wifi Internal Error

Sorry if my English is not good, I'm French and not the best in English.

The text was updated successfully, but these errors were encountered:

Источник

Oserror wifi internal error

Unavailable for now: We're participating in the Reddit Blackout. ESP32 is a series of low cost, low power system on a chip microcontrollers with integrated Wi-Fi and dual-mode Bluetooth. The ESP32 series employs either a Tensilica Xtensa LX6, Xtensa LX7 or a RiscV processor, and both dual-core and single-core variations are available. It includes in-built antenna switches, RF balun, power amplifier, low-noise receive amplifier, filters, and power management modules as well.

I am getting started using the ESP32 with Thonny IDE, and I keep running into a problem where I get

OSError: Wifi Internal Error

whenever I run the code. I have tried this with multiple different tutorial projects to no avail, and searching the error itself doesn't produce results that hit those exact keywords.

I started with the BME280 tutorial here:

When I first tried the project I didn't have a BME280 so I rewrote part of the code to utilize a push button instead and have it send an email when it was pushed. I was still receiving the error, but I found that if I was holding the button down when I ran the code it would send the email and also give me the error. I ordered a BME280 and have run the code as written, and get the error with no email triggered.

I continued searching, and found this stack exchange question:

so I ran the answers code. When it ran it compiled and ran, but gave no output, just

I also tried the code listed in "MicroPython Programming with ESP32" by Rui Santos,

try: import usocket as socket except: import socket import network import esp esp.osdebug(None) import gc gc.collect() ssid = "MY_NETWORK" password = "MY_PASSWORD" station = network.WLAN(network.STA_IF) station.active(True) station.connect(ssid, password) while station.isconnected() == False: pass print("Connection successful") print(station.ifconfig)

and the Wifi Internal Error persists. I have tried it both on my at home router credentials and on my phone's hotspot.

I am at a bit of a loss as to how to track down what is going wrong; I have flashed the board with the current bin file from MicroPython website, as per the tutorials; without any internet hits for troubleshooting I don't know enough to better narrow down what could be happening.

Any help is appreciated. Thank you!

Источник

Оцените статью
Adblock
detector