IotWebConf icon indicating copy to clipboard operation
IotWebConf copied to clipboard

On ESP32 the password is reset after reboot

Open lamello opened this issue 5 years ago • 7 comments

Hello,

On my ESP32 there is a strange behaviour of the library. Every time after a reboot the _forceDefaultPassword is active (without pressing the button).

I've found a solution.

I have changed this: (IotWebConf.cpp line:119 en up) if (this->_configPin >= 0) { pinMode(this->_configPin, INPUT_PULLUP); this->_forceDefaultPassword = (digitalRead(this->_configPin == LOW)); }

for this: if (this->_configPin >= 0) { pinMode(this->_configPin, INPUT_PULLUP); digitalRead(this->_configPin); // dummy read for timing purposes this->_forceDefaultPassword = !digitalRead(this->_configPin); }

Thanks for sharing this library

lamello avatar May 22 '20 15:05 lamello

So it basically means, that ESP32 needs some time after pinMode is set and the first digitalRead is performed. It is good to know. Thank you for pointing that out!

prampec avatar May 22 '20 21:05 prampec

I can confirm the problem on an ESP32 and also confirm the fix:

bool IotWebConf::init()
{
  // -- Setup pins.
  if (this->_configPin >= 0)
  {
    pinMode(this->_configPin, INPUT_PULLUP);
#if defined(ESP32)
    digitalRead(this->_configPin); // #124: dummy read for timing purposes < ==== this fixes ESP32 problem
#endif
    this->_forceDefaultPassword = (digitalRead(this->_configPin) == LOW);
  }

I thought about a PR for this fix but then I saw that there is a branch named "possibleESP32fix". @prampec how is the status for this?

Thanks for this library: I tried to do a similar library but could not get the loading/saving of the params, so I switched my first project to yours! But as it is running on an ESP32, I needed this patch.

cdaller avatar Jan 23 '21 11:01 cdaller

Sorry for your abandoned issue, I will address this one soon.

prampec avatar Apr 14 '21 22:04 prampec

Hi, I just stumbled across this bug as well. It is still persistent in the latest release. However, the bugfix is effective.

theelims avatar Jul 22 '21 21:07 theelims

I found an other workaround, that should be transparent to the library. Instead of placing an additional digitalread inside of IoTWebConf.cpp I placed pinMode(BUTTON_PIN, INPUT_PULLUP); just in front of calling iotWebConf.init();.

theelims avatar Jul 26 '21 22:07 theelims

With your proposel the init function is depending of code outside of that function if it works reliable.

The solution of cdaller is the correct method.

lamello avatar Jul 29 '21 14:07 lamello

With your proposel the init function is depending of code outside of that function if it works reliable.

The solution of cdaller is the correct method.

Fixing the code inside the library is certainly the better way.

theelims avatar Aug 01 '21 12:08 theelims