diff --git a/things.ino b/things.ino index 23d88d1..69aa5b1 100644 --- a/things.ino +++ b/things.ino @@ -19,6 +19,8 @@ extern "C" { //#define DHTTYPE DHT21 // DHT21 (AM2301) #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 char mqtt_server[40]; char mqtt_port[6] = "1883"; @@ -183,10 +185,11 @@ void setup() { // put your setup code here, to run once: Serial.begin(9600); - // set led pin as output - pinMode(BUILTIN_LED, OUTPUT); + pinMode(BUILTIN_LED, OUTPUT); // set led pin as output ticker.attach(0.5, toggle_led); // toggle led slowly during initialization + pinMode(CONFIGPIN, INPUT); // flash-button on nodemcu + // clean FS, for testing //SPIFFS.format(); @@ -230,8 +233,12 @@ void setup() { // local intialization 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 wifiManager.setAPCallback(configModeCallback);