Skip to content

Commit 0786a08

Browse files
authored
Update esp_atcontrol_webclient.py
Added support for Challenger RP2040, added a variable for setting the Time Between Queries, and print when it sleeps..
1 parent 85a1f07 commit 0786a08

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

examples/esp_atcontrol_webclient.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,37 @@
1818
print("WiFi secrets are kept in secrets.py, please add them there!")
1919
raise
2020

21+
# Debug Level
22+
# Change the Debug Flag if you have issues with AT commands
23+
debugflag = False
2124

22-
# With a Particle Argon
23-
RX = board.ESP_TX
24-
TX = board.ESP_RX
25-
resetpin = DigitalInOut(board.ESP_WIFI_EN)
26-
rtspin = DigitalInOut(board.ESP_CTS)
27-
uart = busio.UART(TX, RX, timeout=0.1)
28-
esp_boot = DigitalInOut(board.ESP_BOOT_MODE)
29-
esp_boot.direction = Direction.OUTPUT
30-
esp_boot.value = True
25+
# How long between queries
26+
TIME_BETWEEN_QUERY = 60 # in seconds
3127

28+
if board.board_id == "challenger_rp2040_wifi":
29+
RX = board.ESP_RX
30+
TX = board.ESP_TX
31+
resetpin = DigitalInOut(board.WIFI_RESET)
32+
rtspin = False
33+
uart = busio.UART(TX, RX, baudrate=11520, receiver_buffer_size=2048)
34+
esp_boot = DigitalInOut(board.WIFI_MODE)
35+
esp_boot.direction = Direction.OUTPUT
36+
esp_boot.value = True
37+
status_light = None
38+
else:
39+
RX = board.ESP_TX
40+
TX = board.ESP_RX
41+
resetpin = DigitalInOut(board.ESP_WIFI_EN)
42+
rtspin = DigitalInOut(board.ESP_CTS)
43+
uart = busio.UART(TX, RX, timeout=0.1)
44+
esp_boot = DigitalInOut(board.ESP_BOOT_MODE)
45+
esp_boot.direction = Direction.OUTPUT
46+
esp_boot.value = True
47+
status_light = None
3248

3349
print("ESP AT commands")
3450
esp = adafruit_espatcontrol.ESP_ATcontrol(
35-
uart, 115200, reset_pin=resetpin, rts_pin=rtspin, debug=False
51+
uart, 115200, reset_pin=resetpin, rts_pin=rtspin, debug=debugflag
3652
)
3753

3854
URL = "http://wifitest.adafruit.com/testwifi/index.html"
@@ -57,8 +73,8 @@
5773
print("Content size:", r.headers["content-length"])
5874
print("Encoding:", r.encoding)
5975
print("Text:", r.text)
60-
61-
time.sleep(60)
76+
print("Sleeping for: {0} Seconds".format(TIME_BETWEEN_QUERY))
77+
time.sleep(TIME_BETWEEN_QUERY)
6278
except (ValueError, RuntimeError, adafruit_espatcontrol.OKError) as e:
6379
print("Failed to get data, retrying\n", e)
6480
continue

0 commit comments

Comments
 (0)