27,375
社区成员
发帖
与我相关
我的任务
分享
I2CSendByte(0x51); // send Start Convert Tcommand byte
stop(); // send STOP
I2CBitDly(); // wait
I2CSendAddr(Address,WRITE); // send START and control byte
I2CSendByte(0xAA); // send Read Temperature command byte
I2CSendAddr(Address,READ); // send repeat START and control byte
MSB = I2CGetByte(0); // read Temp MSB
LSB = I2CGetByte(1); // read Temp LSB
stop(); // send STOP
if(MSB>=0x80) //if sign bit is set, then temp is negative
temp_c = (float)((MSB<<8 | LSB) - 65536) * 0.0625;
else
temp_c = (float)((MSB<<8|LSB) * 0.00390625);