OneWire Library for Arduino  version: 1.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
OneWire::DS18B20 Class Reference

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

#include <DS18B20.h>

Inheritance diagram for OneWire::DS18B20:
OneWire::OneWireSlave

Public Types

enum  Resolution { NINE_BIT = 0x1F, TEN_BIT = 0x3F, ELEVEN_BIT = 0x5F, TWELVE_BIT = 0x7F }
 Available resolutions of the DS18B20. More...
 
- Public Types inherited from OneWire::OneWireSlave
enum  CmdResult {
  Success, CommunicationError, CrcError, TimeoutError,
  OperationFailure
}
 

Public Member Functions

 DS18B20 (RandomAccessRomIterator &selector)
 DS18B20 constructor. More...
 
OneWireSlave::CmdResult writeScratchPad (uint8_t th, uint8_t tl, Resolution res)
 Write Scratchpad Command. More...
 
OneWireSlave::CmdResult readScratchPad (uint8_t *scratchPadBuff)
 Read Scratchpad Command. More...
 
OneWireSlave::CmdResult copyScratchPad (void)
 Copy Scratchpad Command. More...
 
OneWireSlave::CmdResult readPowerSupply (bool &localPower)
 Read Power Supply command. More...
 
OneWireSlave::CmdResult convertTemperature (float &temp)
 Convert Temperature Command. More...
 
OneWireSlave::CmdResult recallEEPROM (void)
 Recall Command. More...
 
- Public Member Functions inherited from OneWire::OneWireSlave
RomId romId () const
 
void setRomId (const RomId &romId)
 

Static Public Attributes

static const uint8_t FAMILY_CODE = 0x28
 DS18B20 Family Code. More...
 

Additional Inherited Members

- Protected Member Functions inherited from OneWire::OneWireSlave
 OneWireSlave (RandomAccessRomIterator &selector)
 
OneWireMaster::CmdResult selectDevice () const
 Select this slave device by ROM ID. More...
 
OneWireMastermaster () const
 The 1-Wire master for this slave device. More...
 

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.

Member Enumeration Documentation

Available resolutions of the DS18B20.

Enumerator
NINE_BIT 
TEN_BIT 
ELEVEN_BIT 
TWELVE_BIT 

Constructor & Destructor Documentation

DS18B20::DS18B20 ( RandomAccessRomIterator selector)

DS18B20 constructor.

On Entry:

Parameters
[in]selector- Reference to RandomAccessRomiteraor object that encapsulates owm master that has access to this device and ROM function commands used to a select device

On Exit:

Returns

Member Function Documentation

OneWireSlave::CmdResult DS18B20::convertTemperature ( float &  temp)

Convert Temperature Command.

This command begins a temperature conversion.

On Entry:

Parameters
[in]OnExit:
[out]temp- temperature conversion results
Returns
CmdResult - result of operation
OneWireSlave::CmdResult DS18B20::copyScratchPad ( void  )

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.

On Entry:

Parameters
[in]OnExit:
[out]return CmdResult - result of operation
OneWireSlave::CmdResult DS18B20::readPowerSupply ( bool &  localPower)

Read Power Supply command.

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

On Entry:

Parameters
[in]OnExit:
[out]localPower- Will be False on exit if the DS18B20 is parasite powered
Returns
CmdResult - result of operation
OneWireSlave::CmdResult DS18B20::readScratchPad ( uint8_t *  scratchPadBuff)

Read Scratchpad Command.

This command reads the complete scratchpad.

On Entry:

Parameters
[in]scratchPadBuff- array for receiving contents of scratchpad, this buffer will be over written

On Exit:

Parameters
[out]scratchPadBuff- contents of scratchpad
Returns
CmdResult - result of operation
OneWireSlave::CmdResult DS18B20::recallEEPROM ( void  )

Recall Command.

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

On Entry:

Parameters
[in]OnExit:
[out]return CmdResult - result of operation
OneWireSlave::CmdResult DS18B20::writeScratchPad ( uint8_t  th,
uint8_t  tl,
Resolution  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.

On Entry:

Parameters
[in]th- 8-bit upper temperature threshold, MSB indicates sign
[in]tl- 8-bit lower temperature threshold, LSB indicates sign
[in]res- Resolution of the DS18B20

On Exit:

Parameters
[out]return CmdResult - result of operation

Member Data Documentation

const uint8_t OneWire::DS18B20::FAMILY_CODE = 0x28
static

DS18B20 Family Code.


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