![]() |
OneWire Library for Arduino
version: 1.0.0
|
DS18B20 Programmable Resolution 1-Wire Digital Thermometer. More...
#include <DS18B20.h>
Public Types | |
enum | Resolution { NINE_BIT = 0x1F, TEN_BIT = 0x3F, ELEVEN_BIT = 0x5F, TWELVE_BIT = 0x7F } |
Available resolutions of the DS18B20. More... | |
![]() | |
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... | |
![]() | |
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 | |
![]() | |
OneWireSlave (RandomAccessRomIterator &selector) | |
OneWireMaster::CmdResult | selectDevice () const |
Select this slave device by ROM ID. More... | |
OneWireMaster & | master () const |
The 1-Wire master for this slave device. More... | |
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.
Available resolutions of the DS18B20.
Enumerator | |
---|---|
NINE_BIT | |
TEN_BIT | |
ELEVEN_BIT | |
TWELVE_BIT |
DS18B20::DS18B20 | ( | RandomAccessRomIterator & | selector | ) |
DS18B20 constructor.
On Entry:
[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:
OneWireSlave::CmdResult DS18B20::convertTemperature | ( | float & | temp | ) |
Convert Temperature Command.
This command begins a temperature conversion.
On Entry:
[in] | On | Exit: |
[out] | temp | - temperature conversion results |
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:
[in] | On | Exit: |
[out] | return CmdResult - result of operation |
OneWireSlave::CmdResult DS18B20::readPowerSupply | ( | bool & | localPower | ) |
OneWireSlave::CmdResult DS18B20::readScratchPad | ( | uint8_t * | scratchPadBuff | ) |
Read Scratchpad Command.
This command reads the complete scratchpad.
On Entry:
[in] | scratchPadBuff | - array for receiving contents of scratchpad, this buffer will be over written |
On Exit:
[out] | scratchPadBuff | - contents of scratchpad |
OneWireSlave::CmdResult DS18B20::recallEEPROM | ( | void | ) |
Recall Command.
This command recalls the temperature trigger values and resolution stored in EEPROM to the scratchpad
On Entry:
[in] | On | Exit: |
[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:
[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:
[out] | return CmdResult - result of operation |
|
static |
DS18B20 Family Code.