WiFi Stopped working - guidance troubleshooting

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
anant479
 
Posts: 5
Joined: Tue Nov 16, 2021 6:10 pm

WiFi Stopped working - guidance troubleshooting

Post by anant479 »

Hi - I am using a Feather ESP32-S2 to run neopixels. I have set up the feather to connect to wifi and get the internet time so the lights run at a certain time of the day.

Recently the Wifi has stopped working. I get the following error:
------------------------
Connecting to MyWiFi
Traceback (most recent call last):
File "code.py", line 106, in <module>
ConnectionError: No network with that ssid

Code done running.
-----------------------

I have verified on another Feather that the wifi is correct and the other device is connecting using the same secrets file


I have done a factory reset, reinstalled and I still get the wifi error. if I remove the wifi related code then everything runs fine.

Would love some guidance on:

1. How do I troubleshoot the wifi module to see if thats the problem?
2. If it is a bad wifi module how do I check if it is software or hardware
3. How to fix :-)

Thanks for the help!

Here is the code:
"""CircuitPython Essentials NeoPixel example"""
import time
import board
import adafruit_ntp
import rtc


# For internet
import ipaddress
import ssl
import wifi
import socketpool
import adafruit_requests


# For Adafruit IO
import busio
from digitalio import DigitalInOut
from adafruit_esp32spi import adafruit_esp32spi
from adafruit_esp32spi import adafruit_esp32spi_wifimanager


from rainbowio import colorwheel
import neopixel

# Definitions For the neopixel
pixel_pin = board.A1
num_pixels = 30
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=1, auto_write=False)


def color_chase(color, wait):
for i in range(num_pixels):
pixels = color
time.sleep(wait)
pixels.show()
time.sleep(0.5)


def rainbow_cycle(wait):
for j in range(255):
for i in range(num_pixels):
rc_index = (i * 256 // num_pixels) + j
pixels = colorwheel(rc_index & 255)
pixels.show()
time.sleep(wait)

def Run_Lights():
# Author: Anant Gairola
# Date: 2022-11-05
# Module added to run lights
color_chase(RED, 0.2) # Increase the number to slow down the color chase
color_chase(YELLOW, 0.2)
color_chase(GREEN, 0.2)
color_chase(CYAN, 0.2)
color_chase(BLUE, 0.2)
color_chase(PURPLE, 0.2)


RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
PINK = (227, 28, 121)
ORANGE = (255, 83, 73)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)

TUNGSTEN = (255, 214, 179) # 2600 KELVIN
HALOGEN = (255, 241, 224) # 3200 KELVIN
CARBONARC = (255, 250, 244) # 5200 KELVIN
HIGHNOONSUN = (255, 255, 251) # 5400 KELVIN
DIRECTSUN = (255, 255, 255) # 6000 KELVIN
OVERCASTSKY = (201, 226, 255) # 7000 KELVIN
CLEARBLUE = (64, 156, 255) # 20000 KELVIN

# STUFF FOR WIFI CONNECT

# URLs to fetch from
TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"
JSON_QUOTES_URL = "https://www.adafruit.com/api/quotes.php"
JSON_STARS_URL = "https://api.github.com/repos/adafruit/circuitpython"

# Get wifi details and more from a secrets.py file
try:
from secrets import secrets
except ImportError:
print("WiFi secrets are kept in secrets.py, please add them there!")
raise

print("ESP32-S2 WebClient Test")

print("My MAC addr:", [hex(i) for i in wifi.radio.mac_address])

print("Available WiFi networks:")
for network in wifi.radio.start_scanning_networks():
print(
"\t%s\t\tRSSI: %d\tChannel: %d"
% (str(network.ssid, "utf-8"), network.rssi, network.channel)
)
wifi.radio.stop_scanning_networks()

print("Connecting to %s" % secrets["ssid"])
wifi.radio.connect(secrets["ssid"], secrets["password"])
print("Connected to %s!" % secrets["ssid"])
print("My IP address is", wifi.radio.ipv4_address)

ipv4 = ipaddress.ip_address("8.8.4.4")
print("Ping google.com: %f ms" % (wifi.radio.ping(ipv4) * 1000))

pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())

print("Fetching text from", TEXT_URL)
response = requests.get(TEXT_URL)
print("-" * 40)
print(response.text)
print("-" * 40)

print("Fetching json from", JSON_QUOTES_URL)
response = requests.get(JSON_QUOTES_URL)
print("-" * 40)
print(response.json())
print("-" * 40)

print()

print("Fetching and parsing json from", JSON_STARS_URL)
response = requests.get(JSON_STARS_URL)
print("-" * 40)
print("CircuitPython GitHub Stars", response.json()["stargazers_count"])
print("-" * 40)

print("done")


# START CODE FOR GET WEATHER
# Use cityname, country code where countrycode is ISO3166 format.
# E.g. "New York, US" or "London, GB"
LOCATION = secrets["timezone"]

# Set up where we'll be fetching data from
DATA_SOURCE = "http://api.openweathermap.org/data/2.5/weather?q=" + secrets["timezone"]
DATA_SOURCE += "&appid=" + secrets["openweather_token"]

print("Response is", response)

''' -------------------------------------------------------------------------------------'''


# START THE MAIN LOOP

# Checks the internet time
pool = socketpool.SocketPool(wifi.radio)
ntp = adafruit_ntp.NTP(pool, tz_offset=-5)
rtc.RTC().datetime = ntp.datetime

pixels.fill((0, 0, 0))
pixels.show()

while True:
# pixels.fill(HALOGEN)
# pixels.show()
# Increase or decrease to change the speed of the solid color change.
# time.sleep(0.5)

# Starting time stuff I added

# pixels.fill((0, 0, 0))
# pixels.show()

while ((time.localtime().tm_hour >17) and (time.localtime().tm_hour < 19)):
# print("current datetime: Hour", time.localtime().tm_hour)
Run_Lights()

while ((time.localtime().tm_hour >19) or (time.localtime().tm_hour < 17)):
pixels.fill((0, 0, 0))
pixels.show()

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: WiFi Stopped working - guidance troubleshooting

Post by mikeysklar »

How far is you Feather ESP32-S2 (the one that is not connecting) from the AP? Is there an enclosure or anything that could reduce the signal?

What is the result of running the example internet test code with a fresh secrets.py (or that copied from the working feather)?

https://learn.adafruit.com/adafruit-esp ... ernet-test

User avatar
anant479
 
Posts: 5
Joined: Tue Nov 16, 2021 6:10 pm

Re: WiFi Stopped working - guidance troubleshooting

Post by anant479 »

Hi - thanks, that is the internet test file I have been using which was working fine till a week ago and now gives me an error. The location of the feather has not changed and is 20 feet from the router.

The same secrets file and same code is working on another feather (same model) so I strongly suspect it is a hardware issue. Was wondering if there was a way to do any other checks to verify that hypothesis, and then fix it. Or is my only option to just use it as a non-wifi feather :(

Thanks again for the help.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: WiFi Stopped working - guidance troubleshooting

Post by mikeysklar »

The code you had posted had NeoPixel things integrated. Have you been testing with the stock example?

You can update the firmware on the Feather ESP32-S2. I know you have done a factory reset, but the NINA-FW can also be updated.

https://learn.adafruit.com/upgrading-es ... re-3086380

What was the purchase date of this Feather unit?

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”