Driver crate for the HTU21D temperature and relative humidity sensor. I made this crate because I got a sensor for an upcoming project and didn’t find any crate for it. Turns out there is a crate, but oh well. It’s still been a learning experience.
It’s been my first time working with I²C directly, and implementing this crate from the datasheet was quite a bit more complex than the the 3642bs one. Just like that crate, this one is also compatible with all embedded_hal-based HALs and probably Embassy.
For now, the crate includes these functions:
.temperature()does what you’d expect. It sends a request to read the temperature, waits for the sensor to take the measurement and then reads the I²C bus for the reply. It puts together the bits of the answer and does the required math from the datasheet.
.humidity()is the same story as the previous, but it returns the relative humidity instead.
.dew_point_temp()calculates the dew point temperature, which is the temperature to which the air would have to be cooled to become saturated with water.
This is the first thing I made after finishing the rust book and ruslings exercises, so I’ve made use of generics a bit more consistently with this one.
It’s still far off from perfect. I’ve still had to fight with the compiler and ended up with not exactly what I wanted.
Because of how the generics work, I couldn’t unwrap, debug print or
impl From the errors.
Despite this I haven’t insisted on fighting with it, because I needed this ready to be used ASAP.
I wanted it to build a project with the ESP32-C3, but turns out the I²C on it is broken, so that sucks.
I don’t have much else to say about it, so I’ll leave it here.