Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years ago.
Infrared Thermometer MLX90614 and Nucleo STM32L152R3
Hi to all, i write this:
Serial pc(PA_9,PA_10); //Serial 1 TX, RX PER DEBUG. I2C i2c(PB_9,PB_8); const int addr = 0x5A; char data_read[2]; int main() { pc.printf("\nI2C Scanner"); data_read[1]='A'; data_read[0]='B'; while(1) { int error, address; int nDevices; pc.printf("Scanning...\n"); nDevices = 0; for(address = 1; address < 127; address++ ) { i2c.start(); error = i2c.write(address << 1); //We shift it left because mbed takes in 8 bit addreses i2c.stop(); if (error == 1) { pc.printf("I2C device found at address 0x%X", address); //Returns 7-bit addres int status = i2c.read((address << 1),data_read, 2); pc.printf("%d-", status); pc.printf("%d-", (int)data_read[1]); pc.printf("%d\n", (int)data_read[0]); nDevices++; } } if (nDevices == 0){ pc.printf("No I2C devices found\n"); } else{ pc.printf("\ndone\n"); } wait(5); // wait 5 seconds for next scan } }
in this code i can read the address of IR Thermometer, the address is 0XA5, but i can't read the value of temperature, in fact if i print the status i read 0, the data_read[0] and data_read[1] have the value 255 , i don't know where is the problem can you help me?
best regards. A.
1 Answer
9 years ago.
why not leverage from github https://github.com/sparkfun/SparkFun_MLX90614_Arduino_Library
Hi David thanks for your answer, i read the code that you post and write this:
int status=i2c.read(0x08); // equal for int status=i2c.read(0x07); p1=i2c.read(1); //Tobj low byte p2=i2c.read(1); //Tobj heigh byte p3=i2c.read(0); //PEC pc.printf("%d-", status); pc.printf("data-"); pc.printf("%d-", (int)p1); pc.printf("%d-", (int)p2); pc.printf("%d-", (int)p3);
i see that i read that status is 1, i think is good because i can read the Tobj he problem is that p1,p2 and p3 is 255 i don't understand where is the error do you have some idea?
posted by 03 Dec 2015