Blynk and SD Card login data

Hey guys,

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.

Does anyone as any advice?

thanks for your help guys!

seems easy enough. just search for “arduino reading sd card file” and you should get the results you’re looking for.

However, have you considered OTA? I’ve never used it before, but you wouldnt even have to go to your aunts house to change out sd cards that way.

This might not be the best link… but it should be enough to get started
http://esp8266.github.io/Arduino/versions/2.0.0/doc/ota_updates/ota_updates.html

thats for your answer @lvennard!

yeah i used it already.

do you know if i can use it to flash an arduino nano using esp12… in that case nodemcu as Serial?

I did OTA updates directly to the Esp8266… not this way…

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.

Not looking easy… and unsure how it could merge with Blynk. You will be on your own learning this one I think.

Much quicker, easier and cheaper to just use your NodeMCU as the standalone MCU

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…

any idea?

You need to read the SD card line by line and save \n after writing each variable.

{while (myFile.available()) {read_file = read_file + char(myFile.read());}

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?

grrrrr :sweat_smile:

That would be \n not /n

Do you have access to Serial Monitor or are you working blind?

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…

Then that is the question I would be asking assistance for :wink:

I thought exactly the same. Instead OP is fumbling around in the dark without Serial Monitor and using pre iOT hardware.

Flashing lights are not my thing but thousands of people are controlling theirs with an ESP.

1 Like