|
15 | 15 | except ImportError:
|
16 | 16 | print("WiFi secrets are kept in secrets.py, please add them there!")
|
17 | 17 | raise
|
| 18 | +# Debug Level |
| 19 | +# Change the Debug Flag if you have issues with AT commands |
| 20 | +debugflag = False |
18 | 21 |
|
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 |
29 | 40 |
|
30 | 41 |
|
31 | 42 | print("ESP AT commands")
|
| 43 | +# For Boards that do not have an rtspin like challenger_rp2040_wifi set rtspin to False. |
32 | 44 | 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 |
34 | 46 | )
|
35 | 47 | print("Resetting ESP module")
|
36 | 48 | esp.hard_reset()
|
|
39 | 51 | while True:
|
40 | 52 | try:
|
41 | 53 | 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 |
42 | 57 | print("Scanning for AP's")
|
43 | 58 | for ap in esp.scan_APs():
|
44 | 59 | print(ap)
|
|
0 commit comments