[GH-ISSUE #1152] Can't use wifiManager.resetSettings(); inside loop #986

Closed
opened 2026-02-28 01:27:59 +03:00 by kerem · 3 comments
Owner

Originally created by @ITstreet1 on GitHub (Nov 27, 2020).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1152

Basic Infos

Arduino IDE 1.8.12

Hardware

WiFimanager Branch/Release:

  • Master
  • Development

Esp8266/Esp32:

  • [x ] ESP8266
  • ESP32

Hardware: ESP-12e, esp01, esp25

  • ESP01
  • [x ] ESP12 E/F/S (nodemcu, wemos, feather)
  • Other

ESP Core Version: 2.4.0, staging

  • 2.3.0
  • 2.4.0
  • staging (master/dev)

Description

In example sketch AutoConnectWithFSPParameters.ino, there is a wifiManager.resetSettings(); function, which can reset settings of SPIFFS data. As wifiManager is declared inside setup, I can not use this function inside a loop with a button. Or maybe there is a way, that I don't know.

Settings in IDE

Module: Generic ESP8266 Module

Additional libraries:

Sketch


#include <Arduino.h>

void setup() {
// didn't change a thing from an example
}

void loop() {
wifiManager.resetSettings();
}

Debug Messages

exit status 1
'wifiManager' was not declared in this scope
Originally created by @ITstreet1 on GitHub (Nov 27, 2020). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1152 ### Basic Infos Arduino IDE 1.8.12 #### Hardware **WiFimanager Branch/Release:** - [ ] Master - [ ] Development **Esp8266/Esp32:** - [x ] ESP8266 - [ ] ESP32 **Hardware: ESP-12e, esp01, esp25** - [ ] ESP01 - [x ] ESP12 E/F/S (nodemcu, wemos, feather) - [ ] Other **ESP Core Version: 2.4.0, staging** - [ ] 2.3.0 - [ ] 2.4.0 - [ ] staging (master/dev) ### Description In example sketch AutoConnectWithFSPParameters.ino, there is a wifiManager.resetSettings(); function, which can reset settings of SPIFFS data. As wifiManager is declared inside setup, I can not use this function inside a loop with a button. Or maybe there is a way, that I don't know. ### Settings in IDE Module: Generic ESP8266 Module Additional libraries: ### Sketch ```cpp #include <Arduino.h> void setup() { // didn't change a thing from an example } void loop() { wifiManager.resetSettings(); } ``` ### Debug Messages ``` exit status 1 'wifiManager' was not declared in this scope ```
kerem 2026-02-28 01:27:59 +03:00
  • closed this issue
  • added the
    Question
    label
Author
Owner

@EgHubs commented on GitHub (Dec 11, 2020):

Just redeclare it!

   if ( digitalRead(TRIGGER_PIN) == LOW) {
       WiFiManager wifiManager;
       wifiManager.resetSettings();
       delay(500);
       resetFunc();
     }

and resetFunc is declared before the void setup() function
void(* resetFunc) (void) = 0; //declare reset function @ address 0

<!-- gh-comment-id:743365592 --> @EgHubs commented on GitHub (Dec 11, 2020): Just redeclare it! ``` if ( digitalRead(TRIGGER_PIN) == LOW) { WiFiManager wifiManager; wifiManager.resetSettings(); delay(500); resetFunc(); } ``` and resetFunc is declared before the void setup() function `void(* resetFunc) (void) = 0; //declare reset function @ address 0 `
Author
Owner

@tablatronix commented on GitHub (Dec 11, 2020):

Yeah this is a scope issue, basic C++, not a wm issue

either make wm global, or create a new instance

<!-- gh-comment-id:743373801 --> @tablatronix commented on GitHub (Dec 11, 2020): Yeah this is a scope issue, basic C++, not a wm issue either make wm global, or create a new instance
Author
Owner

@ChernikovS1971 commented on GitHub (Apr 25, 2022):

EgHubs
thank! your code works!

<!-- gh-comment-id:1108137043 --> @ChernikovS1971 commented on GitHub (Apr 25, 2022): [EgHubs](https://github.com/EgHubs) thank! your code works!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#986
No description provided.