#include <EEPROM.h>
// Device configuration
struct Configuration {
char deviceID[32]; // Make and model of the device. For example "Bleu Farms ResDefender"
char version[8]; // <major>.<minor>.<build> Example: 1.2.1
char name[16]; // The name of this device. Example: "Tub 1"
char location[32]; // The location of this device. Example: "Garage"
byte macAddress[6]; // MAC address of the wemos D1, if used
char unitOfMeasure; // M = Metric, I = Imperial
char ssid[32]; // SSID of the wifi we want to connect to
char pw[32]; // Password for the WiFi we want to connect to
};
int eepromAddress = 0; //Location we want the configuration to be stored.
Configuration myConfig;
void writeConfig() {
EEPROM.put(eepromAddress, myConfig);
}
void readConfig() {
EEPROM.get(eepromAddress, myConfig);
}
https://github.com/tzapu/WiFiManager
WiFiManager wifiManager;
wifiManager.setSTAStaticIPConfig(ip, gateway, subnet);
{
//if it does not connect it starts an access point with the specified name
//here "AutoConnectAP" with password "password"
//and goes into a blocking loop awaiting configuration
if (!wifiManager.autoConnect("AutoConnectAP", "password")) {
Serial.println(F("failed to connect, we should reset as see if it connects"));
delay(3000);
ESP.reset();
delay(5000);
}
}