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?
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.
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?
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 -> 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 -> Current counter value: 1
08:34:30.562 -> Restarting in 10 seconds…
I do not know what next to try. Any help gratefully received.
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?
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”