gfroerli / firmware

Firmware for the water temperature sensor project
GNU General Public License v3.0
6 stars 1 forks source link

DS18B20: Implement own driver module #83

Closed dbrgn closed 3 years ago

dbrgn commented 3 years ago

The ds18b20 crate is not ideal for us. For instance, when wrapping an address, it first reads the config register. This is something we don't need to do when booting up the sensor in a known (default) state. Additionally, by implementing the driver code ourselves, we have more control over the sensor readings.

This commit replaces the external ds18b20 crate with a custom module that does a temperature reading directly using the one-wire crate. It also gets rid of the unnecessary one-wire bus scan when initializing the bus. Last but not least, the raw data is now returned (as u16), as opposed to the external driver which would convert the measurement into an f32. (We need the raw data in order to make use of #82.)

As a nice side effect, the flashed binary is now 1 KiB smaller!

Raw measurements being logged in dev mode:

image