mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #1445] Chip not remembering custom Parameters that are set, after Power Cycle #1236
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#1236
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @atulravi on GitHub (Jul 1, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1445
I have been trying to see if the ESP will automatically perform a task that was setup after a power-cycle only to notice that it is not remembering the data that is input during setup.
[Hardware details given in the end. Using an ESP01]
On the setup page, I have a custom input parameter where I input my IFTTT webhook link so that I don't need to hard code it in every-time. After a power cycle, the webhook link is becoming the placeholder text which in my case is Default value. ( Serial Monitor data given below)
Before Power-cycle (Just after setup):
500
Parameter:
https://maker.ifttt.com/trigger/helpme/json/with/key/****************
Connecting to maker.ifttt.com
Request resource: https://maker.ifttt.com/trigger/helpme/json/with/key/***************
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 51
Connection: close
X-Powered-By: Sad Unicorns
X-Robots-Tag: none
X-Top-SecreTTT: VG9vIGVhc3k/IElmIHlvdSBjYW4gcmVhZCB0aGlzLCBFbWFpbCB1cyBhdCBqb2JzK3NlY3JldEBpZnR0dC5jb20uIFdlIHdhbnQgTWFrZXJzLg==
Date: Fri, 01 Jul 2022 14:33:50 GMT
ETag: W/"33-1PhScKy8yGhDdh/TbzClK+PieyE"
Vary: Accept-Encoding
X-Cache: RefreshHit from cloudfront
Via: 1.1 7ddf286a74f41d315547cb4965fc2464.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: MAA51-P1
X-Amz-Cf-Id: h78-yFLR2h_mmEoUfoPHswk1ICn4_FHO8KYKY-Hzu6Th41syNZQlYQ==
Congratulations! You've fired the helpme json event
closing connection
requestmade
Connecting to maker.ifttt.com
Request resource: https://maker.ifttt.com/trigger/helpme/json/with/key/*********************
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 51
Connection: close
X-Powered-By: Sad Unicorns
X-Robots-Tag: none
X-Top-SecreTTT: VG9vIGVhc3k/IElmIHlvdSBjYW4gcmVhZCB0aGlzLCBFbWFpbCB1cyBhdCBqb2JzK3NlY3JldEBpZnR0dC5jb20uIFdlIHdhbnQgTWFrZXJzLg==
Date: Fri, 01 Jul 2022 14:33:50 GMT
ETag: W/"33-1PhScKy8yGhDdh/TbzClK+PieyE"
Vary: Accept-Encoding
X-Cache: RefreshHit from cloudfront
Via: 1.1 98505de3b08a10ebacb304bf006d1078.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: MAA51-P1
X-Amz-Cf-Id: 7mS_GjkVwEEPRFu6tMzBi-Che7t55zyChtxO7oj5s5Vc4JUoK5nZ5A==
After Power Cycle (Un Plugging and Re-Plugging):

It can be noticed that the data that was custom input during setup has gotten reset to the placeholder text (code given below for reference). So effectively, after a power-cycle, the device no longer works.
Code:
#include <WiFiManager.h>
const int buttonPin = 0; // the number of the pushbutton pin
const int resetsw = 1;
const int ledPin = 5; // the number of the LED pin
int buttonState = 0;
int resetState = 0;
const char* server = "maker.ifttt.com";
WiFiManager manager;
WiFiManagerParameter parameterglobal("parameterId", "IFTTT Maker Link", "default value", 500);
//flag for saving data
bool shouldSaveConfig = true;
void setup() {
//manager.resetSettings();
pinMode(buttonPin, INPUT);
pinMode(5,OUTPUT);
pinMode(resetsw,INPUT);
Serial.begin(115200);
manager.setDebugOutput(false);
}
void loop(){
resetState = digitalRead(resetsw);
makeIFTTTRequest();
Serial.println("requestmade");
if (resetState == HIGH){
manager.resetSettings();
Serial.println("chip reset");
}
}
//data
void saveConfigCallback () {
Serial.println("Should save config");
shouldSaveConfig = true;
}
// Ifttt request
void makeIFTTTRequest() {
Serial.print("Connecting to ");
Serial.print(server);
WiFiClient client;
int retries = 5;
while(!!!client.connect(server, 80) && (retries-- > 0)) {
Serial.print(".");
}
Serial.println();
if(!!!client.connected()) {
Serial.println("Failed to connect, going back to sleep");
}
Serial.print("Request resource: ");
Serial.println(parameterglobal.getValue());
client.print(String("GET ") + parameterglobal.getValue() +
" HTTP/1.1\r\n" +
"Host: " + server + "\r\n" +
"Connection: close\r\n\r\n");
int timeout = 5 * 10; // 5 seconds
while(!!!client.available() && (timeout-- > 0)){
delay(100);
}
if(!!!client.available()) {
Serial.println("No response, going back to sleep");
}
while(client.available()){
Serial.write(client.read());
}
Serial.println("\nclosing connection");
client.stop();
}
Hardware Specs:
Chip: ESP-01 (ESP8266) {Generic ESP8266 module}

Reset Method: ck
Flash Size: 512K
Debug Port: disabled.
[Other details attached in image below]
@TI-SH-K205 commented on GitHub (Jul 1, 2022):
Thanks for everything sir ..........❤️❤️❤️❤️❤️
On Fri, Jul 1, 2022, 8:57 PM ESCcrasci @.***> wrote:
@mrjerzy commented on GitHub (Jul 7, 2022):
Hi,
the README states that you need to store custom parameters on your own.
In the examples folder you can find some code, which explains how to read the values collected by WifiManager: https://github.com/tzapu/WiFiManager/blob/master/examples/Parameters/SPIFFS/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino#L125-L131
Once you have extracted those values you could use for example the ESP's non-volatile storage.
There are some nice examples in the esp-idf examples library how to read and write to the NVS:
https://github.com/espressif/esp-idf/blob/master/examples/storage/nvs_rw_value/main/nvs_value_example_main.c
In the examples library of the wifi manager you will find also some alternatives to NVS.
BR