Hi folks,
I'm having a weird issue with my Teensy 4.1 and an Adafruit Airlift. I need to use the alternate SPI pins for the Airlift because of a hardware conflict. I'm using the SPI library and had success testing on my Teensy 3.2 but when I subbed in my 4.1 (with its different set of alternates) it does not seem to respond. It completely ignores the SPI reassignments and runs on the default SPI pins instead.
Could someone please tell me if I'm missing something obvious? I've checked and triple-checked the pins and the code. I'm suspecting something's up with WiFiNINA at this point, but need a sanity check.
I'm running teensyduino 1.52 and Arduino 1.8.13. I've even tried this on older builds of Teensyduino and Arduino
I'm having a weird issue with my Teensy 4.1 and an Adafruit Airlift. I need to use the alternate SPI pins for the Airlift because of a hardware conflict. I'm using the SPI library and had success testing on my Teensy 3.2 but when I subbed in my 4.1 (with its different set of alternates) it does not seem to respond. It completely ignores the SPI reassignments and runs on the default SPI pins instead.
Could someone please tell me if I'm missing something obvious? I've checked and triple-checked the pins and the code. I'm suspecting something's up with WiFiNINA at this point, but need a sanity check.
I'm running teensyduino 1.52 and Arduino 1.8.13. I've even tried this on older builds of Teensyduino and Arduino
Code:
#include <SPI.h>
#include <WiFiNINA.h>
// Configure the pins used for the ESP32 connection
// TEENSYDUINO
#define SPIWIFI SPI // The SPI port
#define SPIWIFI_SS 5 // 15 // Chip select pin def:5
#define ESP32_RESETN 6 // 18 // Reset pin def:6
#define SPIWIFI_ACK 9 // 16 // a.k.a BUSY or READY pin def:9
#define ESP32_GPIO0 -1
void setup() {
// SPI.setMOSI(7); SPI.setMISO(8); SPI.setSCK(14); SPI.begin(); // teensy 3.2 ?? it works!!!!
SPI.setMOSI(26); SPI.setMISO(1); SPI.setSCK(27); SPI.begin(); // teensy 4.1 ?? NOPE :(
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("WiFi Scanning test");
// Set up the pins!
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
// check for the WiFi module:
while (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
// don't continue
delay(1000);
}
// print your MAC address:
byte mac[6];
WiFi.macAddress(mac);
Serial.print("MAC: ");
printMacAddress(mac);
}
void loop() {
// scan for existing networks:
Serial.println("Scanning available networks...");
listNetworks();
delay(10000);
}
void listNetworks() {
// scan for nearby networks:
Serial.println("** Scan Networks **");
int numSsid = WiFi.scanNetworks();
if (numSsid == -1) {
Serial.println("Couldn't get a wifi connection");
while (true);
}
// print the list of networks seen:
Serial.print("number of available networks:");
Serial.println(numSsid);
// print the network number and name for each network found:
for (int thisNet = 0; thisNet < numSsid; thisNet++) {
Serial.println(WiFi.SSID(thisNet));
}
}
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();
}