The use of the ESP8266 in the world of IoT

User avatar
By khoih-prog

You can install directly from Arduino Library Manager

This library is based on, modified, bug-fixed and improved from [`DataCute`]( to add support for ESP32 and ESP8266.

Using this library to detect a double reset, using

1. RTC Memory, EEPROM or SPIFFS for ESP8266
2. EEPROM and SPIFFS for ESP32.

New in v1.0.1

1. Add EEPROM and SPIFFS support, besides RTC memory, for ESP8266
2. Add SPIFFS support, besides EEPROM, for ESP32


Detects a double reset so that an alternative start-up mode can be used. One example use is to allow re-configuration of a device's wifi credentials.


How to use

Code: Select all// These defines must be put before #include <ESP_DoubleResetDetector.h>
// to select where to store DoubleResetDetector's variable.
// For ESP32, You must select one to be true (EEPROM or SPIFFS)
// For ESP8266, You must select one to be true (RTC, EEPROM or SPIFFS)
// Otherwise, library will use default EEPROM storage
#define ESP_DRD_USE_EEPROM      false
#define ESP_DRD_USE_SPIFFS      true    //false

#ifdef ESP8266
  #define ESP8266_DRD_USE_RTC     false   //true

#define DOUBLERESETDETECTOR_DEBUG       true  //false

#include <ESP_DoubleResetDetector.h>      //

// Number of seconds after reset during which a
// subseqent reset will be considered a double reset.
#define DRD_TIMEOUT 10

// RTC Memory Address for the DoubleResetDetector to use
#define DRD_ADDRESS 0

DoubleResetDetector* drd;

void setup()
  drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);

  if (drd->detectDoubleReset())
    Serial.println("Double Reset Detected");
    digitalWrite(LED_BUILTIN, LOW);
    Serial.println("No Double Reset Detected");
    digitalWrite(LED_BUILTIN, HIGH);

void loop()
  // Call the double reset detector loop method every so often,
  // so that it can recognise when the timeout expires.
  // You can also call drd.stop() when you wish to no longer
  // consider the next reset as a double reset.