Hi all!
I am reading data from a humidity sensor via the I2C interface of an Arduino Uno. I am getting the data as a u16 which works fine. Now I want to convert that u16 raw data to the actual humidity. This would look something like this:
let humidity_raw: u16 = 0x3fff; // that would be 100 % rel. humidity
let humidity: f32 = (humidity_raw as f32) * 100.0 / 16383.0;
Now I have problems writing the humidity
f32
value to the serial port. I am currently using the ufmt
crate which does not support formatting of floats:
ufmt::uwriteln!(&mut serial, "humidity: {}", humidity).void_unwrap();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `uDisplay` is not implemented for `f32`
Is there an alternative for the ufmt
crate? I also tried to get the whole part and the fractional part from the humidity
value separately but I did not come up with a trivial solution.