8 years, 11 months ago.

I2C bug with MLX90614

hi to all, i write this easy program for use IR Thermometer MLX90614,

#define I2C_WRITE   0
#define I2C_READ    1
Serial pc(PA_9,PA_10); //Serial 1  TX,  RX  PER DEBUG. 
I2C i2c(PB_9,PB_8); // sda, scl
int main() {
    pc.printf("\nI2C");
   i2c.frequency(100000);  //100Khz
    while(1) {
				char p1,p2,p3;
        pc.printf("start...\n");        
							  i2c.start();						
       			int status=i2c.write((0x5A<<1));		//0xB4						
								int status2=i2c.write(0x07);	  //Tobj 	
						    i2c.start();	
					int status3=i2c.write((0x5A<<1)+I2C_READ);	
							   p1=i2c.read(1);     //Tobj low byte
								p2=i2c.read(1);     //Tobj heigh byte
								  p3=i2c.read(0);     //PEC			
								i2c.stop();
								pc.printf("%d-", status);
								pc.printf("%d-", status2);
								pc.printf("%d-", status3);												
										pc.printf("data-I");
								pc.printf("%d-", (int)p1);
									pc.printf("%d-", (int)p2);
										pc.printf("%d-", (int)p3);														
															pc.printf("data-F");		
          wait(5);           // wait 5 seconds for next scan          
            }
        }

the value of status is 1, it's good, the value of status2 and status3 is 0, because i don't have the ACK, i test the IR Thermometer with busPirate and all work well

Set speed:
 1. ~5KHz
 2. ~50KHz
 3. ~100KHz
 4. ~400KHz
(1)>3
Ready
I2C>[0xb4]
I2C START BIT
WRITE: 0xB4 ACK
I2C STOP BIT
I2C>[0xb5]
I2C START BIT
WRITE: 0xB5 ACK
I2C STOP BIT
I2C>[0xb4 0x07 [ 0xb5 rrr]
I2C START BIT
WRITE: 0xB4 ACK
WRITE: 0x07 ACK
I2C START BIT
WRITE: 0xB5 ACK
READ: 0xD9
READ:  ACK 0x39
READ:  ACK 0xAE
NACK
I2C STOP BIT
I2C>

i think the problem is the i2c.write(0x07) and the i2c.write(0x5A<<1)+I2C_READ that don't' give the right value to IR sensor do you have idea where i fix this problem?

best regards. A.

1 Answer

8 years, 11 months ago.

See answer to your earlier question