Arduino

You can use the AirLift with Arduino. Unlike CircuitPython, it work work with just about any Arduino chip, even a classic Arduino UNO. However, if you want to use libraries like ArduinoJSON or add sensors and SD card, you'll really want an ATSAMD21 (Cortex M0) or ATSAMD51 (Cortex M4), both of which have plenty or RAM

Arduino Microcontroller Pin Definitions

Because each Feather uses a different processor, you'll need to include the following pin definitions to your code depending on which board you are using:

Feather M0, M4, 32u4, or NRF52840

Download: file
#define SPIWIFI       SPI  // The SPI port
#define SPIWIFI_SS    13   // Chip select pin
#define ESP32_RESETN  12   // Reset pin
#define SPIWIFI_ACK   11   // a.k.a BUSY or READY pin
#define ESP32_GPIO0   -1

Feather 328P

Download: file
#define SPIWIFI       SPI  // The SPI port
#define SPIWIFI_SS     4   // Chip select pin
#define ESP32_RESETN   3   // Reset pin
#define SPIWIFI_ACK    2   // a.k.a BUSY or READY pin
#define ESP32_GPIO0   -1

Feather NRF52832

Download: file
#define SPIWIFI       SPI  // The SPI port
#define SPIWIFI_SS    16  // Chip select pin
#define ESP32_RESETN  15  // Reset pin
#define SPIWIFI_ACK    7  // a.k.a BUSY or READY pin
#define ESP32_GPIO0   -1

Teensy

Download: file
#define SPIWIFI       SPI  // The SPI port
#define SPIWIFI_SS     5   // Chip select pin
#define ESP32_RESETN   6   // Reset pin
#define SPIWIFI_ACK    9   // a.k.a BUSY or READY pin
#define ESP32_GPIO0   -1

Note: These pin definitions leave the the ESP32's GPIO0 pin undefined (-1). If you wish to use this pin - solder the pad on the bottom of the FeatherWing and set #define ESP32_GPIO0 to the correct pin for your microcontroller.

Note: These pin definitions leave the the ESP32's GPIO0 pin undefined (-1).

If you wish to use this pin - solder the pad on the bottom of the FeatherWing and set #define ESP32_GPIO0 to the correct pin for your microcontroller.

Library Install

We're using a variant of the Arduino WiFiNINA library, which is amazing and written by the Arduino team! The official WiFi101 library won't work because it doesn't support the ability to change the pins.

So! We made a fork that you can install.

Click here to download the library:

Within the Arduino IDE, select Install library from ZIP...

adafruit_products_image.png

And select the zip you just downloaded.

First Test

OK now you have it wired and library installed, time to test it out!

Lets start by scanning the local networks. Load up the ScanNetworks example

adafruit_products_image.png

At the top you'll see a section where the GPIO pins are defined

adafruit_products_image.png

If you don't see this, you may have the wrong WiFiNINA library installed. Uninstall it and re-install the Adafruit one as above.

Compile and upload to your board wired up to the AirLift

adafruit_products_image.png

If you don't even get the MAC address printed out, check your wiring.

If you get the MAC address but cannot scan any networks, check your power supply. You need a solid 3-5VDC into Vin in order for the ESP32 not to brown out.

WiFi Connection Test

Now that you have your wiring checked, time to connect to the Internet!

Open up the WiFiWebClient example

adafruit_products_image.png

Open up the secondary tab, arduino_secrets.h. This is where you will store private data like the SSID/password to your network.

adafruit_products_image.png

You must change these string values before updating to your board!

After you've set it correctly, upload and check the serial monitor. You should see the following. If not, go back, check wiring, power and your SSID/password

adafruit_products_image.png

Secure Connection Example

Many servers today do not allow non-SSL connectivity. Lucky for you the ESP32 has a great TLS/SSL stack so you can have that all taken care of for you. Here's an example of a secure WiFi connection:

adafruit_products_image.png

Note we use WiFiSSLClient client; instead of WiFiClient client; to require an SSL connection!

adafruit_products_image.png

JSON Parsing Demo

This example is a little more advanced - many sites will have API's that give you JSON data. We'll use ArduinoJSON to convert that to a format we can use and then display that data on the serial port (which can then be re-directed to a display of some sort)

First up, use the Library manager to install ArduinoJSON.

Then load the example JSONdemo

adafruit_products_image.png

By default it will connect to to the Twitter banner image API, parse the username and followers and display them.

adafruit_products_image.png

Adapting Other Examples

Once you've got it connecting to the Internet you can check out the other examples. 

This guide was first published on May 29, 2019. It was last updated on May 29, 2019. This page (Arduino) was last updated on Sep 22, 2019.