Skip to content

Commit 85a1f07

Browse files
authored
Update esp_atcontrol_localtime.py
Added support for Challenger RP2040 WiFI, added a setting for the sleep between Polling, added a Print statement when it is sleeping and for how long.
1 parent b555813 commit 85a1f07

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

examples/esp_atcontrol_localtime.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,38 @@
2121
print("WiFi secrets are kept in secrets.py, please add them there!")
2222
raise
2323

24-
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
35-
24+
# Debug Level
25+
# Change the Debug Flag if you have issues with AT commands
26+
debugflag = False
27+
28+
# How Long to sleep between polling
29+
sleep_duration = 5
30+
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, receiver_buffer_size=2048)
37+
esp_boot = DigitalInOut(board.WIFI_MODE)
38+
esp_boot.direction = Direction.OUTPUT
39+
esp_boot.value = True
40+
status_light = None
41+
42+
else:
43+
RX = board.ESP_TX
44+
TX = board.ESP_RX
45+
resetpin = DigitalInOut(board.ESP_WIFI_EN)
46+
rtspin = DigitalInOut(board.ESP_CTS)
47+
uart = busio.UART(TX, RX, timeout=0.1)
48+
esp_boot = DigitalInOut(board.ESP_BOOT_MODE)
49+
esp_boot.direction = Direction.OUTPUT
50+
esp_boot.value = True
51+
status_light = None
3652

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

@@ -78,4 +94,6 @@
7894

7995
while True:
8096
print(time.localtime())
81-
time.sleep(1)
97+
print("Sleeping for: {0} Seconds".format(sleep_duration))
98+
time.sleep(sleep_duration)
99+

0 commit comments

Comments
 (0)