Skip to main content

Module ds18b20

Module ds18b20 

Source
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.