modm API documentation
modm::ds18b20< OneWire > Class Template Reference

Measurement resolution setting. More...

#include <modm/driver/temperature/ds18b20.hpp>

Inheritance diagram for modm::ds18b20< OneWire >:

Public Types

enum  Resolution : uint8_t { Bits9 = 0b0'00'11111, Bits10 = 0b0'01'11111, Bits11 = 0b0'10'11111, Bits12 = 0b0'11'11111 }
 

Public Member Functions

 Ds18b20 (const uint8_t *rom)
 Constructor. More...
 
bool configure (Resolution resolution)
 Configure measurement resolution. More...
 
bool isAvailable ()
 Check if the device is present. More...
 
void startConversion ()
 Start the conversion of this device.
 
void startConversions ()
 Start the conversion for all connected devices. More...
 
bool isConversionDone ()
 Check if the last conversion is complete. More...
 
int16_t readTemperature ()
 Read the current temperature in centi-degree. More...
 

Protected Member Functions

bool selectDevice ()
 Select the current device.
 

Protected Attributes

uint8_t identifier [8]
 

Static Protected Attributes

static const uint8_t CONVERT_T = 0x44
 
static const uint8_t WRITE_SCRATCHPAD = 0x4e
 
static const uint8_t READ_SCRATCHPAD = 0xbe
 
static const uint8_t COPY_SCRATCHPAD = 0x48
 
static const uint8_t RECALL_E2 = 0xb8
 
static const uint8_t READ_POWER_SUPPLY = 0xb4
 
static OneWire ow
 

Detailed Description

template<typename OneWire>
class modm::ds18b20< OneWire >

Measurement resolution setting.

The maximum conversion time doubles for every additional bit: 9 bits: 93.75 ms 10 bits: 187.5 ms 11 bits: 375 ms 12 bits: 750 ms

Author
Fabian Greif

Member Function Documentation

template<typename OneWire >
bool modm::ds18b20< OneWire >::configure ( Resolution  resolution)

Configure measurement resolution.

Set the measurement resolution. Every additional bit doubles the measurement time.

Returns
true if a device is found, false if no device is available on the bus.
template<typename OneWire >
modm::ds18b20< OneWire >::Ds18b20 ( const uint8_t *  rom)

Constructor.

Default resolution is 12-bit.

Parameters
rom8-byte unique ROM number of the device
template<typename OneWire >
bool modm::ds18b20< OneWire >::isAvailable ( )

Check if the device is present.

Returns
true if the device is found, false if the ROM number is not available on the bus.
template<typename OneWire >
bool modm::ds18b20< OneWire >::isConversionDone ( )

Check if the last conversion is complete.

Returns
true conversion complete,
false conversion in progress.
template<typename OneWire >
int16_t modm::ds18b20< OneWire >::readTemperature ( )

Read the current temperature in centi-degree.

Returns
temperature in centi-degree
template<typename OneWire >
void modm::ds18b20< OneWire >::startConversions ( )

Start the conversion for all connected devices.

Uses the SKIP_ROM command to start the conversion on all connected DS18B20 devices.

Warning
Use this function with caution. If you have devices other than the DS18B20 connected to your 1-wire bus check if they tolerate the SKIP_ROM + CONVERT_T command.

The documentation for this class was generated from the following file: