I’m building a RGB led controller for a fishtank that simulates the daylight.
i have it working with my project but, because it’s not a project for my home… i would like to do it more “professional”.
I am using an arduino nano, an SDCard reader, an RGB controler and a NodeMCU to wifi my project.
My idea is to use a small SD Card to store 3 files (AUTH.TXT, SSID.TXT and PASS.TXT).
At the begining of the sketch it should read the SD Card and load chat auth[]; ssid and pass.
When blynk begins it can use the loaded values from sd card… then i can change the files remotely without have to go to my aunt house if they change routers and ISP.
Does anyonehave tried anything like that?
I can store the variable in “auth” but all the times a load it, nothing happens. i think it must but because it is declaired as a const variable in blynk libraries.
sorry man, we need someone way better than me on this one. I tapped my limit answering round one. i have to cheat and copy all of my arduino code cause i suck at C.
I am using a RGB LED Driver Module and for some reason i can’t control it directly from my NodeMCU… Thats why i am using an arduino nano as an intermediary. Believe me… if i could avoid it i would… (i had to use logic level converters for that…)
I will not try to do that… i am almost on the way for this.
I am having just a problem of syntax…
char new_auth[] = "00000000000000000000000000000000";
char new_ssid[] = "";
char new_pass[] = "";
myFile = SD.open("auth.txt");
if (myFile) {while (myFile.available()) {read_file = read_file + char(myFile.read());}
read_file = read_file.substring(0,32);
read_file.toCharArray(new_auth, 34);;
myFile.close();} else {
// if the file didn't open, print an error:
Serial.println("auth.txt not found");
}
read_file = "";
myFile = SD.open("ssid.txt");
if (myFile) {while (myFile.available()) {read_file = read_file + char(myFile.read());}
int sizeint = read_file.length();
read_file = read_file.substring(0,sizeint);
read_file.toCharArray(new_ssid, sizeint+2);
myFile.close();} else {
// if the file didn't open, print an error:
Serial.println("ssid.txt not found");
}
it works fine for the token… because its a fixed size… but it is giving me issues with the SSID and Pass…
in this line, at the variable “read_file” i have a String that contains everything i need.
Lets imagine “mywifipass/n” (the file only has 1 line)
i guess i need to make:
int file_len = read_file.lenght(); (to know the size of the SSID)
read_file = read_file.substring(0, file_len -1 ); (i took off the \n)
now i guess if i do:
read_file.toCharArray(new_ssid, file_len -1);
i guess i have an char[], with the size i need. why doesn’t it work?
Well… In that case… No. Maybe I have to debug in an Arduino mega using Serial1…
The token I only got it working after I initialize it with auth [] = “exactly 32 digits”…
Even in the output serial I had exactly the same in the String and Char…