hi,
I have a tmp275 sensor and arduino uno board.
my code to read the temperature is:
#include <Wire.h>
int tmp275Address = 0x48; // becouse I connect pins A0:A2 to ground
void setup(){
Serial.begin(9600);
Wire.begin();
}
void loop(){
float celsius = getTemperature();
Serial.print("Celsius: ");
Serial.println(celsius);
delay(3000);
}
float getTemperature(){
Wire.requestFrom(tmp275Address,2);
byte MSB = Wire.read();
byte LSB = Wire.read();
int TemperatureSum = ((MSB << 8) | LSB) >> 4;
float celsius = TemperatureSum*0.0625;
return celsius;
}
On the datasheet of sensor (http://www.ti.com/lit/ds/symlink/tmp275.pdf) is specified that the resolution of the sensor is 0,0625°C.
With my code I read a resolution of 0,5°C, but I would like 0,0625°C of resolution.
I'm not expert with the programmation and and I think that the problem is on the line:
"int TemperatureSum = ((MSB << 8) | LSB) >> 4; "
Can you help me?
thanks
P.S. the smiles is number eigth