|
1 | 1 | /**************************************************************************************************************************** |
2 | | - ESP8266WM_Config.ino |
| 2 | + ESP8266WM_ForcedConfig.ino |
3 | 3 | For ESP8266 boards |
4 | 4 |
|
5 | 5 | Blynk_WM is a library for the ESP8266/ESP32 Arduino platform (https://github.com/esp8266/Arduino) to enable easy |
@@ -42,6 +42,39 @@ DHT dht(DHT_PIN, DHT_TYPE); |
42 | 42 | BlynkTimer timer; |
43 | 43 | Ticker led_ticker; |
44 | 44 |
|
| 45 | +#define BLYNK_PIN_FORCED_CONFIG V10 |
| 46 | +#define BLYNK_PIN_FORCED_PERS_CONFIG V20 |
| 47 | + |
| 48 | +// Use button V10 (BLYNK_PIN_FORCED_CONFIG) to forced Config Portal |
| 49 | +BLYNK_WRITE(BLYNK_PIN_FORCED_CONFIG) |
| 50 | +{ |
| 51 | + if (param.asInt()) |
| 52 | + { |
| 53 | + Serial.println( "CP Button Hit. Rebooting" ); |
| 54 | + |
| 55 | + // This will keep CP once, clear after reset, even you didn't enter CP at all. |
| 56 | + Blynk.resetAndEnterConfigPortal(); |
| 57 | + |
| 58 | + delay ( 8000 ); |
| 59 | + ESP.restart(); |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +// Use button V20 (BLYNK_PIN_FORCED_PERS_CONFIG) to forced Persistent Config Portal |
| 64 | +BLYNK_WRITE(BLYNK_PIN_FORCED_PERS_CONFIG) |
| 65 | +{ |
| 66 | + if (param.asInt()) |
| 67 | + { |
| 68 | + Serial.println( "Persistent CP Button Hit. Rebooting" ); |
| 69 | + |
| 70 | + // This will keep CP forever, until you successfully enter CP, and Save data to clear the flag. |
| 71 | + Blynk.resetAndEnterConfigPortalPersistent(); |
| 72 | + |
| 73 | + delay ( 8000 ); |
| 74 | + ESP.restart(); |
| 75 | + } |
| 76 | +} |
| 77 | + |
45 | 78 | void readAndSendData() |
46 | 79 | { |
47 | 80 | float temperature = dht.readTemperature(); |
@@ -123,10 +156,10 @@ void setup() |
123 | 156 | delay(200); |
124 | 157 |
|
125 | 158 | #if ( USE_LITTLEFS || USE_SPIFFS) |
126 | | - Serial.print(F("\nStarting ESP8266WM_Config using ")); |
| 159 | + Serial.print(F("\nStarting ESP8266WM_ForcedConfig using ")); |
127 | 160 | Serial.print(CurrentFileFS); |
128 | 161 | #else |
129 | | - Serial.print(F("\nStarting ESP8266WM_Config using EEPROM")); |
| 162 | + Serial.print(F("\nStarting ESP8266WM_ForcedConfig using EEPROM")); |
130 | 163 | #endif |
131 | 164 |
|
132 | 165 | #if USE_SSL |
|
0 commit comments