Basic EEPROM garbage reading

I'm trying to make a general code for reading and writing data from a temperature sensor to and from EEPROM for later use (i plan to buy an EEPROM chip soon, but just experimenting with the arduino's on board for now.

Two questions really, first i tried to write code to send each Temp. readings to the EEPROM with each reading going to a new address (code is based on basic temperature input to serial, and EEPROM examples combined basically, as i have to start somewhere being an absolute beginner to programming).

#include <EEPROM.h>

int tempPin = 0;   //initialise temperature pin analog 0.
int i;


void setup()
{
  Serial1.begin(9600);   //begin serial connect.
  Serial.begin(9600);
    
}

void loop()
{
 
float temperature = getVoltage(tempPin);
temperature = (temperature - .5) * 100; //convert mV to deg.
EEPROM.write(i,temperature); //write to EEPROM, new address>new reading
Serial.println(EEPROM.read(i));
i++;
delay(3000);

}

float getVoltage(int pin)
{
  return (analogRead(pin) * 0.004882814); //convert to right voltage range
}

I get complete garbage when it outputs though and and i'm not sure why any ideas? ive searched the forum and found functions to call values etc. which seem similar.., but have a feeling im just missing something simple i should understand but don't.

Secondly once i can get this initial code working, is there a way to fill up each address with bytes (rather than just 1), then move to the next address and so forth?

thanks for any help you can give!

EEPROM.write(i,temperature); //write to EEPROM, new address>new reading

There is no EEPROM write method for a "float" (or any data type other than "uint8_t", aka "byte"), so the garbage you are seeing is probably just eight bits of your thirty-two.

Have a look for "EEPROM write anything" over at the main site.
http://www.arduino.cc/playground/Code/EEPROMWriteAnything

You can download (for free) the sketch to do exactly that from the website for my http://www.arduinoevilgenius.com.

Its project 13 - temperature logger. It compresses the temperatures and stuffs them into EEPROM.

Commands from the Serial Monitor to retrieve the data.

It compresses the temperatures and stuffs them into EEPROM.

Lossy or lossless compression ?

Lossy or lossless compression ?

Lossless. Nothing sophisticated, it just fits it into a byte, with 1/4 degree resolution for a temperature range of -20 to 44 C

byte compressedReading = (byte)((reading + 20.0) * 4);

The variable 'reading' is a float.