Write char on eeprom by this library

I am using a pretty small library (in fact, it is not really a library) to save, read data from a eeprom (24LC256), i took from here:
http://apexlogic.net/code-bank/arduino/eeprom-i2c-write-anything/

This is the code of the “library”:

#include <Arduino.h>
#define DEVICE 0x50 //this is the device ID from the datasheet of the 24LC256

//in the normal write anything the eeaddress is incrimented after the writing of each byte. The Wire library does this behind the scenes.

template <class T> int eeWrite(int ee, const T& value)
{
const byte* p = (const byte*)(const void*)&value;
int i;
Wire.beginTransmission(DEVICE);
Wire.write((int)(ee >> 8)); // MSB
Wire.write((int)(ee & 0xFF)); // LSB
for (i = 0; i < sizeof(value); i++)
Wire.write(*p++);
Wire.endTransmission();
return i;
}

template <class T> int eeRead(int ee, T& value)
{
byte* p = (byte*)(void*)&value;
int i;
Wire.beginTransmission(DEVICE);
Wire.write((int)(ee >> 8)); // MSB
Wire.write((int)(ee & 0xFF)); // LSB
Wire.endTransmission();
Wire.requestFrom(DEVICE,sizeof(value));
for (i = 0; i < sizeof(value); i++)
if(Wire.available())
*p++ = Wire.read();
return i;
}

Teh web also shows and example code, what works perfect. However, the example does not shows how to write/read charts into the eeprom, what is something that i also want to do.

Here you have the code of the example with the modification i did to include the writting and reading of a char to be printed later in the serial port.

#include <Wire.h>
#include "eepromi2c.h"

struct config
{
char* header;
long targetLat;
long targetLon;
float fNum;
bool first;
int attempts;
} config;

void setup(){
  Wire.begin();
Serial.begin(9600);

//config some of the variables during to be saved.
config.header = ("here goes a long chart what will be printed in the screen and also saved into an SD card");
config.targetLat = 4957127;
config.targetLon = 6743421;
config.first = false;
config.attempts = 30;
config.fNum = 2.23;
eeWrite(0,config);
delay (30);
}

void loop()
{

//change the variables within the strucutre to show the read worked
config.header = ("");
config.targetLat =0;
config.targetLon = 0;
config.first = true;
config.fNum = 0.0;
config.attempts = 0;
eeRead(0,config);
delay(30);

Serial.print("Header ");
Serial.println(config.header);
Serial.print("lat = ");
Serial.println(config.targetLat);
Serial.print("lon =");
Serial.println(config.targetLon);
Serial.print("first");
Serial.println(config.first);
Serial.print("float");
Serial.println(config.fNum);
Serial.print("attempts = ");
Serial.println(config.attempts);
delay(1000);
}

The code works great such as it is. The problem cames when i comment the variables definition in the setup section (those lines below the “Serial.begin” command). Then, i upload the code again, to see if it really remain the information in the eeprom. And here is were i have the problem. The program still works perfect, except the string is not available (“nan” is returned by arduino in each loop).
So, the epprom save the numbers or boolean values, but not the char… So, what is incorrect in my char definition?

I really need to solve this issue, because i need to show a lot of string in my code but i am out of memory. So, to add all those strings to the eeprom will save my project!.

Thanks so much for your inputs, ideas and help!

After some hours of iterations and test, i discovered that i was wrong when trying to save the text into the eeprom because i declared it such as a chart. The solution was to declare a string like this:

struct config
{
[color=red]String header;[/color]
long targetLat;
long targetLon;
float fNum;
bool first;
int attempts;
} config;

Now it works ok!

But my second problem is to pass this information (the ID of a Ds18b20 sensor) to the eeprom:

uint8_t sensor[1][8] = {
  {0x28,0x96,0x38,0x20,0x05,0x00,0x00,0xE2}
};

I tried by declaring it in this way in the "config" section:

struct config
{
String header;
long targetLat;
long targetLon;
float fNum;
bool first;
int attempts;
[color=red]uint8_t sensor[1][8];[/color]
} config;

This information is called in the loop to read the temperature sensor in this way:

eeRead(0,config);
delay(30);
sensors1.requestTemperatures();
Serial.print(sensors1.getTempC(sensor[0]))

But it return -127, what means that the sensor does not exist or it is not connected.

So, may be i am declaring this information in an incorrect way... Any of you have an idea about how could i solve this? Thanks!

Does your EEPROM write code handle pages well?
e.g. when you want to store a float in byte 62, 63, 64, 65
(the 24LC256 uses 64 byte pages)

I solved paging in this lib - http://playground.arduino.cc/Main/LibraryForI2CEEPROM -

I really do not have idea… i never used eeprom devices before… so, i do not know well how they works… I was only looking for an easy and light way to store data in it… But i don´t know how the code works…

I will take a look to the library you use to see how could i work with it.
Thanks again for your comments and tips!
Cheers