The ESP32 has about 4MB of internal flash memory and since the data stored within the flash memory is retained even when power is recycled, it becomes super useful for applications where you need to keep certain amount of data even after power off. For today’s tutorial, we will learn how to read and write data to the ESP32’s Flash Memory.

The flash memory is similar to the EEPROM memory which is common in most microcontrollers. It is a Non-Volatile memory which means that the data stored, remain even when the ESP undergoes a reset or power is cycled.  This can be very useful in applications where you need to store particular device settings, remember the last state of a particular variable, or store some important runtime data for later use, etc. To give an example, say a piece of equipment being controlled by the ESP32 was ON when power was cut, in most cases, the equipment will stay OFF when power returns depending on the set parameters but with the help of Flash memory, the system can be programmed to return to the last state that was stored.

As cool as non-volatility is, flash memories, however, have a downside which limits their applications; they usually have a fixed number of write operations. Thus the data in flash memories should only be overwritten when it has been compared and a difference has been established.

To demonstrate the use and capabilities of the flash memory, we will build a dimmer circuit in which a potentiometer is used to vary the brightness of an LED and the system is required to remember the brightness level after a reset. Alongside the use of the Flash memory for storage, at the end of this tutorial, you will know how to use an analog sensor with the ESP32 and how PWM works with it.


The following components are required for this project;

  1. ESP32 DOIT DEVKIT V1 Board
  2. Breadboard
  3. 5mm LED
  4. 220 Ohm resistor
  5. 10k Potentiometer
  6. Jumper wires

While the project is based on the DOIT’s ESP32 DevKit V1 board, it should also work with any of the other ESP32 based development boards.


Leave a Comment

Your email address will not be published.

= 4 + 1

(Spamcheck Enabled)

Scroll to Top