How to write a big number to EEPROM e.g. 4000?

I am trying to store a value of say 4000, but I am unable to do so. I am able to write and retrieve values for upto 240.

Below is the code that i am using.

int val;
int address;

void setup()
val = 4000;
address = 10;
EEPROM.update(address, val);

void loop() {
val =;

Read the basics of computers.
The address stores one byte , or 8 bit , or another way zero to 255.
Val is a int which is 2 or 4 bytes , so to store the int you need more than one address.
Look at some i2c libraries and see how they cut the int up by moving the int up .

EEPROM.put() and EEPROM.get() are functions that can deal with other data types than byte.

@peter_a: On the Particles (and other 32bit processors) int is four byte.
And while it is good to understand how to do the splitting up of multi-byte datatypes, it’s not required due to above functions.

So int’s are long by default ? , didn’t know that .
That will save me a little typing if my number is more than 32767.

Yup! This is the reason why I prefer the int16_t/int32_t type for it’s explicity :wink: