The AT Command firmware is no longer actively supported - we moved to the ESP+SPI solution for a better experience and more security. However, this code does work and there may be some community improvements

OK once that is done, you can finally use your freshly-programmed module to connect to the 'net. You can remove miniesptool and the firmware files from your Express' CIRCUITPY drive..

Download and install the ESP AT control library onto your CircuitPython board.

Since there are many steps, it's best to run full examples by saving them to on your board rather than interacting with the REPL. That said, you really want to have a serial connection open to see what's going on.

ESP Wiring

We'll be using a Feather M4 to demonstrate. Wire up the ESP8266 module as shown:

  • VBat from ESP8266 to VBat on Feather M4 (if your board doesn't have a Battery power pin, skip this)
  • Vin from ESP8266 to VUSB on Feather M4 - use whatever 5V (no higher!) power source you have
  • GND to GND
  • ESP8266 Reset to D5 (you can use any pin)
  • ESP8266 RX to UART TX
  • ESP8266 TX to UART RX
  • ESP8266 GPIO13 to D6 (you can use any pin)  (NOT shown on fritzing diagram -- yet..)

Note the UART pins are 'cross wired' - RX to TX. We don't use GPIO 0 but if you want you can keep it connected so that you can go back and upload firmware if you need.

Test wiring & WiFi with AP Scan

Create a file containing settings for your local WiFi router. See the example template below. Change the values to match the name of your wireless network and its password. Copy this file to your CIRCUITPY drive.

There are several examples in the GitHub repo for the library, available here.

It is suggested you start with the program. Save the example below to your board as or save it by another name and execute it manually at the REPL.


secrets = {
    "ssid" : "MY SSID",
    "password" : "MY PASSWORD"
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import board
import busio
from digitalio import DigitalInOut
from digitalio import Direction
from adafruit_espatcontrol import adafruit_espatcontrol

# Get wifi details and more from a file
    from secrets import secrets
except ImportError:
    print("WiFi secrets are kept in, please add them there!")

# With a Particle Argon
RX = board.ESP_TX
TX = board.ESP_RX
resetpin = DigitalInOut(board.ESP_WIFI_EN)
rtspin = DigitalInOut(board.ESP_CTS)
uart = busio.UART(TX, RX, timeout=0.1)
esp_boot = DigitalInOut(board.ESP_BOOT_MODE)
esp_boot.direction = Direction.OUTPUT
esp_boot.value = True

print("ESP AT commands")
esp = adafruit_espatcontrol.ESP_ATcontrol(
    uart, 115200, reset_pin=resetpin, rts_pin=rtspin, debug=False
print("Resetting ESP module")

first_pass = True
while True:
        if first_pass:
            print("Scanning for AP's")
            for ap in esp.scan_APs():
            print("Checking connection...")
            # secrets dictionary must contain 'ssid' and 'password' at a minimum
            print("Connected to AT software version ", esp.version)
            print("IP address ", esp.local_ip)
            first_pass = False
        print("Pinging", end="")
    except (ValueError, RuntimeError, adafruit_espatcontrol.OKError) as e:
        print("Failed to get data, retrying\n", e)
        print("Resetting ESP module")

If you did not set the SSID/password in your file you will get an error on connection

Update those lines and try again! On success the connection will be reported  and the program will Ping IP address ( every 30 seconds

This guide was first published on Dec 16, 2018. It was last updated on Dec 16, 2018.

This page (AT Setup & Test) was last updated on May 08, 2021.

Text editor powered by tinymce.