Store number over 1 byte in EEPROM
Posted: Wed Mar 20, 2024 10:53 am
New to this, trying to store a persistent number between boots but it rolls over after 8 bits. Works as expected until I hit 256. Is each address only capable of holding a byte? How do I abstract that away to store larger numbers?
in setup()
in loop() on certain condition
Code: Select all
#include <EEPROM.h>
#define EEPROM_SIZE 512
int numClick = 0;
Code: Select all
EEPROM.begin(EEPROM_SIZE);
numClick = EEPROM.read(0);
Code: Select all
numClick = EEPROM.read(0);
........
numClick++;
........
EEPROM.write(0, numClick);
EEPROM.commit();