Device interface library for multiple platforms including Mbed.

Dependents:   DeepCover Embedded Security in IoT MaximInterface MAXREFDES155#

Embed: (wiki syntax)

« Back to documentation index

DS18B20 Class Reference

DS18B20 Class Reference

DS18B20 Programmable Resolution 1-Wire Digital Thermometer. More...

#include <DS18B20.hpp>

Public Types

typedef Core::array
< uint_least8_t, 8 > 
Scratchpad
 Holds the contents of the device scratchpad.

Public Member Functions

MaximInterfaceDevices_EXPORT
Core::Result< void > 
initialize () const
 Initializes the device for first time use.
MaximInterfaceDevices_EXPORT
Core::Result< void > 
writeScratchpad (uint_least8_t th, uint_least8_t tl, uint_least8_t res)
 Write Scratchpad Command.
MaximInterfaceDevices_EXPORT
Core::Result< Scratchpad
readScratchpad () const
 Read Scratchpad Command.
MaximInterfaceDevices_EXPORT
Core::Result< void > 
copyScratchpad ()
 Copy Scratchpad Command.
MaximInterfaceDevices_EXPORT
Core::Result< bool > 
readPowerSupply () const
 Read Power Supply command.
MaximInterfaceDevices_EXPORT
Core::Result< void > 
convertTemperature ()
 Convert Temperature Command.
MaximInterfaceDevices_EXPORT
Core::Result< void > 
recallEeprom ()
 Recall Command.

Detailed Description

DS18B20 Programmable Resolution 1-Wire Digital Thermometer.

The DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements and has an alarm function with nonvolatile user-programmable upper and lower trigger points. The DS18B20 communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor. In addition, the DS18B20 can derive power directly from the data line ("parasite power"), eliminating the need for an external power supply.

Definition at line 52 of file DS18B20.hpp.


Member Typedef Documentation

typedef Core::array<uint_least8_t, 8> Scratchpad

Holds the contents of the device scratchpad.

Definition at line 62 of file DS18B20.hpp.


Member Function Documentation

Result< void > convertTemperature (  )

Convert Temperature Command.

This command begins a temperature conversion.

Definition at line 130 of file DS18B20.cpp.

Result< void > copyScratchpad (  )

Copy Scratchpad Command.

This command copies from the scratchpad into the EEPROM of the DS18B20, storing the temperature trigger bytes and resolution in nonvolatile memory.

Definition at line 102 of file DS18B20.cpp.

Result< void > initialize (  ) const

Initializes the device for first time use.

Definition at line 49 of file DS18B20.cpp.

Result< bool > readPowerSupply (  ) const

Read Power Supply command.

This command determines if the DS18B20 is parasite powered or has a local supply

Returns:
True if the device is powered by a local power supply, or false if the device is parasitically powered.

Definition at line 90 of file DS18B20.cpp.

Result< DS18B20::Scratchpad > readScratchpad (  ) const

Read Scratchpad Command.

Returns:
scratchpad Contents of scratchpad.

Definition at line 67 of file DS18B20.cpp.

Result< void > recallEeprom (  )

Recall Command.

This command recalls the temperature trigger values and resolution stored in EEPROM to the scratchpad.

Definition at line 177 of file DS18B20.cpp.

Result< void > writeScratchpad ( uint_least8_t  th,
uint_least8_t  tl,
uint_least8_t  res 
)

Write Scratchpad Command.

If the result of a temperature measurement is higher than TH or lower than TL, an alarm flag inside the device is set. This flag is updated with every temperature measurement. As long as the alarm flag is set, the DS1920 will respond to the alarm search command.

Parameters:
[in]th8-bit upper temperature threshold, MSB indicates sign.
[in]tl8-bit lower temperature threshold, LSB indicates sign.
[in]resResolution of the DS18B20.

Definition at line 54 of file DS18B20.cpp.