Please excuse newbie to Arduinos and programming. I have been working on this project for over a year and have been stuck on the FTP portion for over 6 months. The overall project is an audio recorder that stores audio files in raw format on the SD Card and then opens an FTP server allowing my computer to connect on a schedule and download the audio files. The audio recording is handled by the Audio Adapter board for Teensy 4.x and works flawlessly. WiFi is handled by the Adafruit Airlift Featherwing Co-Processor and the Adafruit Teensy adapter board. The WiFi works perfectly. I am using the SimpleFTPServer.h library for FTP and as far as the serial monitor shows, it is working and reports that it is listening on port 21 but not only am I unable to connect to it, a port scanner doesn't show any open ports at all. For example of my problem I have created a scaled down sketch that exhibits the issue I am dealing with (just WiFi, SD Card and FTP).
I have tried numerous different FTP libraries, numerous WiFi libraries (WiFi.h, WiFiNINA.h, WiFiNINA_Generic.h) The current WiFiNINA.h library I am using in this example is the Adafruit WiFiNINA library.
Any assistance that anyone can offer would be greatly appreciated.
The code compiles clean and the Serial Output is below.
********* Serial Output ***********
Firmware Version is 1.2.2
Wifi Begin
Attempting to connect to WPA SSID: MATRIX
...Connecting
You're connected to the network.SSID: MATRIX
BSSID: B0:A7:B9:13:A5:6B
signal strength (RSSI):-60
Encryption Type:4
IP Address: 192.168.1.127
192.168.1.127
MAC address: C4D:57:B8:AFC
Preparing to initialize SD Card
SD Card Initialized
Initializing FTP Server...
NOT ANONYMOUS
esp8266
Ftp server waiting for connection on port 21
********** End Serial Output *************
I have tried numerous different FTP libraries, numerous WiFi libraries (WiFi.h, WiFiNINA.h, WiFiNINA_Generic.h) The current WiFiNINA.h library I am using in this example is the Adafruit WiFiNINA library.
Any assistance that anyone can offer would be greatly appreciated.
The code compiles clean and the Serial Output is below.
********* Serial Output ***********
Firmware Version is 1.2.2
Wifi Begin
Attempting to connect to WPA SSID: MATRIX
...Connecting
You're connected to the network.SSID: MATRIX
BSSID: B0:A7:B9:13:A5:6B
signal strength (RSSI):-60
Encryption Type:4
IP Address: 192.168.1.127
192.168.1.127
MAC address: C4D:57:B8:AFC
Preparing to initialize SD Card
SD Card Initialized
Initializing FTP Server...
NOT ANONYMOUS
esp8266
Ftp server waiting for connection on port 21
********** End Serial Output *************
Code:
#include <SimpleFTPServer.h>
#include <SdFat.h>
#include <SdFatConfig.h>
#include <sdios.h>
#include <WiFiNINA.h>
#include <SPI.h>
//Define WiFi Connections
#define SPIWIFI SPI
#define SPIWIFI_SS 5
#define ESP32_RESET 6
#define SPIWIFI_ACK 9
#define ESP32_GPIO0 -1
//Define WiFi Credentials
const char* ssid = "MATRIX";
const char* pass = "rpentagon845psilly417";
int status = WL_IDLE_STATUS; // the Wifi radio's status
//Define SD Card Object
SdFat sd;
//Define FTP Server Object
FtpServer ftpSrv;
// Use these with the Teensy 3.5 & 3.6 SD card
#define SDCARD_CS_PIN BUILTIN_SDCARD
#define SDCARD_MOSI_PIN 11 // not actually used
#define SDCARD_SCK_PIN 13 // not actually used
// IP address of FTP server
// if set to 0, use DHCP for the routeur to assign IP
// IPAddress serverIp( 192, 168, 1, 40 );
IPAddress serverIp( 192, 168, 1, 127 ); //This IP is the same IP given to Teensy by DHCP
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
}
// Set up the pins!
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESET, ESP32_GPIO0, &SPIWIFI);
SPI.begin();
String fv = WiFi.firmwareVersion();
Serial.print("Firmware Version is ");
Serial.println(fv);
// attempt to connect to Wifi network:
Serial.println("Wifi Begin");
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);
Serial.println("...Connecting");
}
// you're connected now, so print out the data:
Serial.print("You're connected to the network.");
printCurrentNet();
printWifiData();
// Initialize the SD card
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
Serial.println("Preparing to initialize SD Card");
while (!(SD.begin(SDCARD_CS_PIN))) {
// stop here if no SD card, but print a message
Serial.println("SD Card Not Initialized");
delay(500);
}
Serial.println("SD Card Initialized");
//Initialize FTP Server
Serial.println();
Serial.println("Initializing FTP Server...");
ftpSrv.begin("esp8266","esp8266");
// ftpSrv.init( externalIp );
//ftpSrv.init( IPAddress( 192, 168, 1, 195 ));
}
void loop() {
ftpSrv.handleFTP();
}
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();
}