Hi,
Calculating the temperature from the raw data of HW is a litle tricky. Here is how i did it in my HW2S.Port Arduino Projekt.
float calcTempHW(uint16_t tempRaw) { uint16_t tempFunc[26][2] = {{0, 1}, {14, 2}, {28, 3}, {58, 5}, {106, 8}, {158, 11}, {234, 15}, {296, 18}, {362, 21}, {408, 23}, {505, 27}, {583, 30}, {664, 33}, {720, 35}, {807, 38}, {897, 41}, {1021, 45}, {1150, 49}, {1315, 54}, {1855, 70}, {1978, 74}, {2239, 82}, {2387, 87}, {2472, 90}, {2656, 97}, {2705, 99}}; if (tempRaw > 3828) return 0; if (tempRaw < 1123) return 100; tempRaw = 3828 - tempRaw; uint8_t i = 0; while (i < 26 && tempRaw >= tempFunc[i][0]) { i++; } return tempFunc[i - 1][1] + (tempFunc[i][1] - tempFunc[i - 1][1]) * (float)(tempRaw - tempFunc[i - 1][0]) / (tempFunc[i][0] - tempFunc[i - 1][0]); }
The result is the same like in jlog with this way. hope it helps a little.
|