You can use an AirLift with Arduino. Unlike CircuitPython, it work work with just about any Arduino board, even a classic Arduino UNO. However, if you want to use libraries like Adafruit IO Arduino, 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.

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 Sketch->Include Library -> Add .ZIP library...

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.

Arduino Microcontroller Pin Definition

Next, you'll need to need to modify the pin definition above for the AirLift Shield. Replace the configuration in the sketch with the pinouts below:

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

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 Example

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. The only change you'll want to make is at the top of the sketches, add:

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

And then before you check the status() of the module, call the function WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI); like so:

Download: file
// check for the WiFi module:
  WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
  while (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    delay(1000);
  }
This guide was first published on Jun 21, 2019. It was last updated on Jun 21, 2019.
This page (Arduino) was last updated on Jun 03, 2020.