|
18 | 18 | print("WiFi secrets are kept in secrets.py, please add them there!")
|
19 | 19 | raise
|
20 | 20 |
|
| 21 | +# Debug Level |
| 22 | +# Change the Debug Flag if you have issues with AT commands |
| 23 | +debugflag = False |
21 | 24 |
|
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 |
31 | 27 |
|
| 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 |
32 | 48 |
|
33 | 49 | print("ESP AT commands")
|
34 | 50 | 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 |
36 | 52 | )
|
37 | 53 |
|
38 | 54 | URL = "http://wifitest.adafruit.com/testwifi/index.html"
|
|
57 | 73 | print("Content size:", r.headers["content-length"])
|
58 | 74 | print("Encoding:", r.encoding)
|
59 | 75 | 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) |
62 | 78 | except (ValueError, RuntimeError, adafruit_espatcontrol.OKError) as e:
|
63 | 79 | print("Failed to get data, retrying\n", e)
|
64 | 80 | continue
|
0 commit comments