Esp32cam: I read String from SPIFFS but it is not accepted. Why ?
Posted: Thu Aug 10, 2023 10:44 am
Hello. I ask for help.
I'm using the sendFile example from this library:
https://github.com/GyverLibs/FastBot/tree/main
But instead of having the BOT_TOKEN value as a #define, I intend to read the BOT_TOKEN from a .txt file inside LittleFS.
For this I declared a global String bottokenstring;
I comment out // the #define BOT_TOKEN and create an empty global String BOT_TOKEN.
And read using:
file = LittleFS.open("/CONFIG.txt", "r");
if (file) {
while (file.available()) {
bottokenstring = myFile.readStringUntil('\n');
}
file.close();
}
Then I do it inside the setup(), BOT_TOKEN = bottokenstring;
Mute FastBot bot(BOT_TOKEN); instead of placing it inside the Setup(); after getting the String BOT_TOKEN.
Does not work.
But if I enter the value of BOT_TOKEN inside Setup(); Just type, manually, BOT_TOKEN = "2654326546:asjhAsfAsfkllgUsaOuiz_axfkj_AsfkjhB";
There it works. Wonder what's going on? I read the String bottokenstring in the serial monitor and it is identical. But something prevents it from being recognized as a String.
I'm using the sendFile example from this library:
https://github.com/GyverLibs/FastBot/tree/main
But instead of having the BOT_TOKEN value as a #define, I intend to read the BOT_TOKEN from a .txt file inside LittleFS.
For this I declared a global String bottokenstring;
I comment out // the #define BOT_TOKEN and create an empty global String BOT_TOKEN.
And read using:
file = LittleFS.open("/CONFIG.txt", "r");
if (file) {
while (file.available()) {
bottokenstring = myFile.readStringUntil('\n');
}
file.close();
}
Then I do it inside the setup(), BOT_TOKEN = bottokenstring;
Mute FastBot bot(BOT_TOKEN); instead of placing it inside the Setup(); after getting the String BOT_TOKEN.
Does not work.
But if I enter the value of BOT_TOKEN inside Setup(); Just type, manually, BOT_TOKEN = "2654326546:asjhAsfAsfkllgUsaOuiz_axfkj_AsfkjhB";
There it works. Wonder what's going on? I read the String bottokenstring in the serial monitor and it is identical. But something prevents it from being recognized as a String.