I'd like to use an SD card to provide the login credentials to an ESP32. I've already got the ESP32 reading the relative data from the SD card and storing it as a char array on the ESP, but when I use those arrays in the WiFi.begin function it never connects.
Is this something to do with the way arrays work or am I doing something else wrong?
Respective code:
if (dataFile) {
Serial.println("File is available");
while (dataFile.available()) {
byte currbyte = dataFile.read();
if (currbyte == 58) {
reading = 1; //Begin reading data
i = 0;
}
while (reading == 1 and s == 0) {
byte currbyte = dataFile.read();
//Serial.print(currbyte);
//Serial.println(char(currbyte));
if (currbyte == 13) {
s = 1;
reading = 0 ;
}
ssid[i] = char(currbyte);
i++;
//Serial.println(ssid);
}
while (reading == 1 and s == 1) {
byte currbyte = dataFile.read();
//Serial.print(currbyte);
//Serial.println(char(currbyte));
if (currbyte == 13) {
s = 2;
reading = 0 ;
}
password[i] = char(currbyte);
i++;
//Serial.println(password);
}
}
dataFile.close();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED and count < 20) {
Serial.println("Connecting to WiFi..");
delay(1000);
count++;}