SodaqMoja / SodaqOne-UniversalTracker

37 stars 28 forks source link

temperature not working #20

Open koos147 opened 2 years ago

koos147 commented 2 years ago

Good day,

i have a Sodaq one Version 2. at the temperature it always reported a nice 20 degrees.

when i changed the getBoardTemperature function to bellow. it reports an rawTemp of -1 when checking the bellow page it shows an LIS3DE instead of an LSM303 https://support.sodaq.com/Boards/One/#summary Is this device capable of measuring the temperature?


int8_t getBoardTemperature()
{
    setLsm303Active(true);

    uint8_t tempL = lsm303.readReg(LSM303::TEMP_OUT_L);
    uint8_t tempH = lsm303.readReg(LSM303::TEMP_OUT_H);

    // Note: tempH has the 4 "unused" bits set correctly by the sensor (0x0 or 0xF)
    int16_t rawTemp = ((uint16_t)tempH << 8) | tempL;

    setLsm303Active(false);
      #ifdef DEBUG
        consolePrint("temperature: ");
        consolePrintln(rawTemp);
      #endif

    return round(TEMPERATURE_OFFSET + rawTemp / 8.0);
}