Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to Use NVS? #7442

Answered by Xylopyrographer
Bwanna asked this question in Q&A
Nov 7, 2022 · 4 comments · 3 replies
Discussion options

Hi,
I'm trying to migrate away from using EEPROM to NVS and could use some help. Please consider this a newbie question, although I've been doing basic arduino for a a while.

I've found ArduinoNvs.h https://github.com/rpolitex/ArduinoNvs which does help.

The biggest challenge is finding code that shows how to save a 'double' datatype into NVS on an ESP32. I did see a recommendation to put datatypes like these inside a struct, which I've done. However, I can't decipher how to save a 'struct' in NVS.

Here's the struct I'd like to save in NVS
struct NTC_Coef { double Coef1; double Coef2; double Coef3; double Coef4; } NCT = { 0.0014619791146952, 0.0001.894175741, 0.0000000842224008, -0.000011716827022565 };

Thanks for the help!
Steve

You must be logged in to vote

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
1 reply
Comment options

Thank you. Yes, I reviewed those docs and references, but were unable to translate that into Arduino code for use... that's why I highlighted this being a 'newbie' question. Would greatly appreciate if there was a very basic ARDUINO IDE example to reference. I just can't find any.

Thanks,

Answer selected by pedrominatel
Comment options

Did you take a look at the built-in Preferences examples? On Nov 7, 2022, at 12:49 PM, Bwanna ***@***.***> wrote:  Thank you. Yes, I reviewed those docs and references, but were unable to translate that into Arduino code for use... that's why I highlighted this being a 'newbie' question. Would greatly appreciate if there was a very basic ARDUINO IDE example to reference. I just can't find any. Thanks, — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.
You must be logged in to vote
0 replies
Comment options

There’s also this: https://randomnerdtutorials.com/esp32-save-data-permanently-preferences/ On Nov 7, 2022, at 12:49 PM, Bwanna ***@***.***> wrote:  Thank you. Yes, I reviewed those docs and references, but were unable to translate that into Arduino code for use... that's why I highlighted this being a 'newbie' question. Would greatly appreciate if there was a very basic ARDUINO IDE example to reference. I just can't find any. Thanks, — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.
You must be logged in to vote
2 replies
Comment options

Thank you! The built in preferences works great and that link provided great examples. Very much appreciated!

Comment options

There’s also this: https://randomnerdtutorials.com/esp32-save-data-permanently-preferences/

Exactly what was needed to resolve my // TODO: refactor from EEPROM to Preferences marker.

Comment options

😃👍 On Nov 7, 2022, at 5:16 PM, Bwanna ***@***.***> wrote:  Thank you! The built in preferences works great and that link provided great examples. Very much appreciated! — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /