So anyway, here is an implementation of a couple routines with one that saves a string in the onboard EEProm on the Arduino and then a second that reads it back. In my next iteration I will add a CSV parser such that if you put two distinct variables into the EEProm, separated by commas, you will get an array of two variables back from the read.
Here is what the serial console displays when this sketch is run:
--Starting
--String to Save on EEProm
2.222,4.44
--String Retrieved from EEProm
2.222,4.44
--All Done
--String to Save on EEProm
2.222,4.44
--String Retrieved from EEProm
2.222,4.44
--All Done
Here is a LINK to the sketch itself. There is really not that much to this example but the time it took me to relearn a little about array handling in "C" made this more of a challenge than I expected (for my old brain).
Note that I wrote my own floating to string conversion function as I was not thrilled with the way that dtostrf works. Even this trivial routine took my old brain more than a couple minutes to write...as we hear the clanking of gears shifting. --Updated to reflect that even after all that I had an error in the code that I just corrected. I am struggling with working at the pointer level!
Another update - Found this posting on the Arduino Forum with a nice technique for using the EEProm memory to store anything with one operation.
No comments:
Post a Comment