I'm making some progress. Slowing understanding more how this I2C communication works. I figured out that the addresses shown in table 5 on page 11, must have 20 added to them. So 0x004 becomes 0x024x. Someone can probably explain the reason why better.
So I can now read the existing emissivity coefficient correctly. High & low byte = 255, which gives you 65535 combined. Exactly what the data sheet says.
In order to write a new value you must first erase (write 0) to the cell, and then proceed to write your value. This is where I am having problems. Take a look at my code.#include <i2cmaster.h>
i2c_init(); //Initialise the i2c bus
PORTC = (1 << PORTC4) | (1 << PORTC5);//enable pullups
int dev = 0x5A<<1;
unsigned int data_low = 0;
unsigned int data_high = 0;
int pec = 0;
unsigned short data_temp = 0x0000;
double emissivity = 0x0000;
i2c_write(0x24); //Register Address
i2c_write(0x0000); //Erase (write 0)
i2c_write(0x5999); //Write Data
data_low = i2c_readAck(); //Read 1 byte and then send ack
data_high = i2c_readAck(); //Read 1 byte and then send ack
pec = i2c_readNak();
Serial.print("Data Low: ");
Serial.print("Data High: ");
data_temp = (((data_high) << + data_low);
Serial.print("Emissivity Coefficient: ");
emissivity = (data_temp/65535);
Do I need to make seperate writes to the MSB and LSB? As of now I am not even able to erase the cell.