Hello,
I saw the new Arduino Nano Every has 4 times lower EEPROM memory than the old Nano, how can I calculate the amount of kb I use for EEPROM to check if 256byte woud be enough?
I saved 5 values to EEPROM (5 variables) how do I know how much bytes I use?
Depends how big the variables are that you are storing.
You can use sizeof(var) to find the number of bytes that var uses.
What are the variable data types? What size is each data type. One character is one byte. An int can be 2 bytes or 4 bytes depending on the processor. The number of bytes for long, float and double are also dependent on processor.
But like @red_car says, use the sizeof() function to get their sizes.
All of the 5 variables are a 2 digit number, and whenever is written it overwrites the old values.
Would that fit in 256byte?
All of the 5 variables are a 2 digit number.
Show the code that you are using.
"2 digit number" doesn't tell us much... it depends on the type of the variable.
If you are only storing 5 numbers... even if they are 4 bytes each, you should have plenty of room. Must be some other problem.. show your code.
on an 8 bit Arduino an int data type can store the values from -32768 to 32767 and it will occupy 2 bytes. So it can be from 1 to 5 digits plus sign. For int number = 0; number will occupy 2 bytes, int number = 24534; will also occupy 2 bytes.
See here for information on the sizes of Arduino data types and what they can hold.
There are just 2 digit integers (5 numbers). If my guess is right by what @groundFungus said, I should use 10bytes in this case.
int val1 = 0;
int val2 = 0;
int val3 = 0;
int val4 = 0;
int val5 = 0;
I got it, thank you!
If you are using an Uno.. then yes.. 10 bytes.
So why do you say...
You need to tell the EEPROM what address you want it written to also. So for the numbers above you need to leave at least 2 bytes for each.
EEPROM.put(address, value)
Use put (based on size of value) rather than write (which only writes 1 byte)
I am having no luck finding a definitive answer to the question of data type sizes for the Nano Every with the 4809 processor. OP would be well advised to use the sizeof() function to determine the data type sizes for sure.
5 variables of any type will not require 256 bytes of EEPROM to store them
Personally I would put the variables (whatever type they are) in an array or struct and put()/get() that to/from the EEPROM with a single address, probably zero rather than messing around with individual variables
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.