I'm working with ESP32 Wroom-32 and AHT25 temperature and humidity sensors. I need to store the temperature and humidity data using EEPROM.

I don't think ESP32 has internal EEPROM. If not means how can I store the data using external EEPROM?


1 Answer 1


ESP32 doesn't have EEPROM.

The main practical differences between EEPROM and Flash is that EEPROM is slower, can be erased byte by byte, and has much higher write endurance.

If you want to write data every few seconds to non-volatile memory, EEPROM is a much better choice. Flash with a filesystem like SPIFFS would erase and rewrite at least a page every time so that would quickly wear down the flash chip.

However, ESP32 has 8kB of RTC SRAM. This is SRAM so it's fast with unlimited write endurance. Of course it will lose its contents if the chip loses power, but this particular chunk of RAM is on the RTC (real time clock) power domain. Contents are preserved if the chip resets or goes to deep sleep (unlike the rest of the RAM which loses contents in deep sleep).

If your circuit is battery powered and makes use of deep sleep, RTC RAM is a good choice to store your logged data. Besides, in this case, you'll also need the RTC to keep time. When you have enough data stored in RTC RAM to write a full page of Flash, then you can do so, this will reduce the number of Flash writes and solve the write endurance problem.

If you don't have a battery, you can add a capacitor to your power supply to keep ESP32 alive long enough in case power is lost to write to Flash. But, if you don't have a battery, and you need the correct time of day for your data logging, then you need WiFi to update the time via NTP. So you may as well export the data live by wifi and save it on a server instead.

Another solution is a I2C EEPROM chip.

  • \$\begingroup\$ Sure Flash needs to be erased in pages, but what prevents writing byte at a time? \$\endgroup\$
    – Justme
    Jul 6, 2023 at 17:01
  • \$\begingroup\$ Erasing turns all bits into ones. If you don't use a filesystem you can write byte by byte (or even bit by bit) but you can only write zero bits ! So you need a specific format that can tell where the end of the write was. Plain text would be fine because line ends contain zero bits. If you use a filesystem it will probably want to update fields like file size, date, etc on every write so that won't work. \$\endgroup\$
    – bobflux
    Jul 6, 2023 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.