reset wifi-settings on press of button, fixes #4
This commit is contained in:
parent
12c641a43d
commit
84dfe25160
15
things.ino
15
things.ino
@ -19,6 +19,8 @@ extern "C" {
|
|||||||
//#define DHTTYPE DHT21 // DHT21 (AM2301)
|
//#define DHTTYPE DHT21 // DHT21 (AM2301)
|
||||||
#define DHTTYPE DHT22 // DHT22 (AM2302)
|
#define DHTTYPE DHT22 // DHT22 (AM2302)
|
||||||
|
|
||||||
|
#define CONFIGPIN D3 // config-button is connected to this pin
|
||||||
|
|
||||||
// define default values here, overwritten by values from config.json
|
// define default values here, overwritten by values from config.json
|
||||||
char mqtt_server[40];
|
char mqtt_server[40];
|
||||||
char mqtt_port[6] = "1883";
|
char mqtt_port[6] = "1883";
|
||||||
@ -183,10 +185,11 @@ void setup() {
|
|||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// set led pin as output
|
pinMode(BUILTIN_LED, OUTPUT); // set led pin as output
|
||||||
pinMode(BUILTIN_LED, OUTPUT);
|
|
||||||
ticker.attach(0.5, toggle_led); // toggle led slowly during initialization
|
ticker.attach(0.5, toggle_led); // toggle led slowly during initialization
|
||||||
|
|
||||||
|
pinMode(CONFIGPIN, INPUT); // flash-button on nodemcu
|
||||||
|
|
||||||
// clean FS, for testing
|
// clean FS, for testing
|
||||||
//SPIFFS.format();
|
//SPIFFS.format();
|
||||||
|
|
||||||
@ -230,8 +233,12 @@ void setup() {
|
|||||||
|
|
||||||
// local intialization
|
// local intialization
|
||||||
WiFiManager wifiManager;
|
WiFiManager wifiManager;
|
||||||
// reset settings - for testing
|
|
||||||
//wifiManager.resetSettings();
|
// reset settings if config-button is pressed
|
||||||
|
if (!digitalRead(CONFIGPIN)) {
|
||||||
|
Serial.println("config-button pressed, resetting wifi settings");
|
||||||
|
wifiManager.resetSettings();
|
||||||
|
}
|
||||||
|
|
||||||
// set callback that gets called when connecting to previous WiFi fails, and enters Access Point mode
|
// set callback that gets called when connecting to previous WiFi fails, and enters Access Point mode
|
||||||
wifiManager.setAPCallback(configModeCallback);
|
wifiManager.setAPCallback(configModeCallback);
|
||||||
|
Loading…
Reference in New Issue
Block a user