-
Notifications
You must be signed in to change notification settings - Fork 50
FM75
The FM75 is a temperature sensor chip that seems to be what some of the TEMPer devices use - or at least they're using a chip that uses the same formulas for calculating the temperature from the raw data.
The Fairchild FM75 has a temperature range of -40°C to 125°C, is calibrated to ±1°C within 0°C to 100°C typical, and has a "user-configurable" 9, 10, 11 or 12-bit resolution (where the user is the implementor). For more details, see the datasheet.
However, the TEMPer types using this chip (or an equivalent) usually say -40°C ~ +120°C - which is one reason I suspect they're using a compatible chip instead of an actual Fairchild FM75, though I may be wrong. (It's not like the rest of the device (esp. the plastic housing) can withstand those temperatures anyway.)
The raw data we get from this type of sensor is two bytes, a high byte and a low byte, where the high byte is signed (using two's complement notation) and the low byte is unsigned (since both are really just one number).
To convert these two bytes into a floating-point temperature value in degrees Celcius, we start by combining the bytes into an integer:
int temp = ( (signed char)high_byte << 8 ) + ( (unsigned char)low_byte && 0xFF );
Then, we convert it to a float, using this formula (supposedly taken from the FM75 datasheet):
float tempC = temp * 125.0 / 32000.0;
Which is, technically, the same as dividing by 256 (0x100) - basically, moving the decimal point into place.
In other words, we actually get the temperature back as a fixed-point binary value, so the only conversion needed is to get the value into the host machine's floating-point type.