Hi everyone :),
I bought a LM92 temp sensor and I have done my first tests. Read the temperature values ??was not a problem but I want to configure the interrupt register to generate an alert when arrive at a specific temperature.
Datasheet: http://www.ti.com/lit/ds/symlink/lm92.pdf
My problem is that I don't know how send data because this is 16 bits. I put my code, I set alarm for low temperature when it arrives at 32 °, for example turn on a led.
Reading LM92.
#include <Wire.h>
char lm92addr = 0x48; //A1 and A0 to GND #1001000
int val = 0x1900;
char buffer[2];
int tempcode;
float temp;
void setup()
{
Serial.begin(9600);
Wire.begin();
// Pag. 13 on Datasheet, the register is 16bits
// (temperature data is bit3 - bit15)
Wire.beginTransmission(lm92addr);
Wire.write(0x04); // Register address for configure T_LOW
Wire.write(0x18); // set value: 0001100000000000 T-Low 30ºC first 8Bit
Wire.write(0x00); // second 8Bit
// T_High
Wire.write(0x05); // Register address for configure T_High
Wire.write(0x19); // set value: 0001100110000000 T_High 33ºC
Wire.write(0x80);
Wire.endTransmission();
}
void loop()
{
Wire.requestFrom(lm92addr,2); // Se solicitan los dos Bytes
if (Wire.available())
{
for(int i=0; i<2; i++)
{
buffer[i]= Wire.read();
}
tempcode= ((buffer[0] << 8) + buffer[1]) >>3;
temp = tempcode * 0.0625;
Serial.print("t = ");
Serial.print(temp);
Serial.print(" C");
Serial.println();
}
delay(500);
}
I'm not sure if it is correct divided my chain into two 8-bit, but if I send
Wire.write(0x1800);
seems not to work. What is the correct way to send the string or write on the sensor.
Sorry for my english, a greeting and thank you very much.