View Source onewire_ds18b20 (grisp v2.8.0)

Communicate with the DS18B20 - Programmable Resolution 1-Wire Digital Thermometer

Summary

Functions

Initiate a temperature measurement.

Read the scratchpad.

Read the temperature in °C from the scratchpad.

Functions

convert(ID, Timeout)

-spec convert([byte()], any()) -> ok.

Initiate a temperature measurement.

Example

 1> onewire_ds18b20:convert([40,255,190,25,96,23,3,203], 500).
 ok

read_scratchpad(ID)

-spec read_scratchpad([byte()]) -> {LSB :: binary(), MSB :: binary(), Config :: binary()}.

Read the scratchpad.

Returns the two bytes of the temperature register (LSB and MSB) and the one byte of the configuration register.

temp(ID)

-spec temp([byte()]) -> float().

Read the temperature in °C from the scratchpad.

Example

 onewire_ds18b20:temp([40,255,190,25,96,23,3,203]).
 22.375