能源管控程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 26 KiB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. ## ESP_DoubleResetDetector
  2. [![arduino-library-badge](https://www.ardu-badge.com/badge/ESP_DoubleResetDetector.svg?)](https://www.ardu-badge.com/ESP_DoubleResetDetector)
  3. [![GitHub release](https://img.shields.io/github/release/khoih-prog/ESP_DoubleResetDetector.svg)](https://github.com/khoih-prog/ESP_DoubleResetDetector/releases)
  4. [![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/ESP_DoubleResetDetector/blob/master/LICENSE)
  5. [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
  6. [![GitHub issues](https://img.shields.io/github/issues/khoih-prog/ESP_DoubleResetDetector.svg)](http://github.com/khoih-prog/ESP_DoubleResetDetector/issues)
  7. <a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
  8. <a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
  9. ---
  10. ---
  11. ## Table of Contents
  12. * [Why do we need this ESP_DoubleResetDetector library](#why-do-we-need-this-esp_doubleresetdetector-library)
  13. * [Features](#features)
  14. * [Currently supported Boards](#currently-supported-boards)
  15. * [Changelog](changelog.md)
  16. * [Prerequisites](#prerequisites)
  17. * [Installation](#installation)
  18. * [Use Arduino Library Manager](#use-arduino-library-manager)
  19. * [Manual Install](#manual-install)
  20. * [VS Code & PlatformIO](#vs-code--platformio)
  21. * [HOWTO Usage](#howto-usage)
  22. * [Examples](#examples)
  23. * [ 1. ConfigOnDoubleReset](examples/ConfigOnDoubleReset)
  24. * [ 2. ConfigOnDRD_ESP32_minimal](examples/ConfigOnDRD_ESP32_minimal)
  25. * [ 3. ConfigOnDRD_ESP8266_minimal](examples/ConfigOnDRD_ESP8266_minimal)
  26. * [ 4. minimal](examples/minimal)
  27. * [ 5. checkWaitingDRD](examples/checkWaitingDRD) **New**
  28. * [Examples from other libraries](#examples-from-other-libraries)
  29. * [ 1. ESP_WiFiManager Library](https://github.com/khoih-prog/ESP_WiFiManager)
  30. * [ 1. ConfigOnDoubleReset](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDoubleReset)
  31. * [ 2. ConfigOnDRD_FS_MQTT_Ptr](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDRD_FS_MQTT_Ptr)
  32. * [ 3. ESP32_FSWebServer_DRD](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ESP32_FSWebServer_DRD)
  33. * [ 4. ESP_FSWebServer_DRD](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ESP_FSWebServer_DRD)
  34. * [ 5. ConfigOnDRD_ESP32_minimal](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDRD_ESP32_minimal)
  35. * [ 6. ConfigOnDRD_ESP8266_minimal](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDRD_ESP8266_minimal)
  36. * [ 7. ConfigOnDRD_FS_MQTT_Ptr_Complex](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDRD_FS_MQTT_Ptr_Complex)
  37. * [ 8. ConfigOnDRD_FS_MQTT_Ptr_Medium](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDRD_FS_MQTT_Ptr_Medium)
  38. * [ 2. ESPAsync_WiFiManager Library](https://github.com/khoih-prog/ESPAsync_WiFiManager)
  39. * [ 1. Async_ConfigOnDoubleReset](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnDoubleReset)
  40. * [ 2. Async_ConfigOnDRD_FS_MQTT_Ptr](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnDRD_FS_MQTT_Ptr)
  41. * [ 3. Async_ESP32_FSWebServer_DRD](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ESP32_FSWebServer_DRD)
  42. * [ 4. Async_ESP_FSWebServer_DRD](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ESP_FSWebServer_DRD)
  43. * [ 5. Async_ConfigOnDRD_ESP32_minimal](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnDRD_ESP32_minimal)
  44. * [ 6. Async_ConfigOnDRD_ESP8266_minimal](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnDRD_ESP8266_minimal)
  45. * [ 7. Async_ConfigOnDRD_FS_MQTT_Ptr_Complex](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex)
  46. * [ 8. Async_ConfigOnDRD_FS_MQTT_Ptr_Medium](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium)
  47. * [Many other libraries are depending on this library's DRD feature](#many-other-libraries-are-depending-on-this-librarys-drd-feature)
  48. * [ 1. Blynk_WM](https://github.com/khoih-prog/Blynk_WM)
  49. * [ 2. Blynk_Async_WM](https://github.com/khoih-prog/Blynk_Async_WM)
  50. * [ 3. BlynkEthernet_WM](https://github.com/khoih-prog/BlynkEthernet_WM)
  51. * [ 4. BlynkESP32_BT_WF](https://github.com/khoih-prog/BlynkESP32_BT_WF)
  52. * [ 5. BlynkGSM_Manager](https://github.com/khoih-prog/BlynkEthernet_WM)
  53. * [ 6. Blynk_Async_ESP32_BT_WF](https://github.com/khoih-prog/Blynk_Async_ESP32_BT_WF)
  54. * [ 7. Blynk_Async_GSM_Manager](https://github.com/khoih-prog/Blynk_Async_GSM_Manager)
  55. * [ 8. Ethernet_Manager](https://github.com/khoih-prog/Ethernet_Manager)
  56. * [Example checkWaitingDRD](#Example-checkWaitingDRD)
  57. * [Debug Terminal Output Samples](#debug-terminal-output-samples)
  58. * [1. ESP32_FSWebServer_DRD on ESP32_DEV](#1-esp32_fswebserver_drd-on-esp32_dev)
  59. * [2. ConfigOnDoubleReset on ESP32_DEV](#2-configondoublereset-on-esp32_dev)
  60. * [3. ESPAsync_WiFi using LittleFS on ESP32S3_DEV](#3-ESPAsync_WiFi-using-LittleFS-on-ESP32S3_DEV)
  61. * [Libraries using ESP_DoubleResetDetector or DoubleResetDetector_Generic library](#libraries-using-esp_doubleresetdetector-or-doubleresetdetector_generic-library)
  62. * [Debug](#debug)
  63. * [Troubleshooting](#troubleshooting)
  64. * [Issues](#issues)
  65. * [TO DO](#to-do)
  66. * [DONE](#done)
  67. * [Contributions and Thanks](#contributions-and-thanks)
  68. * [Contributing](#contributing)
  69. * [License](#license)
  70. * [Copyright](#copyright)
  71. ---
  72. ---
  73. ### Why do we need this [ESP_DoubleResetDetector library](https://github.com/khoih-prog/ESP_DoubleResetDetector)
  74. #### Features
  75. [**ESP_DoubleResetDetector**](https://github.com/khoih-prog/ESP_DoubleResetDetector) is a library for the **ESP8266 and ESP32** boards to detects a double reset, within configurable timeout (default 10s) seconds, so that an alternative start-up mode can be used. Example use cases are to allow re-configuration of a device's WiFi / MQTT / Blynk credentials.
  76. This library is based on, modified, bug-fixed and improved from [`Stephen Denne's DoubleResetDetector`](https://github.com/datacute/DoubleResetDetector) to add support to ESP8266 and ESP32 using EEPROM, SPIFFS and LittleFS besides original RTC.
  77. Currently, [`DoubleResetDetector`](https://github.com/datacute/DoubleResetDetector) only supports ESP8266 using RTC memory.
  78. This library can be used to detect a double reset within a predetermined time to force the program to enter a special operation such as Config Portal, Clear Default Data, etc., using :
  79. 1. EEPROM, SPIFFS or LittleFS for ESP8266 and ESP32 boards.
  80. 2. RTC memory for ESP8266 boards (unadvised).
  81. #### Currently supported Boards
  82. This [**ESP_DoubleResetDetector** library](https://github.com/khoih-prog/ESP_DoubleResetDetector) currently supports these following boards:
  83. 1. **ESP32, ESP32_C3, ESP32_S2 and ESP32_S3 boards, using EEPROM, SPIFFS or LittleFS**.
  84. 2. **ESP8266 boards RTC memory, EEPROM, SPIFFS or LittleFS**
  85. ---
  86. ---
  87. ## Prerequisites
  88. 1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest)
  89. 2. [`ESP32 Core 2.0.2+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/)
  90. 3. [`ESP8266 Core 3.0.2+`](https://github.com/esp8266/Arduino) for ESP8266-based boards. [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/). SPIFFS is deprecated from ESP8266 core 2.7.1+, to use LittleFS.
  91. 4. [`LittleFS_esp32 v1.0.6+`](https://github.com/lorol/LITTLEFS) for ESP32-based boards using LittleFS with ESP32 core v1.0.5-. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/LittleFS_esp32.svg?)](https://www.ardu-badge.com/LittleFS_esp32). **Notice**: This [`LittleFS_esp32 library`](https://github.com/lorol/LITTLEFS) has been integrated to Arduino [ESP32 core v1.0.6+](https://github.com/espressif/arduino-esp32/tree/master/libraries/LITTLEFS) and you don't need to install it if using ESP32 core v1.0.6+
  92. ---
  93. ---
  94. ## Installation
  95. ### Use Arduino Library Manager
  96. The best and easiest way is to use `Arduino Library Manager`. Search for `ESP_DoubleResetDetector`, then select / install the latest version. You can also use this link [![arduino-library-badge](https://www.ardu-badge.com/badge/ESP_DoubleResetDetector.svg?)](https://www.ardu-badge.com/ESP_DoubleResetDetector) for more detailed instructions.
  97. ### Manual Install
  98. 1. Navigate to [ESP_DoubleResetDetector](https://github.com/khoih-prog/ESP_DoubleResetDetector) page.
  99. 2. Download the latest release `ESP_DoubleResetDetector-master.zip`.
  100. 3. Extract the zip file to `ESP_DoubleResetDetector-master` directory
  101. 4. Copy the whole `ESP_DoubleResetDetector-master` folder to Arduino libraries' directory such as `~/Arduino/libraries/`.
  102. ### VS Code & PlatformIO:
  103. 1. Install [VS Code](https://code.visualstudio.com/)
  104. 2. Install [PlatformIO](https://platformio.org/platformio-ide)
  105. 3. Install [**ESP_DoubleResetDetector** library](https://registry.platformio.org/libraries/khoih-prog/ESP_DoubleResetDetector) by using [Library Manager](https://registry.platformio.org/libraries/khoih-prog/ESP_DoubleResetDetector/installation). Search for **ESP_DoubleResetDetector** in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22)
  106. 4. Use included [platformio.ini](platformio/platformio.ini) file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at [Project Configuration File](https://docs.platformio.org/page/projectconf.html)
  107. ---
  108. ---
  109. #### HOWTO Usage
  110. How to use
  111. ```cpp
  112. // These defines must be put before #include <ESP_DoubleResetDetector.h>
  113. // to select where to store DoubleResetDetector's variable.
  114. // For ESP32, You must select one to be true (EEPROM or SPIFFS)
  115. // For ESP8266, You must select one to be true (RTC, EEPROM, LITTLEFS or SPIFFS)
  116. // Otherwise, library will use default EEPROM storage
  117. #ifdef ESP8266
  118. #define ESP8266_DRD_USE_RTC false //true
  119. #define ESP_DRD_USE_LITTLEFS true //false
  120. #endif
  121. #define ESP_DRD_USE_EEPROM false
  122. #define ESP_DRD_USE_SPIFFS true
  123. #define DOUBLERESETDETECTOR_DEBUG true //false
  124. #include <ESP_DoubleResetDetector.h> //https://github.com/khoih-prog/ESP_DoubleResetDetector
  125. // Number of seconds after reset during which a
  126. // subseqent reset will be considered a double reset.
  127. #define DRD_TIMEOUT 10
  128. // RTC Memory Address for the DoubleResetDetector to use
  129. #define DRD_ADDRESS 0
  130. DoubleResetDetector* drd;
  131. #ifdef ESP32
  132. // For ESP32
  133. #ifndef LED_BUILTIN
  134. #define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
  135. #endif
  136. #define LED_OFF LOW
  137. #define LED_ON HIGH
  138. #else
  139. // For ESP8266
  140. #define LED_ON LOW
  141. #define LED_OFF HIGH
  142. #endif
  143. void setup()
  144. {
  145. pinMode(LED_BUILTIN, OUTPUT);
  146. Serial.begin(115200);
  147. Serial.println("\nStarting minimal example for ESP_DoubleResetDetector");
  148. drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
  149. if (drd->detectDoubleReset())
  150. {
  151. Serial.println("Double Reset Detected");
  152. digitalWrite(LED_BUILTIN, LED_ON);
  153. }
  154. else
  155. {
  156. Serial.println("No Double Reset Detected");
  157. digitalWrite(LED_BUILTIN, LED_OFF);
  158. }
  159. }
  160. void loop()
  161. {
  162. // Call the double reset detector loop method every so often,
  163. // so that it can recognise when the timeout expires.
  164. // You can also call drd.stop() when you wish to no longer
  165. // consider the next reset as a double reset.
  166. drd->loop();
  167. }
  168. ```
  169. ---
  170. ---
  171. ### Examples
  172. 1. [ConfigOnDoubleReset](examples/ConfigOnDoubleReset)
  173. 2. [ConfigOnDRD_ESP32_minimal](examples/ConfigOnDRD_ESP32_minimal)
  174. 3. [ConfigOnDRD_ESP8266_minimal](examples/ConfigOnDRD_ESP8266_minimal)
  175. 4. [minimal](examples/minimal)
  176. ### Examples from other libraries
  177. #### 1.[ESP_WiFiManager Library](https://github.com/khoih-prog/ESP_WiFiManager)
  178. * [ 1. ConfigOnDoubleReset](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDoubleReset)
  179. * [ 2. ConfigOnDRD_FS_MQTT_Ptr](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDRD_FS_MQTT_Ptr)
  180. * [ 3. ESP32_FSWebServer_DRD](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ESP32_FSWebServer_DRD)
  181. * [ 4. ESP_FSWebServer_DRD](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ESP_FSWebServer_DRD)
  182. * [ 5. ConfigOnDRD_ESP32_minimal](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDRD_ESP32_minimal)
  183. * [ 6. ConfigOnDRD_ESP8266_minimal](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDRD_ESP8266_minimal)
  184. * [ 7. ConfigOnDRD_FS_MQTT_Ptr_Complex](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDRD_FS_MQTT_Ptr_Complex)
  185. * [ 8. ConfigOnDRD_FS_MQTT_Ptr_Medium](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDRD_FS_MQTT_Ptr_Medium)
  186. #### 2. [ESPAsync_WiFiManager Library](https://github.com/khoih-prog/ESPAsync_WiFiManager)
  187. * [ 1. Async_ConfigOnDoubleReset](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnDoubleReset)
  188. * [ 2. Async_ConfigOnDRD_FS_MQTT_Ptr](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnDRD_FS_MQTT_Ptr)
  189. * [ 3. Async_ESP32_FSWebServer_DRD](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ESP32_FSWebServer_DRD)
  190. * [ 4. Async_ESP_FSWebServer_DRD](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ESP_FSWebServer_DRD)
  191. * [ 5. Async_ConfigOnDRD_ESP32_minimal](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnDRD_ESP32_minimal)
  192. * [ 6. Async_ConfigOnDRD_ESP8266_minimal](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnDRD_ESP8266_minimal)
  193. * [ 7. Async_ConfigOnDRD_FS_MQTT_Ptr_Complex](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex)
  194. * [ 8. Async_ConfigOnDRD_FS_MQTT_Ptr_Medium](https://github.com/khoih-prog/ESPAsync_WiFiManager/tree/master/examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium)
  195. and there are many more.
  196. #### Many other libraries are depending on this library's DRD feature
  197. All examples of these following libraries are using DRD feature of this [ESP_DoubleResetDetector Library](https://github.com/khoih-prog/ESP_DoubleResetDetector)
  198. * [ 1. Blynk_WM](https://github.com/khoih-prog/Blynk_WM)
  199. * [ 2. Blynk_Async_WM](https://github.com/khoih-prog/Blynk_Async_WM)
  200. * [ 3. BlynkEthernet_WM](https://github.com/khoih-prog/BlynkEthernet_WM)
  201. * [ 4. BlynkESP32_BT_WF](https://github.com/khoih-prog/BlynkESP32_BT_WF)
  202. * [ 5. BlynkGSM_Manager](https://github.com/khoih-prog/BlynkEthernet_WM)
  203. * [ 6. Blynk_Async_ESP32_BT_WF](https://github.com/khoih-prog/Blynk_Async_ESP32_BT_WF)
  204. * [ 7. Blynk_Async_GSM_Manager](https://github.com/khoih-prog/Blynk_Async_GSM_Manager)
  205. * [ 8. Ethernet_Manager](https://github.com/khoih-prog/Ethernet_Manager)
  206. ---
  207. ---
  208. ### Example [checkWaitingDRD](examples/checkWaitingDRD)
  209. https://github.com/khoih-prog/ESP_DoubleResetDetector/blob/28a1b81298cd5b9c2ffabe35e60cffa1874ec837/examples/checkWaitingDRD/checkWaitingDRD.ino#L20-L132
  210. ---
  211. ---
  212. ### Debug Terminal Output Samples
  213. #### 1. ESP32_FSWebServer_DRD on ESP32_DEV
  214. This is terminal debug output when running [ESP32_FSWebServer_DRD](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ESP32_FSWebServer_DRD) on **ESP32 ESP32_DEV.**. Config Portal was requested by DRD to input and save Credentials. The boards then connected to WiFi AP **HueNet1** using new Static IP successfully. WiFi AP **HueNet1** is then lost, and board **autoreconnects** itself to backup WiFi AP **HueNet2**.
  215. ```cpp
  216. Starting ESP32_FSWebServer_DRD with DoubleResetDetect using SPIFFS on ESP32_DEV
  217. ESP_WiFiManager v1.10.1
  218. ESP_DoubleResetDetector v1.3.1
  219. FS File: /ConfigSW.json, size: 150B
  220. FS File: /CanadaFlag_1.png, size: 40.25KB
  221. FS File: /CanadaFlag_2.png, size: 8.12KB
  222. FS File: /CanadaFlag_3.jpg, size: 10.89KB
  223. FS File: /edit.htm.gz, size: 4.02KB
  224. FS File: /favicon.ico, size: 1.12KB
  225. FS File: /graphs.js.gz, size: 1.92KB
  226. FS File: /index.htm, size: 3.63KB
  227. FS File: /drd.dat, size: 4B
  228. FS File: /wifi_cred.dat, size: 192B
  229. [WM] RFC925 Hostname = ESP32-FSWebServerDRD
  230. [WM] setAPStaticIPConfig
  231. [WM] setSTAStaticIPConfig for USE_CONFIGURABLE_DNS
  232. [WM] Set CORS Header to : Your Access-Control-Allow-Origin
  233. Stored: SSID = HueNet2, Pass = 12345678
  234. [WM] * Add SSID = HueNet2 , PW = 12345678
  235. Got stored Credentials. Timeout 120s for Config Portal
  236. SPIFFS Flag read = 0xd0d04321
  237. No doubleResetDetected
  238. Saving config file...
  239. Saving config file OK
  240. [WM] LoadWiFiCfgFile
  241. [WM] OK
  242. [WM] * Add SSID = HueNet1 , PW = 12345678
  243. [WM] * Add SSID = HueNet2 , PW = 12345678
  244. ConnectMultiWiFi in setup
  245. [WM] ConnectMultiWiFi with :
  246. [WM] * Flash-stored Router_SSID = HueNet2 , Router_Pass = 12345678
  247. [WM] * Additional SSID = HueNet1 , PW = 12345678
  248. [WM] * Additional SSID = HueNet2 , PW = 12345678
  249. [WM] Connecting MultiWifi...
  250. [WM] WiFi connected after time: 1
  251. [WM] SSID: HueNet1 ,RSSI= -27
  252. [WM] Channel: 2 ,IP address: 192.168.2.232
  253. After waiting 3.16 secs more in setup(), connection result is connected. Local IP: 192.168.2.232
  254. HTTP server started @ 192.168.2.232
  255. Open http://esp32-fs-browser.local/edit to see the file browser
  256. [WM] freeing allocated params!
  257. Stop doubleResetDetecting
  258. Saving config file...
  259. Saving config file OK
  260. WiFi lost. Call connectMultiWiFi in loop
  261. [WM] ConnectMultiWiFi with :
  262. [WM] * Flash-stored Router_SSID = HueNet2 , Router_Pass = 12345678
  263. [WM] * Additional SSID = HueNet1 , PW = 12345678
  264. [WM] * Additional SSID = HueNet2 , PW = 12345678
  265. [WM] Connecting MultiWifi...
  266. [WM] WiFi connected after time: 3
  267. [WM] SSID: HueNet2 ,RSSI= -59
  268. [WM] Channel: 4 ,IP address: 192.168.2.232
  269. HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH
  270. ```
  271. ---
  272. #### 2. ConfigOnDoubleReset on ESP32_DEV
  273. This is terminal debug output when running [ConfigOnDoubleReset](https://github.com/khoih-prog/ESP_WiFiManager/tree/master/examples/ConfigOnDoubleReset) on **ESP32 ESP32_DEV.**. Config Portal was requested by DRD to input and save Credentials.
  274. ```
  275. Starting ConfigOnDoubleReset with DoubleResetDetect using LittleFS on ESP32_DEV
  276. ESP_WiFiManager v1.10.1
  277. ESP_DoubleResetDetector v1.3.1
  278. [WM] RFC925 Hostname = ConfigOnDoubleReset
  279. [WM] Set CORS Header to : Your Access-Control-Allow-Origin
  280. Stored: SSID = HueNet1, Pass = 12345678
  281. [WM] * Add SSID = HueNet1 , PW = 87654321
  282. Got stored Credentials. Timeout 120s for Config Portal
  283. LittleFS Flag read = 0xd0d04321
  284. No doubleResetDetected
  285. Saving config file...
  286. Saving config file OK
  287. [WM] LoadWiFiCfgFile
  288. [WM] OK
  289. [WM] * Add SSID = HueNet1 , PW = jenniqqs
  290. [WM] * Add SSID = HueNet2 , PW = jenniqqs
  291. ConnectMultiWiFi in setup
  292. [WM] ConnectMultiWiFi with :
  293. [WM] * Flash-stored Router_SSID = HueNet1 , Router_Pass = jenniqqs
  294. [WM] * Additional SSID = HueNet1 , PW = 12345678
  295. [WM] * Additional SSID = HueNet2 , PW = 87654321
  296. [WM] Connecting MultiWifi...
  297. [WM] WiFi connected after time: 1
  298. [WM] SSID: HueNet1 ,RSSI= -32
  299. [WM] Channel: 2 ,IP address: 192.168.2.101
  300. After waiting 4.43 secs more in setup(), connection result is connected. Local IP: 192.168.2.101
  301. [WM] freeing allocated params!
  302. HStop doubleResetDetecting
  303. Saving config file...
  304. Saving config file OK
  305. HHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH
  306. rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  307. configsip: 0, SPIWP:0xee
  308. clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  309. mode:DIO, clock div:1
  310. load:0x3fff0018,len:4
  311. load:0x3fff001c,len:1216
  312. ho 0 tail 12 room 4
  313. load:0x40078000,len:9720
  314. ho 0 tail 12 room 4
  315. load:0x40080400,len:6352
  316. entry 0x400806b8
  317. Starting ConfigOnDoubleReset with DoubleResetDetect using LittleFS on ESP32_DEV
  318. ESP_WiFiManager Version v1.10.1
  319. ESP_DoubleResetDetector Version v1.3.1
  320. [WM] RFC925 Hostname = ConfigOnDoubleReset
  321. [WM] Set CORS Header to : Your Access-Control-Allow-Origin
  322. Stored: SSID = HueNet1, Pass = jenniqqs
  323. [WM] * Add SSID = HueNet1 , PW = jenniqqs
  324. Got stored Credentials. Timeout 120s for Config Portal
  325. LittleFS Flag read = 0xd0d01234
  326. doubleResetDetected
  327. Saving config file...
  328. Saving config file OK
  329. Open Config Portal without Timeout: Double Reset Detected
  330. Starting configuration portal.
  331. [WM] WiFi.waitForConnectResult Done
  332. [WM] SET AP
  333. [WM] Configuring AP SSID = ESP_9ABF498
  334. [WM] AP PWD = your_password
  335. [WM] AP Channel = 3
  336. [WM] AP IP address = 192.168.4.1
  337. [WM] HTTP server started
  338. [WM] ESP_WiFiManager::startConfigPortal : Enter loop
  339. ```
  340. ---
  341. #### 3. ESPAsync_WiFi using LittleFS on ESP32S3_DEV
  342. This is terminal debug output when running [ESPAsync_WiFi](https://github.com/khoih-prog/ESPAsync_WiFiManager_Lite/tree/master/examples/ESPAsync_WiFi) on **ESP32 ESP32S3_DEV.**. Config Portal was requested by DRD to input and save Credentials.
  343. ```
  344. Starting ESPAsync_WiFi using LittleFS on ESP32S3_DEV
  345. ESPAsync_WiFiManager_Lite v1.8.2
  346. ESP_DoubleResetDetector v1.3.1
  347. LittleFS Flag read = 0xD0D01234
  348. doubleResetDetected
  349. Saving config file...
  350. Saving config file OK
  351. [WML] Hdr=ESP_WM_LITE,SSID=HueNet1,PW=12345678
  352. [WML] SSID1=HueNet2,PW1=12345678
  353. [WML] BName=ESP32_S3
  354. [WML] Hdr=ESP_WM_LITE,SSID=HueNet1,PW=12345678
  355. [WML] SSID1=HueNet2,PW1=12345678
  356. [WML] BName=ESP32_S3
  357. [WML] WiFi networks found:
  358. [WML] 1: HueNet, -20dB
  359. [WML] 2: HueNetTek, -32dB
  360. [WML] 3: HueNet1, -39dB
  361. [WML] 4: HueNet2, -54dB
  362. [WML] 5: DECO-5655, -72dB
  363. [WML] 6: Guest5655, -72dB
  364. [WML] 7: rogers786, -76dB
  365. [WML] 8: AT_301_WLREL6325F_f66d, -76dB
  366. [WML] 10: Rogers 786, -78dB
  367. [WML] 11: BELL042, -80dB
  368. [WML] 12: WirelessMississauga, -82dB
  369. [WML] 13: SmartRG-02a2, -87dB
  370. [WML] 14: Jasmine, -87dB
  371. [WML] 15: Access, -89dB
  372. [WML] 16: Jessie, -90dB
  373. [WML]
  374. stConf:SSID=ESP_E1A1DF7C,PW=MyESP_E1A1DF7C
  375. [WML] IP=192.168.4.1,ch=10
  376. F
  377. Your stored Credentials :
  378. Blynk Server1 = account.duckdns.org
  379. Token1 = token1
  380. Blynk Server2 = account.ddns.net
  381. Token2 = token2
  382. Port = 8080
  383. MQTT Server = mqtt.duckdns.org
  384. ```
  385. ---
  386. ### Libraries using ESP_DoubleResetDetector or DoubleResetDetector_Generic library
  387. You can also see how [`ESP_DoubleResetDetector`](https://github.com/khoih-prog/ESP_DoubleResetDetector) and [`DoubleResetDetector_Generic`](https://github.com/khoih-prog/DoubleResetDetector_Generic) are applied in many other libraries, such as:
  388. 1. [Blynk_WM](https://github.com/khoih-prog/Blynk_WM)
  389. 2. [BlynkEthernet_WM](https://github.com/khoih-prog/BlynkEthernet_WM)
  390. 3. [WiFiManager_NINA_Lite](https://github.com/khoih-prog/WiFiManager_NINA_Lite)
  391. 4. [BlynkESP32_BT_WF](https://github.com/khoih-prog/BlynkESP32_BT_WF),
  392. 5. [Blynk_GSM_Manager](https://github.com/khoih-prog/Blynk_GSM_Manager),
  393. 6. [Blynk_Esp8266AT_WM](https://github.com/khoih-prog/Blynk_Esp8266AT_WM),
  394. 7. [Blynk_WiFiNINA_WM](https://github.com/khoih-prog/Blynk_WiFiNINA_WM),
  395. 8. [Blynk_Async_WM](https://github.com/khoih-prog/Blynk_Async_WM),
  396. 9. [Blynk_Async_ESP32_BT_WF](https://github.com/khoih-prog/Blynk_Async_ESP32_BT_WF),
  397. 10. [Blynk_Async_GSM_Manager](https://github.com/khoih-prog/Blynk_Async_GSM_Manager),
  398. 11. [ESP_WiFiManager](https://github.com/khoih-prog/ESP_WiFiManager)
  399. 12. [ESPAsync_WiFiManager](https://github.com/khoih-prog/ESPAsync_WiFiManager)
  400. 13. [WiFiManager_NINA_Lite](https://github.com/khoih-prog/WiFiManager_NINA_Lite)
  401. 14. [BlynkEthernet_STM32_WM](https://github.com/khoih-prog/BlynkEthernet_STM32_WM),
  402. 15. [ESP_AT_WM_Lite](https://github.com/khoih-prog/ESP_AT_WM_Lite)
  403. 16. [WIOTerminal_WiFiManager](https://github.com/khoih-prog/WIOTerminal_WiFiManager)
  404. 17. [Ethernet_Manager](https://github.com/khoih-prog/Ethernet_Manager)
  405. 18. [Ethernet_Manager_STM32](https://github.com/khoih-prog/Ethernet_Manager_STM32)
  406. and the list is growing fast.
  407. ---
  408. ---
  409. ### Debug
  410. Debug is disabled by default. To enable debug:
  411. ```cpp
  412. // Use this to output debug msgs to Serial
  413. #define DOUBLERESETDETECTOR_DEBUG true
  414. ```
  415. ---
  416. ### Troubleshooting
  417. If you get compilation errors, more often than not, you may need to install a newer version of the `ESP32 / ESP8266` core for Arduino.
  418. Sometimes, the library will only work if you update the `ESP32 / ESP8266` core to the latest version because I am using some newly added function.
  419. ---
  420. ---
  421. ### Issues ###
  422. Submit issues to: [ESP_DoubleResetDetector issues](https://github.com/khoih-prog/ESP_DoubleResetDetector/issues)
  423. ---
  424. ---
  425. ### TO DO
  426. 1. Search for bug and improvement.
  427. ### DONE
  428. 1. For ESP32 and ESP8266 (EEPROM, SPIFFS and LittleFS).
  429. 2. Similar features for Arduino (UNO, Mega, SAM DUE, SAMD21/SAMD51, nRF52, STM32, Teensy, etc.). Look at [**DoubleResetDetector_Generic**](https://github.com/khoih-prog/DoubleResetDetector_Generic)
  430. 3. Add support to `ESP32_C3`, `ESP32_S2`
  431. 4. Add support to `ESP32_S3` using ESP32 core v2.0.2+
  432. ---
  433. ---
  434. ### Contributions and thanks
  435. 1. Thanks to [zobix](https://github.com/zobix) for report the bug in [Isssue 2](https://github.com/khoih-prog/ESP_DoubleResetDetector/issues/2)
  436. 1. Thanks to [Tochi Moreno](https://github.com/tochimoreno) for enhancement request in [DRD is waiting for a double reset? #14](https://github.com/khoih-prog/ESP_DoubleResetDetector/discussions/14) leading to v1.3.1 to add `waitingForDRD()` function to signal in DRD wating period
  437. <table>
  438. <tr>
  439. <td align="center"><a href="https://github.com/zobix"><img src="https://github.com/zobix.png" width="100px;" alt="zobix"/><br /><sub><b>Zobix</b></sub></a><br /></td>
  440. <td align="center"><a href="https://github.com/tochimoreno"><img src="https://github.com/tochimoreno.png" width="100px;" alt="tochimoreno"/><br /><sub><b>Tochi Moreno</b></sub></a><br /></td>
  441. </tr>
  442. </table>
  443. ---
  444. ### Contributing
  445. If you want to contribute to this project:
  446. - Report bugs and errors
  447. - Ask for enhancements
  448. - Create issues and pull requests
  449. - Tell other people about this library
  450. ---
  451. ### License
  452. - The library is licensed under [MIT](https://github.com/khoih-prog/ESP_DoubleResetDetector/blob/master/LICENSE)
  453. ---
  454. ### Copyright
  455. Copyright 2019- Khoi Hoang