Using preferences.h on ESP32 - Variable stored correctly but then overwritten

+Karma for having read forum instructions. Well done.

Move the declarations for ssid and password out of setup(), make them global. You also have to have used putString() before you can use getString(). You never mentioned if you had done that.

If you don’t quite understand why the variables should be outside of setup(), Google “C variable scope”.

1 Like