Read/write boolean to/from EEPROM - casting needed?

Hi there,

I cannot test it myself at the moment, so just to be sure: I want to store (and later retrieve) a boolean variable to EEPROM. Is it necessary to cast it to "byte" (or another type), and then back to boolean for reading?

So:

EEPROM1024.write(address, myBoolean);
myBoolean = EEPROM1024.read(address);

OR

EEPROM1024.write(address, (byte) myBoolean);
myBoolean = (boolean) EEPROM1024.read(address); ?

and, directly using I2C:

Wire.send(myBoolean);
myBoolean = Wire.receive();

OR

Wire.send((boolean) myBoolean);
myBoolean = (boolean) Wire.receive(); ?

more specific you want to store it in I2C eeprom?

yes casting is good practice, but you can put the state of 8 booleans in one byte (bitmasking) and yes that makes the code a bit bigger.

Note the code you presented is no complete sketch....