Esp32

ESP32 Software Reset Using ESP.restart(); Function in Arduino IDE

ESP32 is a microcontroller board that can be controlled using Arduino programming. Multiple functions used inside Arduino code can be used with ESP32 boards. Today this article will cover a code to software reset ESP32 using Arduino IDE.

What Is Software Reset

Most ESP32 boards come with an on board reset button. By pressing that button any data inside the flashed memory remains there because of non-volatile memory. Flash memory and EEPROM work the same way. These are non-volatile memories which means whatever data is saved isn’t removed even if the board is reset or restart.

However, any data stored inside the RAM will be lost because of volatile nature.

Not all ESP32 comes with a reset button so we have to reset them manually or by using a few lines of code. Software reset is another way of resetting the ESP32 board at the desired time interval. Now we will look at ESP32 reset code in detail.

How to Software Reset ESP32 Using Arduino IDE Code

For software reset we will use the ESP.restart(); function in Arduino IDE code. By giving a delay inside Arduino code this function will automatically reset the ESP32 board.

Code

Open Arduino IDE and paste the given code in the editor. After that select ESP32 board and upload it.

void setup() {

  Serial.begin(115200);    /*Baud rate defined for serial communication*/
 
  Serial.println("Restarting in 10 seconds");  
 
  delay(10000);  /*ESP32 Reset after every 10 sec*/
 
  ESP.restart();  /*ESP restart function*/

}

void loop() {  }

 

Code is simple in working. We just initialized the serial communication by defining the baud rate. This will help to see the output every time ESP32 resets.

Delay of 10 sec is given. After the delay time the ESP32 board will automatically reset using the ESP.restart(); function.

Any time interval can be set after which ESP32 can be reset however we can also use the external interrupt with ESP32 that reset it such as push button or touch sensor.

Demonstration

Here in the output, we can see the serial monitor of Arduino IDE. After every 10 sec ESP32 restarts itself meaning it clears its RAM. This is similar to restarting ESP32 or removing the power of ESP32 board.

Conclusion

Software reset helps to clear the RAM without any need of a physical button. If your ESP32 board doesn’t have this RESET button using the given code, we can easily restart or RESET ESP32 at any defined time period.

About the author

Kashif

I am an Electrical Engineer. I love to write about electronics. I am passionate about writing and sharing new ideas related to emerging technologies in the field of electronics.