Library Install
We're using a variant of the Arduino WiFiNINA library, which is amazing and written by the Arduino team! We made a fork that you can install.
Click here to download the library:
Within the Arduino IDE, select Install library from ZIP...
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
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 linked above.
You do not need to change any of these pins - they're pre-defined in the board definition for the Metro M4 WiFi but you still will want to have our version of the library installed because you can switch to the AirLift shield or breakout.
Make sure you select Metro M4 AirLift not Metro M4 Express!
Compile and upload to your board.
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
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
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!
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
By default it will connect to to the Twitter banner image API, parse the username and followers and display them.
Text editor powered by tinymce.