SignalK / SensESP

Universal Signal K sensor framework for the ESP32 platform
https://signalk.org/SensESP/
Apache License 2.0
153 stars 81 forks source link

Wifi credentials cannot be changed #587

Open qMalte opened 2 years ago

qMalte commented 2 years ago

While programming the ESP32 with the SensESP library I encounter the error that the access data of the WIFI on the board can no longer be changed.

The background is that I have two WIFI access points (lab and production environment).

If I store the respective WIFI credentials in the code and load the program on the board, the ESP32 still tries to establish a connection with the WIFI credentials previously entered in the code. However, the problem does not occur with the hostname or the SignalK server.

Is a problem of this kind already known or can someone tell me a way to completely reset an ESP32?

Elzariant commented 2 years ago

same issue for me. I use esptool to erase completely the data

mairas commented 2 years ago

I seem to have missed this issue - sorry about that!

WiFi initialization in SensESP is a bit hairy. The basic idea is that SSID and password entered using WiFiManager (or modified with the web UI) are stored on the SPIFFS filesystem and have precedence over hard-coded values. Since the SPIFFS contents are retained during normal reflashing, this means that changing the hard-coded values don't have an effect.

Erasing the flash either using PlatformIO's "Erase Flash" command or esptool as suggested by @Elzariant would take care of that, but that requires reflashing the software. I think we're missing a reset button interface, allowing a button press to either reset the network credentials or the whole device. I have such an interface implemented with the AceButton library in another project which I hope to publish soon. That could then be backported to SensESP proper.

Having said this, if SensESP saves hard-coded credentials to SPIFFS without user interaction, that does sound like a bug that needs to be fixed. It might take a bit of time until I can do it myself, though...

qMalte commented 2 years ago

Hello Matti,

thank you very much for your feedback.

This has clarified my concern.

Thank you very much!

Many greetings Malte

mairas commented 2 years ago

I'll reopen this because I think the raised point(s) are real issues and should be addressed.

That is:

  1. Hardcoded WiFi credentials shouldn't be written to the file system (not sure if this is the case, needs to be verified).
  2. There should be a button user interface for easier resetting of the WiFi configuration.
johannbarbie commented 1 year ago

i've stumbled over this as well. for those searching for a quick-fix, the exact command to erase the flash is:

esptool.py --chip esp32 erase_flash

is there a link to the hardware button solution already?