
WiFi Manager
That simpletest example works but it's a little finicky - you need to constantly check
WiFi status and have many loops to manage connections and disconnections. For
more advanced uses, we recommend using the WiFiManager object. It will wrap the
connection/status/requests loop for you - reconnecting if WiFi drops, resetting the
ESP32 if it gets into a bad state, etc.
Here's a more advanced example that shows the WiFi manager and also how to POST
data with some extra headers:
# SPDX-FileCopyrightText: 2019 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import
time
import
board
import
busio
from
digitalio
import
DigitalInOut
import
neopixel
from
adafruit_esp32spi
import
adafruit_esp32spi
from
adafruit_esp32spi
import
adafruit_esp32spi_wifimanager
(
"ESP32 SPI webclient test"
)
# Get wifi details and more from a secrets.py file
try
:
from
secrets
import
secrets
except
ImportError
:
(
"WiFi secrets are kept in secrets.py, please add them there!"
)
raise
# If you are using a board with pre-defined ESP32 Pins:
esp32_cs
=
DigitalInOut(board.ESP_CS)
esp32_ready
=
DigitalInOut(board.ESP_BUSY)
esp32_reset
=
DigitalInOut(board.ESP_RESET)
# If you have an externally connected ESP32:
# esp32_cs = DigitalInOut(board.D9)
# esp32_ready = DigitalInOut(board.D10)
# esp32_reset = DigitalInOut(board.D5)
spi
=
busio.SPI(board.SCK, board.MOSI, board.MISO)
esp
=
adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
"""Use below for Most Boards"""
status_light
=
neopixel.NeoPixel(
board.NEOPIXEL,
1
, brightness
=
0.2
)
# Uncomment for Most Boards
"""Uncomment below for ItsyBitsy M4"""
# status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1,
brightness=0.2)
# Uncomment below for an externally defined RGB LED
# import adafruit_rgbled
# from adafruit_esp32spi import PWMOut
# RED_LED = PWMOut.PWMOut(esp, 26)
# GREEN_LED = PWMOut.PWMOut(esp, 27)
# BLUE_LED = PWMOut.PWMOut(esp, 25)
# status_light = adafruit_rgbled.RGBLED(RED_LED, BLUE_LED, GREEN_LED)
wifi
=
adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets, status_light)
counter
=
0
©Adafruit Industries
Page 25 of 54
Содержание Airlift Bitsy Add-On
Страница 4: ...Adafruit Industries Page 4 of 54...
Страница 7: ...Pinouts Adafruit Industries Page 7 of 54...
Страница 42: ...Adafruit Industries Page 42 of 54...
Страница 54: ...Fab Print Adafruit Industries Page 54 of 54...