• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

writing and reading to EEPROM on ESP32 not working

Q&A Forum › writing and reading to EEPROM on ESP32 not working
0 Vote Up Vote Down
f.mentiplay asked 3 years ago
7 Answers
0 Vote Up Vote Down
f.mentiplay answered 3 years ago

I read your great article on Preferences, reading/writing to ESP32. I have a NodeMCU-32S board.
Using the simply example in the article I was not able to read/write to the EEPROM. After a reboot the counter does not increase.  
Should your code work on a NodeMCU-32S board?
Regards Frank

0 Vote Up Vote Down
Bernie answered 3 years ago

I believe it should work on NodeMCU.  As there is no EEPROM on the MCU, the flash memory is used instead.  I can’t find the code, but I once converted the Arduino EEPROM functions to the ESP32 and it worked fine.  Just that you don’t want to flash too many times.

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
Yes, the code should work on any ESP32 board.
Do you get any more information on the Serial Monitor? Did you change anything on the code?
Regards,
Sara

0 Vote Up Vote Down
f.mentiplay answered 3 years ago

Hi Sara
Thank you and Bernie foe replying to my question.
To answer your question. I did not change anything in the code. The code is from your perference article.
/*
ESP32 startup counter example with Preferences library.
This simple example demonstrates using the Preferences library to store how many times the ESP32 module has booted.
The Preferences library is a wrapper around the Non-volatile storage on ESP32 processor.
created for arduino-esp32 09 Feb 2017 by Martin Sloup (Arcao)

Complete project details at https://RandomNerdTutorials.com/esp32-save-data-permanently-preferences/
*/
Here is the output from the serial monitor. After every software reboot the serial monitor reports the current counter value as 1. It never increases.
08:34:20.300 -> Restarting in 10 seconds…
08:34:30.329 -> ets Jun 8 2016 00:22:57
08:34:30.329 ->
08:34:30.329 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
08:34:30.329 -> configsip: 0, SPIWP:0xee
08:34:30.329 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
08:34:30.329 -> mode:DIO, clock div:1
08:34:30.329 -> load:0x3fff0018,len:4
08:34:30.329 -> load:0x3fff001c,len:1044
08:34:30.329 -> load:0x40078000,len:10124
08:34:30.329 -> load:0x40080400,len:5856
08:34:30.329 -> entry 0x400806a8
08:34:30.562 ->
08:34:30.562 -> Current counter value: 1
08:34:30.562 -> Restarting in 10 seconds…
I do not know what next to try. Any help gratefully received.
Regards Frank

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
I just checked the code and it is working fine on my DOIT ESP32 board.
I don’t have a  NodeMCU-32S board to experiment with, so I’m not sure if it is any problem related to that specific board.
Which board are you selecting in Tools > Board?
Regards,
Sara

0 Vote Up Vote Down
f.mentiplay answered 3 years ago

Hi Sara
I went and got an ESP32 DEv board (the 30 pin wider one, I think you use this one) and it worked.
The counter increased after every reset. Looks like Bernie was right and the NodeMCU-32S board doesn’t have EEPROM or is not being used.
Any way problem solved.  I think it would make an interesting article. “What are the differences between ESP32 boards”
Regards Frank

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
Thanks for sharing that.
I didn’t know that about that board. Now I know it is not compatible with that tutorial.
I’ll close this issue.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.