Wifi error message: Timed Out Waiting For SPI char

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
chagrincyclist
 
Posts: 30
Joined: Sun Jun 07, 2020 10:03 am

Wifi error message: Timed Out Waiting For SPI char

Post by chagrincyclist »

I have a CP program running that's getting hung up in connecting. Initially it connects fine and every 3 minutes the program correctly connects again to get updated information but after a number of hours(sometimes minutes) it stumbles and gets hung up. I tested turning off the wifi and back on, that immediately causes it to fail. So it seems that if it doesn't connect right away, it fails. There error message is "Timing out waiting for SPI char, failed to connect, retrying". It's get stuck in the retry loop (which is not a loop in my program but in the wifi module). Try loop in my program is useless because the program is stuck in the loop in the module, the program never advance to my "except".

To test and fix this issue I a made simple program so I can duplicate the defect. This program trys to get the current time every three minutes and display it on a TFT display.

My CP version is up to date and my AirLift firmware is also up to date. I wrote you in June about this issue but left the project for the summer.

Thanks for taking a look at this!

Code: Select all

# IMPORT MODULES
import board, busio, digitalio, displayio, time, terminalio, gc, sys
from digitalio import DigitalInOut
import adafruit_requests as requests
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
from adafruit_esp32spi import adafruit_esp32spi
from adafruit_esp32spi import adafruit_esp32spi_wifimanager
from user_info2 import user_info2
from time import monotonic as now
#import adafruit_il0373
import adafruit_ili9341
from adafruit_display_text import label
from adafruit_display_shapes.line import Line
from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError
from random import randint
from adafruit_display_shapes.triangle import Triangle
import neopixel
#import supervisor

displayio.release_displays()
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)

tft_dc = board.D10
tft_cs = board.D9
display_bus = displayio.FourWire(
    spi, command=tft_dc, chip_select=tft_cs, reset=board.D6)

display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)

splash = displayio.Group()
display.show(splash)
BLACK = 0xFFFF00
esp32_cs = DigitalInOut(board.A5)
esp32_ready = DigitalInOut(board.A4)
esp32_reset = DigitalInOut(board.A3)
status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2)
# WIFI setup
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
# Create the displayio connection to the display pins
requests.set_socket(socket, esp)
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, user_info2, status_light)
aio_username = user_info2["aio_username"]
aio_key = user_info2["aio_key"]
io = IO_HTTP(aio_username, aio_key, requests)# Write your code here :-)

# Draw a green background
color_bitmap = displayio.Bitmap(320, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x000000  # Bright Green

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)

splash.append(bg_sprite)

text_area1 = label.Label(terminalio.FONT, text="current_time", color=BLACK)
text_area1.line_spacing = 0.9
text_area1.scale = 1
text_area1.anchor_point = (0.5, 0.0)
text_area1.anchored_position = (148, 2)
#splash.append(text_area1)

JSON_URL = "http://worldtimeapi.org/api/ip"
response = None
def connect_to_internet():
    global time_data
    while True:
        try:
            print("Fetching json from", JSON_URL)
            r = wifi.get(JSON_URL)
            time_data = r.json()
            r.close()
            break
        except (ValueError, RuntimeError) as e:
            print("throwing exception\n", e)
            wifi.reset()
            continue
        response = None

        time.sleep(60)

#print(time_data)
while True:

    connect_to_internet()
    print(time_data["datetime"])
    text_area1.text = time_data["datetime"]
    splash.append(text_area1)
    display.show(splash)
    display.refresh()
    time.sleep(180)

    splash.remove(text_area1)

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

Re: Wifi error message: Timed Out Waiting For SPI char

Post by mikeysklar »

Which controller board, Circuit Python version, bootloader version and AirLift nina-fw version are you on?

It appears some software patching was done last year, but it would help to confirm the version numbers you are at first.

https://github.com/adafruit/Adafruit_Ci ... issues/102

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

Return to “Wireless: WiFi and Bluetooth”