Hello!
Can you tell me if it is possible to store a configuration file (text file) on a ESP32 module using Arduino IDE?
In this file I want to write custom data such as WIFI SSID, WIFI FIXED IP,WIFI PASSWORD.
And in every code I will write for the module, I will write a function to read the data from the configuration file.
Thank You !
ESP32 Configuration File
Re: ESP32 Configuration File
You may be able to do this through storage to the onboard EEPROM.. Search programs to asses this
Re: ESP32 Configuration File
you can do that thru SPIFFS
have fun
Code: Select all
if (!SPIFFS.begin(true)) {
Serial.println("ERROR: Failed to mount file system");
}
//***********************************************************************
//***********************************************************************
//* saveConfig - save WiFi parameters to config.txt in SPIFFS
//***********************************************************************
//***********************************************************************
bool saveConfig() {
// Open config file for writing.
Serial.println("saveConfig starts");
File configFile = SPIFFS.open("/config.txt", FILE_MODE_W);
if (!configFile) {
Serial.println("Failed to open config.txt for writing");
return false;
}
// Save data.
configFile.println(l_hostname);
configFile.println(l_ssid);
configFile.println(l_Password);
configFile.println(l_dhcp);
configFile.println(l_IP);
configFile.println(l_GW);
configFile.println(l_dns);
configFile.println(l_subnet);
configFile.close();
return true;
}
SPIFFS.end();
-
- Posts: 831
- Joined: Mon Jul 22, 2019 3:20 pm
Re: ESP32 Configuration File
For configuration parameters, it is usually more appropriate to use the nvs keystore. That way you won't need to open and parse the whole file every time you need to read or modify a parameter. It is implemented in arduino as the Preferences library https://github.com/espressif/arduino-es ... ferences.h
Who is online
Users browsing this forum: No registered users and 30 guests