cr0sh:
Well, it says it uses a 2-wire interface, so you could probably use the Wire library on the Arduino to program it; page 6 details how to set ConfigRegister1, you basically send 11 bits of data (0-10) to address 0x05, which I guess is the address of the device on the 2-wire bus. The directions are a little vague; it sounds like you are -not- supposed to change bits 3-7, only bits 0-2 and bits 8-10, in order to change the settings. So you have to read the register, make the alterations, then write the register value back, preserving the value in bits 3-7.
Ok thanks. I understand this but code realisation is to difficult for me :~
I found this sketch that modifies the emission rate, i think this is very close to what I need:
/Simple program to read/write to the EEPROM (or read RAM) of the MLX90614 IR Sensor (in my case
//the MLX90614ESF-AAA). Example below erases the emissivity coefficient and then writes E = 1.
//Written be a total beginner, probably includes errors, and can definitely be
//improved on in many ways... /Lo-fi, 2011.
#include
void setup()
{
Serial.begin(9600);
Serial.println("----------Let's begin!----------");
i2c_init(); //Initialise i2c bus
PORTC = (1 << PORTC4) | (1 << PORTC5); //enable pullups
}
void loop()
{
int dev = 0x00; // I use the general address. If I specify the address
//(0x05<<1), the code doesn't work, don't know why... yet.
unsigned int data_l = 0;
unsigned int data_h = 0;
int pec = 0;
float data_t = 0;
float emissivity = 0;
//READ EEPROM/RAM
Serial.println("*1: Read EEPROM address:");
i2c_start_wait(dev+I2C_WRITE);
i2c_write(0x24); //0x004 and 0x04 etc reads the same address in the RAM,
//add 2(0) for EEPROM, eg. 0x24 (emissivity correction
//coefficient in EEPROM).
i2c_rep_start(dev+I2C_READ);
data_l = i2c_readAck(); //Read 1 byte and then send ack
data_h = i2c_readAck(); //Read 1 byte and then send ack
pec = i2c_readNak();
i2c_stop();
Serial.print("Data Low: ");
Serial.println(data_l);
Serial.print("Data High: ");
Serial.println(data_h);
Serial.print("Data combined: ");
data_t = (((data_h) << 8) + data_l);
Serial.println(data_t);
Serial.print("Emissivity: ");
emissivity = ((data_t) / 65535);
Serial.println(emissivity);
delay(5000);
//WRITE TO EEPROM, FIRST: ERASE OLD STUFF
i2c_start_wait(dev+I2C_WRITE);
i2c_write(0x24); //Register Address to write to
i2c_write(0x00); //Erase low byte (write 0)
i2c_write(0x00); //Erase high byte (write 0)
i2c_write(0xE8); //Send PEC
i2c_stop();
Serial.println("*2: Erasing old emissivity factor (writing 0).");
delay(5000);
//CHECK IF THE EEPROM VALUE HAS BEEN ERASED
Serial.println("*3: Check if the old emissivity coefficient was erased:");
i2c_start_wait(dev+I2C_WRITE);
i2c_write(0x24); //See above comment.
i2c_rep_start(dev+I2C_READ);
data_l = i2c_readAck(); //Read 1 byte and then send ack
data_h = i2c_readAck(); //Read 1 byte and then send ack
pec = i2c_readNak();
i2c_stop();
Serial.print("Data Low: ");
Serial.println(data_l);
Serial.print("Data High: ");
Serial.println(data_h);
Serial.print("Data combined: ");
data_t = (((data_h) << 8) + data_l);
Serial.println(data_t);
Serial.print("Emissivity: ");
emissivity = ((data_t) / 65535);
Serial.println(emissivity);
delay(5000);
//WRITE TO EEPROM, THE NEW STUFF!
i2c_start_wait(dev+I2C_WRITE);
i2c_write(0x24); //Register Address to write to
i2c_write(0xFF); //New emissivity factor, Ef=1
i2c_write(0xFF); //New emissivity factor, Ef=1
i2c_write(0xCC); //Send PEC
i2c_stop();
Serial.println("*4: Write new E to EEPROM (E = 1.0).");
delay(5000);
Serial.println("----------The process starts over again----------");
delay(5000);
}
The only thing I know so far (after 2 hours of research..) is that I have to change i2c_write(0x24); to i2c_write(0x25); and that I need to send the following 16 Bits to this register:
1;0;0;R;R;R;R;R;1;0;0;R;R;R;R;R
R stands for read, so that the sketch first reads whats the existing value and then uses it.
Can anybody please help me with the adaption of the code ? Thanks a lot in advantage :)