Hi all,
today my new parts arrived including an Adafruit Airlift Feather so i decided to connect the Teensy 4.1 to my WLAN.
(I think this would also work with Teensy 4.0)
Here is a bit of an advanced howto, proceed at your own risk, soldering skills are required!
Hardware needed:
AirLift FeatherWing ESP32
https://www.adafruit.com/product/4264
Teensy Feather Adapter
https://www.adafruit.com/product/3200
Stacking Headers for the Teensy/Airlift, or what i used:
FeatherWing Doubler - Prototyping Add-on For All Feather Boards
https://www.adafruit.com/product/2890
(Also available from other suppliers)
The prepared parts will look like this:
Note: On the AirLift you might need to solder the pads near ESPGPIO0.
I did not get it working without soldering the pads but it might be worthwhile to try without first.
You need this Library:
https://github.com/adafruit/WiFiNINA
I used version 1.3.0 of this library.
If you use Teensyduino i think following the instructions on
https://learn.adafruit.com/adafruit-airlift-featherwing-esp32-wifi-co-processor-featherwing
should be helpful. I used PlatformIO, where you have to add this line to the file platformio.ini in your project dir:
You need to apply this patch to the Adafruit WiFiNINA library to make it work with Teensy4:
Then you should be able to compile and upload this sketch:
If it works it should look like this in the serial monitor:
In the terminal window:
Caveat: Sometime it does not find the ESP32, i think it could benefit from some SPI pullup resistors, but i am not sure
which values to use and where exactly. Did not look at Paul's SPI recommendation page today.
today my new parts arrived including an Adafruit Airlift Feather so i decided to connect the Teensy 4.1 to my WLAN.
(I think this would also work with Teensy 4.0)
Here is a bit of an advanced howto, proceed at your own risk, soldering skills are required!
Hardware needed:
AirLift FeatherWing ESP32
https://www.adafruit.com/product/4264
Teensy Feather Adapter
https://www.adafruit.com/product/3200
Stacking Headers for the Teensy/Airlift, or what i used:
FeatherWing Doubler - Prototyping Add-on For All Feather Boards
https://www.adafruit.com/product/2890
(Also available from other suppliers)
The prepared parts will look like this:
Note: On the AirLift you might need to solder the pads near ESPGPIO0.
I did not get it working without soldering the pads but it might be worthwhile to try without first.
You need this Library:
https://github.com/adafruit/WiFiNINA
I used version 1.3.0 of this library.
If you use Teensyduino i think following the instructions on
https://learn.adafruit.com/adafruit-airlift-featherwing-esp32-wifi-co-processor-featherwing
should be helpful. I used PlatformIO, where you have to add this line to the file platformio.ini in your project dir:
Code:
lib_deps = https://github.com/adafruit/WiFiNINA/#1.3.0
You need to apply this patch to the Adafruit WiFiNINA library to make it work with Teensy4:
Code:
diff --git a/src/utility/spi_drv.cpp b/src/utility/spi_drv.cpp
index ff89d41..3884f30 100644
--- a/src/utility/spi_drv.cpp
+++ b/src/utility/spi_drv.cpp
@@ -81,6 +81,14 @@ void SpiDrv::begin()
SLAVERESET = (uint8_t)SPIWIFI_RESET;
#endif
+#ifdef ARDUINO_TEENSY41
+#define SLAVESELECT 5
+#define SLAVERESET 6
+#define SLAVEREADY 9
+#define NINA_GPIO0 10
+#endif
+
+#ifndef ARDUINO_TEENSY41
#ifdef ARDUINO_SAMD_MKRVIDOR4000
inverted_reset = false;
#else
@@ -88,6 +96,7 @@ void SpiDrv::begin()
inverted_reset = true;
SLAVERESET = ~SLAVERESET;
}
+#endif
#endif
Then you should be able to compile and upload this sketch:
Code:
#define SPIWIFI SPI // The SPI port
#include <Arduino.h>
#include <SPI.h>
#include <WiFiNINA.h>
const char *ssid = "YOUR_SSID_HERE";
const char *pass= "YOUR_PASSWORD";
int status = WL_IDLE_STATUS; // the Wifi radio's status
void printMacAddress(byte mac[]) {
for (int i = 5; i >= 0; i--) {
if (mac[i] < 16) {
Serial.print("0");
}
Serial.print(mac[i], HEX);
if (i > 0) {
Serial.print(":");
}
}
Serial.println();
}
void printWifiData() {
// print your board's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
Serial.println(ip);
// print your MAC address:
byte mac[6];
WiFi.macAddress(mac);
Serial.print("MAC address: ");
printMacAddress(mac);
}
void printCurrentNet() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print the MAC address of the router you're attached to:
byte bssid[6];
WiFi.BSSID(bssid);
Serial.print("BSSID: ");
printMacAddress(bssid);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.println(rssi);
// print the encryption type:
byte encryption = WiFi.encryptionType();
Serial.print("Encryption Type:");
Serial.println(encryption, HEX);
Serial.println();
}
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
SPI.begin();
// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true);
}
String fv = WiFi.firmwareVersion();
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
Serial.println("Please upgrade the firmware!");
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network:
status = WiFi.begin(ssid, pass);
// wait 5 seconds for connection:
delay(5000);
}
// you're connected now, so print out the data:
Serial.print("You're connected to the network.");
printCurrentNet();
printWifiData();
}
void loop() {
// check the network connection once every 10 seconds:
delay(10000);
printCurrentNet();
}
If it works it should look like this in the serial monitor:
Code:
Attempting to connect to WPA SSID: bs_XXXXX
You're connected to the network.SSID: bs_XXXXX
BSSID: D0:03:4B:XX:XX:XX
signal strength (RSSI):-62
Encryption Type:4
IP Address: 192.168.178.40
192.168.178.40
MAC address: A4:CF:12:XX:XX:XX
SSID: bs_XXXXX
BSSID: D0:03:4B:XX:XX:XX
signal strength (RSSI):-62
Encryption Type:4
In the terminal window:
Code:
ms@braeburn:WiFiNINA #5009 22:28 :) ping 192.168.178.40
PING 192.168.178.40 (192.168.178.40): 56 data bytes
64 bytes from 192.168.178.40: icmp_seq=0 ttl=255 time=188.952 ms
64 bytes from 192.168.178.40: icmp_seq=1 ttl=255 time=121.472 ms
64 bytes from 192.168.178.40: icmp_seq=2 ttl=255 time=38.590 ms
64 bytes from 192.168.178.40: icmp_seq=3 ttl=255 time=250.641 ms
64 bytes from 192.168.178.40: icmp_seq=4 ttl=255 time=167.443 ms
Caveat: Sometime it does not find the ESP32, i think it could benefit from some SPI pullup resistors, but i am not sure
which values to use and where exactly. Did not look at Paul's SPI recommendation page today.
Last edited: