How to write an array of non primitive objects to Arduino EEPROM then read the array into memory each time the program starts -


i developing pill reminder electronics final year project. need store name of pill, number of times taken, hours taken during , whether active or not. created class pill below, , stored pills in array:

class pill{     public:         string pillname = "nothing";         boolean pilltaken = true;         int hours[6];          boolean active = false;         int count = 0;  };  pill pills[6]; 

now want persist data in arduino eeprom, how can write array of pills eeprom , read data memory each time program starts. also, need update array each time command modify pill received, putting new values.

@galarzaa90 has pointed right information, however, eeprom lib not work string class.

why?

because actual string data not stored in objects memory space, contains pointer dynamic memory elsewhere.

if save string object save length, buffer size , pointer data. however, when restart duino , load string eeprom, pointer pointing to... anywhere expect.

you'll need use cstring/ char array means string data stored inside pill class.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -