The objective of this post is to explain how to perform a software reset on the ESP32, using the Arduino core. The tests of this ESP32 tutorial were performed using a DFRobot’s ESP-WROOM-32 device integrated in a ESP32 FireBeetle board.
Introduction
The objective of this post is to explain how to perform a software reset on the ESP32, using the Arduino core.
The tests of this ESP32 tutorial were performed using a DFRobot’s ESP-WROOM-32 device integrated in a ESP32 FireBeetle board.
If you prefer a video version of this tutorial, please check my YouTube channel below.
The Arduino code
We will start our Setup function code by opening a Serial connection, so we can output a message indicating the program has started.
Serial.begin(115200);
We will then print the mentioned message to the serial port, so we can know when the ESP32 has been restarted and is running again from the beginning.
Serial.println("Restarting in 10 seconds");
After that we will do a small 10 seconds delay before we actually restart the device. To do so, we simply call the delay function, which receives as input the number of microseconds to wait.
delay(10000);
Finally, we will restart the ESP32 with a call to the restart method on the ESP object. This method receives no parameters and returns void.
This ESP object is an extern variable of class EspClass, defined here. You can check at the previous link some other interesting system functions exposed by this object.
Note that we don’t need to perform any library include to access this object, which is available by default.
ESP.restart();
The final full Arduino code can be seen below.
void setup() { Serial.begin(115200); Serial.println("Restarting in 10 seconds"); delay(10000); ESP.restart(); } void loop() {}
Testing the code
To test the code, simply compile it and upload it to your ESP32 board. Then, open the Arduino IDE serial monitor.
You should get an output similar to figure 1, which shows the initial serial print of the program multiple times, meaning that the ESP32 is indeed being reset and the program is running again from the beginning.
Figure 1 – Restarting the ESP32 via software.
Pingback: ESP32 Arduino: Software reset – Arduino Boards News
Pingback: ESP32 Arduino: Software reset – Arduino Boards News
Pingback: ESP8266 Arduino: Software restart | techtutorialsx
Pingback: ESP8266 Arduino: Software restart | techtutorialsx
Thanks a lot. Was searching for exactly this…
Thanks a lot. Was searching for exactly this…
Pingback: ESP32 Arduino web server: Get free heap and reset device remotely | techtutorialsx
Pingback: ESP32 Arduino web server: Get free heap and reset device remotely | techtutorialsx
This reset is not always enough. I have an esp-sketch which is set to reboot in 30 seconds if wifi does not connect. Sometimes it still fails to connect, and reboots over and over. Power-cycling it got it onine after a few minutes.
Thanks for this!