CircuitPython

It's easy to use the Adafruit AirLift breakout with CircuitPython and the Adafruit CircuitPython ESP32SPI module.  This module allows you to easily add WiFi to your project.

The ESP32SPI library requires an M4 or better microcontroller! The M0 will not work.

CircuitPython Microcontroller Pinout

Since all CircuitPython-running Feathers follow the same pinout, you do not need to change any of the pins listed below.

To use the ESP32's pins, copy the following lines into your code:

Download: file
esp32_cs = DigitalInOut(board.D13)
esp32_ready = DigitalInOut(board.D11)
esp32_reset = DigitalInOut(board.D12)

If you wish to use the ESP32's GPIO0 pin - solder the jumper on the back of the FeatherWing, highlighted in red.

Then, include the following code to use the pin:

Download: file
    esp32_gpio0 = DigitalInOut(board.D10)
  

CircuitPython Installation of ESP32SPI Library

You'll need to install the Adafruit CircuitPython ESP32SPI library on your CircuitPython board.

First make sure you are running the latest version of Adafruit CircuitPython for your board.

Next you'll need to install the necessary libraries to use the hardware--carefully follow the steps to find and install these libraries from Adafruit's CircuitPython library bundle.  Our CircuitPython starter guide has a great page on how to install the library bundle.

You can manually install the necessary libraries from the bundle:

  • adafruit_esp32spi.mpy
  • adafruit_requests.mpy
  • adafruit_bus_device

Before continuing make sure your board's lib folder or root filesystem has the adafruit_esp32spi.mpy, and adafruit_bus_device files and folders copied over.

Next make sure you are set up to connect to the serial console

CircuitPython Usage

Copy the following code to your code.py file on your microcontroller:

Download: file
import board
import busio
from digitalio import DigitalInOut

from adafruit_esp32spi import adafruit_esp32spi

print("ESP32 SPI hardware test")

esp32_cs = DigitalInOut(board.D13)
esp32_ready = DigitalInOut(board.D11)
esp32_reset = DigitalInOut(board.D12)

spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)

if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
    print("ESP32 found and in idle mode")
print("Firmware vers.", esp.firmware_version)
print("MAC addr:", [hex(i) for i in esp.MAC_address])

for ap in esp.scan_networks():
    print("\t%s\t\tRSSI: %d" % (str(ap['ssid'], 'utf-8'), ap['rssi']))

print("Done!")

Connect to the serial console to see the output. It should look something like the following:

Make sure you see the same output! If you don't, check your wiring. Note that we've changed the pinout in the code example above to reflect the CircuitPython Microcontroller Pinout at the top of this page.

Once you've succeeded, continue onto the next page!

If you can read the Firmware and MAC address but fails on scanning SSIDs, check your power supply, you may be running out of juice to the ESP32 and it's resetting
This guide was first published on May 29, 2019. It was last updated on May 29, 2019. This page (CircuitPython) was last updated on Sep 15, 2019.