Advertisement
sspence65

esp8266 eeprom put

Jun 20th, 2018
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <EEPROM.h>
  2.  
  3. struct MyObject {
  4. char ssid[20]; // 1 more than the length of the array content
  5. char password[20]; // 1 more than the length of the array content
  6.  
  7. };
  8.  
  9. void setup() {
  10.  
  11. Serial.begin(9600);
  12.  
  13. int eeAddress = 0; //Location we want the data to be put.
  14.  
  15. EEPROM.begin(1024);
  16.  
  17. /** Put is designed for use with custom structures also. **/
  18.  
  19. //Data to store.
  20. MyObject customVar = {
  21. "your_ssid",
  22. "your_passwd"
  23. };
  24.  
  25.  
  26. EEPROM.put(eeAddress, customVar);
  27. EEPROM.commit();
  28. Serial.print("Written custom data type! \n\nView the example sketch eeprom_get to see how you can retrieve the values!");
  29. }
  30.  
  31. void loop() {
  32. /* Empty loop */
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement