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.

Modules§

command
The function commands a DS18B20 answers once it has been addressed.
linux
The kernel’s own 1-Wire driver: thermometers as files under /sys/bus/w1/devices.

Structs§

Ds18b20
A DS18B20 on a 1-Wire bus, measuring on demand.
Scratchpad
A decoded, CRC-verified DS18B20 scratchpad.

Enums§

Resolution
The conversion resolution, selected by the R1/R0 bits of the configuration byte.

Constants§

EEPROM_WRITE_MICROS
How long a copy to the EEPROM takes, in microseconds.
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.
parse_w1_slave
Decodes the text the Linux kernel’s w1_therm driver serves for a thermometer.
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.
w1_slave_text
Renders the text the Linux kernel’s w1_therm driver serves for a scratchpad it read cleanly: the contents of a thermometer’s w1_slave file.