You can use the AirLift with Arduino. Unlike CircuitPython, it work work with most of the Arduino compatible ItsyBitsies, even the 3V ItsyBitsy 32u4. 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
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...
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
At the top you'll see a section where the GPIO pins are defined
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
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.3V 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
Open up the secondary tab, arduino_secrets.h. This is where you will store private data like the SSID/password to your network.
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
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:
Note we use WiFiSSLClient client;
instead of WiFiClient client;
to require an SSL connection!
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
By default it will connect to to the Twitter banner image API, parse the username and followers and display them.
Adapting Other Examples
Once you've got it connecting to the Internet you can check out the other examples. Most of the sketches included with the Adafruit fork of the WiFiNINA library above will have the pin mapping done for the ItsyBitsies. For other examples the only change you'll want to make is at the top of the sketches, add:
#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
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 Bitsy Add-on and set #define ESP32_GPIO0
to the correct pin for your microcontroller. For the ItsyBitsies it will be D10/10
And then before you check the status()
of the module, call the function WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
// 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); }
Page last edited April 09, 2024
Text editor powered by tinymce.