Expand description
Maxim DS18B20 1-Wire digital thermometer.
The DS18B20 reports temperature as a 16-bit two’s-complement number in a nine-byte scratchpad, with a CRC byte that covers the rest. This module decodes that temperature exactly as the datasheet’s temperature/data table specifies, reads the resolution out of the configuration byte, and verifies the scratchpad’s CRC with the Maxim 1-Wire polynomial so a read corrupted on the bus is caught rather than trusted.
It is pure logic: a caller drives the 1-Wire transactions (convert, then read
scratchpad) and hands the nine bytes to Scratchpad::parse.
Structs§
- Scratchpad
- A decoded, CRC-verified DS18B20 scratchpad.
Enums§
- Resolution
- The conversion resolution, selected by the R1/R0 bits of the configuration byte.
Constants§
- FAMILY_
CODE - The 1-Wire family code that identifies a DS18B20 in the first ROM byte.
Functions§
- crc8
- Computes the Maxim 1-Wire CRC-8 over
data. - temperature_
from_ celsius - Converts degrees Celsius to a raw temperature register value.
- temperature_
from_ micro_ celsius - Converts micro-degrees Celsius to a raw temperature register value.
- temperature_
to_ celsius - Converts a raw temperature register value to degrees Celsius.
- temperature_
to_ micro_ celsius - Converts a raw temperature register value to micro-degrees Celsius, exactly.