Skip to content

Commit 6588b06

Browse files
authored
Merge pull request #49 from mperino/main
Adding Support for Challenger 2040 WiFi boards.
2 parents 395ee36 + 432e086 commit 6588b06

File tree

2 files changed

+53
-22
lines changed

2 files changed

+53
-22
lines changed

examples/esp_atcontrol_aio_post.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
22
# SPDX-License-Identifier: MIT
33

4+
# Note, you must create a feed called "test" in your AdafruitIO account.
5+
# Your secrets file must contain your aio_username and aio_key
6+
47
import time
58
import board
69
import busio
@@ -21,21 +24,34 @@
2124
print("WiFi secrets are kept in secrets.py, please add them there!")
2225
raise
2326

27+
# Debug Level
28+
# Change the Debug Flag if you have issues with AT commands
29+
debugflag = False
2430

25-
# With a Particle Argon
26-
RX = board.ESP_TX
27-
TX = board.ESP_RX
28-
resetpin = DigitalInOut(board.ESP_WIFI_EN)
29-
rtspin = DigitalInOut(board.ESP_CTS)
30-
uart = busio.UART(TX, RX, timeout=0.1)
31-
esp_boot = DigitalInOut(board.ESP_BOOT_MODE)
32-
esp_boot.direction = Direction.OUTPUT
33-
esp_boot.value = True
34-
status_light = None
31+
if board.board_id == "challenger_rp2040_wifi":
32+
RX = board.ESP_RX
33+
TX = board.ESP_TX
34+
resetpin = DigitalInOut(board.WIFI_RESET)
35+
rtspin = False
36+
uart = busio.UART(TX, RX, baudrate=11520)
37+
esp_boot = DigitalInOut(board.WIFI_MODE)
38+
esp_boot.direction = Direction.OUTPUT
39+
esp_boot.value = True
40+
status_light = None
41+
else:
42+
RX = board.ESP_TX
43+
TX = board.ESP_RX
44+
resetpin = DigitalInOut(board.ESP_WIFI_EN)
45+
rtspin = DigitalInOut(board.ESP_CTS)
46+
uart = busio.UART(TX, RX, timeout=0.1)
47+
esp_boot = DigitalInOut(board.ESP_BOOT_MODE)
48+
esp_boot.direction = Direction.OUTPUT
49+
esp_boot.value = True
50+
status_light = None
3551

3652
print("ESP AT commands")
3753
esp = adafruit_espatcontrol.ESP_ATcontrol(
38-
uart, 115200, reset_pin=resetpin, rts_pin=rtspin, debug=False
54+
uart, 115200, reset_pin=resetpin, rts_pin=rtspin, debug=debugflag
3955
)
4056
wifi = adafruit_espatcontrol_wifimanager.ESPAT_WiFiManager(esp, secrets, status_light)
4157

examples/esp_atcontrol_simpletest.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,34 @@
1515
except ImportError:
1616
print("WiFi secrets are kept in secrets.py, please add them there!")
1717
raise
18+
# Debug Level
19+
# Change the Debug Flag if you have issues with AT commands
20+
debugflag = False
1821

19-
20-
# With a Particle Argon
21-
RX = board.ESP_TX
22-
TX = board.ESP_RX
23-
resetpin = DigitalInOut(board.ESP_WIFI_EN)
24-
rtspin = DigitalInOut(board.ESP_CTS)
25-
uart = busio.UART(TX, RX, timeout=0.1)
26-
esp_boot = DigitalInOut(board.ESP_BOOT_MODE)
27-
esp_boot.direction = Direction.OUTPUT
28-
esp_boot.value = True
22+
if board.board_id == "challenger_rp2040_wifi":
23+
RX = board.ESP_RX
24+
TX = board.ESP_TX
25+
resetpin = DigitalInOut(board.WIFI_RESET)
26+
rtspin = False
27+
uart = busio.UART(TX, RX, baudrate=11520)
28+
esp_boot = DigitalInOut(board.WIFI_MODE)
29+
esp_boot.direction = Direction.OUTPUT
30+
esp_boot.value = True
31+
else:
32+
RX = board.ESP_TX
33+
TX = board.ESP_RX
34+
resetpin = DigitalInOut(board.ESP_WIFI_EN)
35+
rtspin = DigitalInOut(board.ESP_CTS)
36+
uart = busio.UART(TX, RX, timeout=0.1)
37+
esp_boot = DigitalInOut(board.ESP_BOOT_MODE)
38+
esp_boot.direction = Direction.OUTPUT
39+
esp_boot.value = True
2940

3041

3142
print("ESP AT commands")
43+
# For Boards that do not have an rtspin like challenger_rp2040_wifi set rtspin to False.
3244
esp = adafruit_espatcontrol.ESP_ATcontrol(
33-
uart, 115200, reset_pin=resetpin, rts_pin=rtspin, debug=False
45+
uart, 115200, reset_pin=resetpin, rts_pin=rtspin, debug=debugflag
3446
)
3547
print("Resetting ESP module")
3648
esp.hard_reset()
@@ -39,6 +51,9 @@
3951
while True:
4052
try:
4153
if first_pass:
54+
# Some ESP do not return OK on AP Scan.
55+
# See https://github.com/adafruit/Adafruit_CircuitPython_ESP_ATcontrol/issues/48
56+
# Comment out the next 3 lines if you get a No OK response to AT+CWLAP
4257
print("Scanning for AP's")
4358
for ap in esp.scan_APs():
4459
print(ap)

0 commit comments

Comments
 (0)