user69381: Hi I am a beginner in Arduino Uno. I wanted to store a value of 77880 in EEPROM and fetch it later. I made the code as follows to check my logic(I am using Arduino Uno) :
#include <EEPROM.h>
int addr = 0;
byte value;
void setup() {
  // put your setup code here, to run once:
  int val = 77880;
  EEPROM.write(addr, val);
  Serial.begin(57600);
}

void loop() {
  // put your main code here, to run repeatedly:
  value = EEPROM.read(addr);

  Serial.print(addr);
  Serial.print("\t");
  Serial.print(value);
  Serial.println();
  delay(1000);
}

but I am not getting the value of 77880 when I read the EEPROM address. instead I am getting a value of  56 in my serial output. Can anybody pls explain how should I implement the same?

user4143: EEPROM can only store the values 0-255 in any one address. That's the maximum range of an 8-bit value, and EEPROM "cells" are 8-bit in size.
You will have to split your value up into multiple 8-bit chunks and store each chunk at a different address - for example for 32-bit values you can use:
uint32_t val = 77880; // In hex is 0x13038
int addr = 0;
EEPROM.write(addr, val & 0xFF); // Stores 0x38 in address 0
EEPROM.write(addr + 1, (val >> 8) & 0xFF); // Stores 0x30 in address 1 
EEPROM.write(addr + 2, (val >> 16) & 0xFF); // Stores 0x01 in address 2 
EEPROM.write(addr + 3, (val >> 24) & 0xFF); // Stores 0x00 in address 3 

Then to read you do the opposite and shift the values and OR them:
uint32_t val = (uint32_t)EEPROM.read(addr) |
               ((uint32_t)EEPROM.read(addr + 1) << 8) |
               ((uint32_t)EEPROM.read(addr + 2) << 16) |
               ((uint32_t)EEPROM.read(addr + 3) << 24);

Alternatively the EEPROM library has a "store anything" helper to do it for you:
EEPROM.put(addr, val); 

That will store the variable val across enough cells to fit it (4 in the case of a 32-bit variable), so you must know not to write to the other cells used by it (0, 1, 2 and 3 in this case) or you will corrupt your data.
You recall it with:
EEPROM.get(addr, val);


69381: <p>Hi I am a beginner in Arduino Uno. I wanted to store a value of 77880 in EEPROM and fetch it later. I made the code as follows to check my logic(I am using Arduino Uno) :</p>
<pre><code>#include &lt;EEPROM.h&gt;
int addr = 0;
byte value;
void setup() {
  // put your setup code here, to run once:
  int val = 77880;
  EEPROM.write(addr, val);
  Serial.begin(57600);
}

void loop() {
  // put your main code here, to run repeatedly:
  value = EEPROM.read(addr);

  Serial.print(addr);
  Serial.print(&quot;\t&quot;);
  Serial.print(value);
  Serial.println();
  delay(1000);
}
</code></pre>
<p>but I am not getting the value of 77880 when I read the EEPROM address. instead I am getting a value of  56 in my serial output. Can anybody pls explain how should I implement the same?</p>
 4143: <p>EEPROM can only store the values 0-255 in any one address. That's the maximum range of an 8-bit value, and EEPROM &quot;cells&quot; are 8-bit in size.</p>
<p>You will have to split your value up into multiple 8-bit chunks and store each chunk at a different address - for example for 32-bit values you can use:</p>
<pre><code>uint32_t val = 77880; // In hex is 0x13038
int addr = 0;
EEPROM.write(addr, val &amp; 0xFF); // Stores 0x38 in address 0
EEPROM.write(addr + 1, (val &gt;&gt; 8) &amp; 0xFF); // Stores 0x30 in address 1 
EEPROM.write(addr + 2, (val &gt;&gt; 16) &amp; 0xFF); // Stores 0x01 in address 2 
EEPROM.write(addr + 3, (val &gt;&gt; 24) &amp; 0xFF); // Stores 0x00 in address 3 
</code></pre>
<p>Then to read you do the opposite and shift the values and OR them:</p>
<pre><code>uint32_t val = (uint32_t)EEPROM.read(addr) |
               ((uint32_t)EEPROM.read(addr + 1) &lt;&lt; 8) |
               ((uint32_t)EEPROM.read(addr + 2) &lt;&lt; 16) |
               ((uint32_t)EEPROM.read(addr + 3) &lt;&lt; 24);
</code></pre>
<p>Alternatively the EEPROM library has a &quot;store anything&quot; helper to do it for you:</p>
<pre><code>EEPROM.put(addr, val); 
</code></pre>
<p>That will store the variable <code>val</code> across enough cells to fit it (4 in the case of a 32-bit variable), so you must know not to write to the other cells used by it (0, 1, 2 and 3 in this case) or you will corrupt your data.</p>
<p>You recall it with:</p>
<pre><code>EEPROM.get(addr, val);
</code></pre>
