Round temp to make more sense.
This commit is contained in:
parent
588c0479f5
commit
56ca179475
@ -41,5 +41,8 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
fn convert_to_celsius(raw_temp: u16) -> f32 {
|
||||
// According to chapter 4.9.5. Temperature Sensor in RP2040 datasheet
|
||||
27.0 - (raw_temp as f32 * 3.3 / 4096.0 - 0.706) / 0.001721
|
||||
let temp = 27.0 - (raw_temp as f32 * 3.3 / 4096.0 - 0.706) / 0.001721;
|
||||
let sign = if temp < 0.0 { -1.0 } else { 1.0 };
|
||||
let rounded_temp_x10: i16 = ((temp * 10.0) + 0.5 * sign) as i16;
|
||||
(rounded_temp_x10 as f32) / 10.0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user