ESP32 Configuration File

tomcat2900
Posts: 6
Joined: Tue Jun 25, 2019 11:24 pm

ESP32 Configuration File

Postby tomcat2900 » Tue Jun 25, 2019 11:29 pm

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 !

rodmcm
Posts: 31
Joined: Sat Sep 02, 2017 3:31 am

Re: ESP32 Configuration File

Postby rodmcm » Wed Jun 26, 2019 9:11 am

You may be able to do this through storage to the onboard EEPROM.. Search programs to asses this

muller59
Posts: 3
Joined: Thu Jul 18, 2019 11:59 am

Re: ESP32 Configuration File

Postby muller59 » Thu Jul 18, 2019 1:34 pm

you can do that thru SPIFFS

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();
have fun

lbernstone
Posts: 7
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32 Configuration File

Postby lbernstone » Mon Jul 22, 2019 3:24 pm

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 8 guests