Re: Storing WiFi credentials in flash memory on a Wemod D1 R
![Post Post](./styles/FLATBOOTS/imageset/icon_post_target.gif)
Thanks for replying to this. I ended up writing my configuration struct to eeprom memory. Turns out to be quite simple. Here is a code snippet for anyone else that may have the same question I did:
Code: Select all
#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);
}