Hi, hello, howdy, etc.
I'll quickly start by stating how much help I've had from this forum by just searching, but I've hit a wall with my understanding of C++ and dealing with characters.
I'm working on a summer project that uses an Arduino Mega and the Wifi Shield and I've had a great deal of success but I've hit a problem. I want to read SSID and password data from the SD card and connect to the network. This will allow the installation to be moved to different WiFi spots with a change to a text file, rather than a recompile of the sketch.
Using the standard example by stating...
char ssid[] = "yourNetwork"; //
char pass[] = "secretPassword";
works fine with
status = WiFi.begin(ssid, pass);
But the problem I have is storing the characters from the SD card into a char array that WiFi.begin is happy with. At the moment I'm doing this...
char ssid[32]; // setting up buffers for the incoming sd card data
char pass[32]; //
....
void setup(){
.... setting up the SD card....
myData = SD.open("myData.txt");
int charCount=0;
while (myData.available()) {
char cx = myData.read();
if(cx==10){
//Serial.println("You got it");
switch(lineCount){
case 0:
ssid[charCount]='\0';
break;
case 1:
pass[charCount]='\0';
break;
}
lineCount++;
charCount=0;
}else{
switch(lineCount){
case 0:
ssid[charCount]=cx;
break;
case 1:
pass[charCount]=cx;
break;
}
charCount++;
}
}
Serial.println(ssid); // this prints out the ssid from the card
Serial.println(pass); // this prints out the password from the card
.....
status = WiFi.begin(ssid, pass); // just won't connect using this method.
Any pointers? Every example I've seen seems to be happy that you can print out the char array, but doesn't use it in the way I am wanting to.
EDIT Using 1.0.2 and I haven't upgraded the firmware on the Wifi. (I can't, it's not mine). Everything with the card is pretty much working OK, it's just the manipulation of the chars that is hindering me,