Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Commit a4b54bd

Browse files
authored
Fix example
1 parent ce4ef43 commit a4b54bd

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

examples/ESP8266WM_ForcedConfig/ESP8266WM_ForcedConfig.ino

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************************************************************
2-
ESP8266WM_Config.ino
2+
ESP8266WM_ForcedConfig.ino
33
For ESP8266 boards
44
55
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);
4242
BlynkTimer timer;
4343
Ticker led_ticker;
4444

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+
4578
void readAndSendData()
4679
{
4780
float temperature = dht.readTemperature();
@@ -123,10 +156,10 @@ void setup()
123156
delay(200);
124157

125158
#if ( USE_LITTLEFS || USE_SPIFFS)
126-
Serial.print(F("\nStarting ESP8266WM_Config using "));
159+
Serial.print(F("\nStarting ESP8266WM_ForcedConfig using "));
127160
Serial.print(CurrentFileFS);
128161
#else
129-
Serial.print(F("\nStarting ESP8266WM_Config using EEPROM"));
162+
Serial.print(F("\nStarting ESP8266WM_ForcedConfig using EEPROM"));
130163
#endif
131164

132165
#if USE_SSL

0 commit comments

Comments
 (0)