I am reading a sensor and obtaining values for change in temperature every 10 minutes. At the moment I am saving the change in temperature as an integer.
The range in temperature change should be between -120 and 120, I want to save the temperature change to EEPROM, but I only have 512 bytes spare and as an integer the values take up 2 bytes. Therefore I thought I could assign the value to the corresponding char value and save the char to EEPROM (since this will only take one byte) e.g. (e.g. '4' 's' '$' etc.), however I can't see the easy way to do this.
I am using the arduino IDE which is C++ I believe and asking here because it's really a software question
I thought I should be able to use something like
int tempAsInt = -50;
char tempAsChar;
tempAsChar = char(tempAsInt);
or
int tempAsInt = -50;
signed char tempAsChar;
tempAsChar = tempAsInt;
but the first one printed the same characters (upsidedown question mark or null value) for varied tempAsInt values
and the second one just printed out the same value as the integer, i.e. if the change was -50, it printed -50, so I'm not sure if it is really a char, though perhaps I'm just printing it wrong.
My printing code is
mySerial.print("\tTempAsInt: ");
mySerial.print(tempAsInt);
mySerial.print("\tTempDiffAsInt: ");
mySerial.print(tempDiffAsInt);
mySerial.print("\tTempDiffAsChar: ");
mySerial.print(tempDiffAsChar);