3-phase PV router
Loading...
Searching...
No Matches
DS18B20 Namespace Reference

Classes

struct  PowerOnFilter
 The readings of one sensor, the power-on value skipped. More...
 

Typedefs

using ScratchPad = uint8_t[9]
 The scratchpad: temperature LSB and MSB, TH, TL, configuration, 3 reserved bytes, CRC.
 

Functions

constexpr uint8_t crc8 (const uint8_t *data, uint8_t len)
 The Dallas/Maxim CRC-8 (x^8 + x^5 + x^4 + 1), as OneWire::crc8.
 
constexpr int16_t decode (const ScratchPad &buf)
 The reading of a scratchpad, its CRC checked.
 
constexpr int16_t skipPowerOnValue (int16_t reading, int16_t previous)
 The reading to keep, the power-on value skipped.
 
constexpr int16_t toHundredths (uint8_t lsb, uint8_t msb)
 The temperature of the register, in hundredths of °C.
 

Variables

constexpr int16_t POWER_ON_JUMP { 500 }
 
constexpr int16_t POWER_ON_VALUE { 8500 }
 

Typedef Documentation

◆ ScratchPad

using DS18B20::ScratchPad = uint8_t[9]

The scratchpad: temperature LSB and MSB, TH, TL, configuration, 3 reserved bytes, CRC.

Definition at line 43 of file ds18b20.h.

Function Documentation

◆ crc8()

uint8_t DS18B20::crc8 ( const uint8_t * data,
uint8_t len )
constexpr

The Dallas/Maxim CRC-8 (x^8 + x^5 + x^4 + 1), as OneWire::crc8.

Bit by bit, as the OneWire library without its table (ONEWIRE_CRC8_TABLE 0): its 32-byte table is not worth it for one scratchpad a second. The firmware's own copy, so the native tests check the CRC the firmware runs.

Parameters
dataThe bytes
lenTheir number
Returns
The CRC: the 9th byte of a scratchpad, the 8th of a ROM code

Definition at line 59 of file ds18b20.h.

Here is the caller graph for this function:

◆ decode()

int16_t DS18B20::decode ( const ScratchPad & buf)
constexpr

The reading of a scratchpad, its CRC checked.

Parameters
bufThe 9 bytes read from the sensor
Returns
The temperature in hundredths of °C, DEVICE_DISCONNECTED_RAW on a CRC error, OUTOFRANGE_TEMPERATURE below -55.00 °C or above +125.00 °C.

Definition at line 101 of file ds18b20.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ skipPowerOnValue()

int16_t DS18B20::skipPowerOnValue ( int16_t reading,
int16_t previous )
constexpr

The reading to keep, the power-on value skipped.

A sensor that has just been powered (plugged, or a power glitch) answers 85.00 °C before its first conversion. 85.00 °C more than 5.00 °C away from the previous reading is that value, not a temperature.

Parameters
readingThe reading of the sensor
previousThe last valid reading (PowerOnFilter keeps it)
Returns
reading, or DEVICE_DISCONNECTED_RAW for the power-on value

Definition at line 127 of file ds18b20.h.

Here is the caller graph for this function:

◆ toHundredths()

int16_t DS18B20::toHundredths ( uint8_t lsb,
uint8_t msb )
constexpr

The temperature of the register, in hundredths of °C.

The register is the temperature x16 (1/16 °C at 12 bits), two's complement. x6.25 = x6 + x/4, rounded down (towards -infinity): 1/16 °C gives 6, -1/16 °C -7.

Parameters
lsbByte 0 of the scratchpad
msbByte 1 of the scratchpad

Definition at line 88 of file ds18b20.h.

Here is the caller graph for this function:

Variable Documentation

◆ POWER_ON_JUMP

int16_t DS18B20::POWER_ON_JUMP { 500 }
inlineconstexpr

a bigger jump to 85.00 °C is the power-on value

Definition at line 46 of file ds18b20.h.

◆ POWER_ON_VALUE

int16_t DS18B20::POWER_ON_VALUE { 8500 }
inlineconstexpr

the register at power-on, before any conversion

Definition at line 45 of file ds18b20.h.