Reply To: Altitude & Temp

Home Forums Forums Technical Support for BerryIMU Altitude & Temp Reply To: Altitude & Temp

#7929
jgreen
Participant

the function returns -3310

float readTemp(){
uint8_t block[2];
readFrom(LSM9DS1_MAG_ADDRESS, 0x80 | LSM9DS1_OUT_TEMP_H, 2, block);
int16_t temp = (int16_t)(block[0] | block[1] << 8);
float temperature_c = (float)temp / 8.0 + 25;
float temperature_f = temperature_c * 1.8 + 32;
return temperature_f;
}

Blip, blop, bloop...