DS2482-RK
|
Gets the temperatures for multiple DS18B20 sensors on a single bus. More...
#include <DS2482-RK.h>
Public Member Functions | |
DS2482GetTemperatureForListCommand & | withMaxRetries (size_t value) |
Sets the number of times to retry reading the temperature. Default is 3. | |
DS2482GetTemperatureForListCommand & | withConversionSize (int value) |
Sets the conversion size in bits. Default is CONVERSION_12BIT. More... | |
DS2482GetTemperatureForListCommand & | withParasiticPower (bool value=true) |
Sets whether to use parasitic power or not. The default is false. | |
size_t | getNumRetries () const |
Gets the total number of retries across all sensor reads. More... | |
Public Member Functions inherited from DS2482Command | |
DS2482Command (DS2482 &parent) | |
Construct a command object. More... | |
virtual | ~DS2482Command () |
Destructor. | |
Static Public Member Functions | |
static DS2482GetTemperatureForListCommand & | run (DS2482 &parent, DS2482DeviceList &deviceList, std::function< void(DS2482GetTemperatureForListCommand &, int status, DS2482DeviceList &deviceList)> completion) |
Gets the temperatures for a number of DS18B20 sensors on the 1-wire bus. More... | |
Friends | |
class | DS2482 |
Additional Inherited Members | |
Static Public Attributes inherited from DS2482Command | |
static const int | RESULT_WORKING = 0 |
Asynchronous call still in progress. | |
static const int | RESULT_DONE = 1 |
Asynchronous call completed successfully. | |
static const int | RESULT_I2C_ENDTRANSMISSION_BUSY_ERROR = -1 |
Busy timeout upon entering endTransmission (I2C error) | |
static const int | RESULT_I2C_ENDTRANSMISSION_START_ERROR = -2 |
Start bit generation timeout (I2C error) | |
static const int | RESULT_I2C_ENDTRANSMISSION_ADDRESS_ERROR = -3 |
End of address transmission timeout (I2C error) | |
static const int | RESULT_I2C_ENDTRANSMISSION_TRANSFER_ERROR = -4 |
Data byte transfer timeout (I2C error) | |
static const int | RESULT_I2C_ENDTRANSMISSION_AFTER_TRANSFER_ERROR = -5 |
Data byte transfer succeeded, busy timeout immediately after (I2C error) | |
static const int | RESULT_I2C_READ_TIMEOUT = -100 |
I2C requestFrom did not return bytes. | |
static const int | RESULT_I2C_COMMAND_TIMEOUT = -101 |
An I2C command timed out. | |
static const int | RESULT_1WIRE_SHORT = -200 |
On a 1-wire bus reset, a short was detected (SD flag set) | |
static const int | RESULT_1WIRE_BUSY = -201 |
The previous 1-wire command had not completed yet. | |
static const int | RESULT_1WIRE_NO_DEVICE = -202 |
No device on the 1-wire bus when doing a 1-wire send address (no presence pulse detected) | |
static const int | RESULT_TOO_MANY_RETRIES = -300 |
Specified number of retries exceeded without getting a response with a valid CRC. | |
static const int | RESULT_SEARCH_FAILED = -301 |
During a 1-wire search bus, got an invalid set of bits returned. | |
static const int | RESULT_SET_CHANNEL_FAILED = -303 |
A DS2482-800 set channel operation failed to set the channel. | |
static const uint8_t | TRIPLET_CMD = 0x78 |
DS2482 I2C command code. | |
static const uint8_t | SINGLE_1WIRE_BIT_CMD = 0x87 |
DS2482 I2C command code. | |
static const uint8_t | WRITE_BYTE_CMD = 0xa5 |
DS2482 I2C command code. | |
static const uint8_t | READ_BYTE_CMD = 0x96 |
DS2482 I2C command code. | |
static const uint8_t | RESET_1WIRE_CMD = 0xb4 |
DS2482 I2C command code. | |
static const uint8_t | CHANNEL_SELECT_CMD = 0xc3 |
DS2482 I2C command code. | |
static const uint8_t | WRITE_CONFIG_CMD = 0xd2 |
DS2482 I2C command code. | |
static const uint8_t | SET_READ_PTR_CMD = 0xe1 |
DS2482 I2C command code. | |
static const uint8_t | DEVICE_RESET_CMD = 0xf0 |
DS2482 I2C command code. | |
static const uint8_t | CONFIG_REG = 0xc3 |
DS2482 register code. | |
static const uint8_t | READ_DATA_REG = 0xe1 |
DS2482 register code. | |
static const uint8_t | STATUS_REG = 0xf0 |
DS2482 register code. | |
static const uint8_t | STATUS_DIR_MASK = 0b10000000 |
DS2482 status register bit. | |
static const uint8_t | STATUS_TSB_MASK = 0b01000000 |
DS2482 status register bit. | |
static const uint8_t | STATUS_SBR_MASK = 0b00100000 |
DS2482 status register bit. | |
static const uint8_t | STATUS_RST_MASK = 0b00010000 |
DS2482 status register bit. | |
static const uint8_t | STATUS_LL_MASK = 0b00001000 |
DS2482 status register bit. | |
static const uint8_t | STATUS_SD_MASK = 0b00000100 |
DS2482 status register bit. | |
static const uint8_t | STATUS_PPD_MASK = 0b00000010 |
DS2482 status register bit. | |
static const uint8_t | STATUS_1WB_MASK = 0b00000001 |
DS2482 status register bit. | |
static const uint8_t | CONFIG_1WS_MASK = 0b1000 |
DS2482 config register bit. | |
static const uint8_t | CONFIG_SPU_MASK = 0b0100 |
DS2482 config register bit. | |
static const uint8_t | CONFIG_APU_MASK = 0b0001 |
DS2482 config register bit. | |
static const uint8_t | SEARCH_ROM = 0xf0 |
1-wire ROM select command | |
static const uint8_t | READ_ROM = 0x33 |
1-wire ROM select command | |
static const uint8_t | MATCH_ROM = 0x55 |
1-wire ROM select command | |
static const uint8_t | SKIP_ROM = 0xcc |
1-wire ROM select command | |
static const uint8_t | ALARM_SEARCH = 0xec |
DS18B20 command. | |
static const uint8_t | CONVERT_T = 0x44 |
DS18B20 command. | |
static const uint8_t | WRITE_SCRATCHPAD = 0x4e |
DS18B20 command. | |
static const uint8_t | READ_SCRATCHPAD = 0xbe |
DS18B20 command. | |
static const uint8_t | COPY_SCRATCHPAD = 0x48 |
DS18B20 command. | |
static const uint8_t | RECALL_E2 = 0xb8 |
DS18B20 command. | |
static const uint8_t | READ_POWER_SUPPLY = 0xb4 |
DS18B20 command. | |
static const int | CONVERSION_9BIT = 0 |
9-bit conversion size, resolution of 1/2 degree C, conversion time 94 ms | |
static const int | CONVERSION_10BIT = 1 |
10-bit conversion size, resolution of 1/4 degree C, conversion time 188 ms | |
static const int | CONVERSION_11BIT = 2 |
11-bit conversion size, resolution of 1/8 degree C, conversion time 375 ms | |
static const int | CONVERSION_12BIT = 3 |
12-bit conversion size, resolution of 1/16 degree C, conversion time 750 ms (default) | |
static const int | RETRIES_DEFAULT = 3 |
Default numnber of retries if you don't override it with withRetries() | |
Protected Member Functions inherited from DS2482Command | |
void | pushCommand () |
Add this command to the parent queue. | |
void | pushCommandList () |
Pushes a command list onto the command list stack. This is done when a command needs their own sequence of commands to run. | |
void | popCommandList () |
Pops a command list off the command list stack. This is done when a command needs their own sequence of commands to run. | |
int | readStatus (uint8_t &value, bool setReadPointerFirst=true) |
Reads the status DS2482 status register. | |
int | readData (uint8_t &value, bool setReadPointerFirst=true) |
Reads the status DS2482 data register. | |
int | setReadPointer (uint8_t reg) |
Sets the DS2482 read pointer to a specific register (CONFIG_REG, READ_DATA_REG, READ_DATA_REG) | |
int | readConfig (uint8_t &value) |
Reads the DS2482 config register. Always sets the data pointer first. | |
int | writeConfig (bool speed, bool spu, bool apu) |
Writes the DS2482 config register. | |
int | writeReg0 (uint8_t reg) |
Writes a DS2482 register. | |
int | writeReg1 (uint8_t reg, uint8_t value) |
Writes the DS2482 config register and a value. | |
int | strongPullUp (bool on) |
Enables or disables strong pull-up mode. Used by parasitic power mode. | |
void | beginTransmission () |
Reflects to DS2482 parent to do an I2C operation. | |
uint8_t | endTransmission (bool stop=true) |
Reflects to DS2482 parent to do an I2C operation. | |
uint8_t | requestFrom (uint8_t numBytes, bool stop=true) |
Reflects to DS2482 parent to do an I2C operation. | |
size_t | write (uint8_t val) |
Reflects to DS2482 parent to do an I2C operation. | |
size_t | write (const uint8_t *buf, size_t count) |
Reflects to DS2482 parent to do an I2C operation. | |
int | available (void) |
Reflects to DS2482 parent to do an I2C operation. | |
int | read (void) |
Reflects to DS2482 parent to do an I2C operation. | |
Protected Attributes inherited from DS2482Command | |
DS2482 & | parent |
The DS2482 that this command is being run on. | |
Gets the temperatures for multiple DS18B20 sensors on a single bus.
This is faster than calling DS2482GetTemperatureCommand for each sensor separately. The reason is that the longest operation, ConvertT, takes 750 milliseconds (for 12-bit readings). When you use DS2482GetTemperatureForListCommand ConvertT for all of the sensors on the bus is done at the same time, so you only incur the 750 millisecond time once, regardless of how many sensors are on the bus. The individual readings need to be made for each DS18B20, but that's fast.
As with all command objects, you do not typically construct one of these objects. Instead, use the static run method to handle allocating, initializing, and queueing the command.
|
inline |
Gets the total number of retries across all sensor reads.
This should be 0 most of the time when all sensors were read successfully the first time.
|
static |
Gets the temperatures for a number of DS18B20 sensors on the 1-wire bus.
parent | The DS2482 you want to send the command to. If it's a DS2482_800, make sure you set the channel as well. |
deviceList | the DS2482DeviceList for the devices you want to get the temperatures for |
completion | The completion handler lambda function. status is the result status of the call; if DS2482Command::RESULT_DONE then the call succeeded. |
This is faster than calling DS2482GetTemperatureCommand for each sensor separately. The reason is that the longest operation, ConvertT, takes 750 milliseconds (for 12-bit readings). When you use DS2482GetTemperatureForListCommand ConvertT for all of the sensors on the bus is done at the same time, so you only incur the 750 millisecond time once, regardless of how many sensors are on the bus. The individual readings need to be made for each DS18B20, but that's fast.
Note that every DS18B20 on the 1-wire bus is commanded to convert their temperature, not just the ones in the deviceList. Only the temperatures for the sensors in the deviceList are retrieved, however.
This call executes asynchronously. The completion function is called when complete or an error occurs.
|
inline |
Sets the conversion size in bits. Default is CONVERSION_12BIT.
value | The number of bits the DS18B20s are configured for. The constants are defined in the DS2482Command class and are one of: CONVERSION_9BIT, CONVERSION_10BIT, CONVERSION_11BIT, or CONVERSION_12BIT. At 9 bits, the resolution is 1/2 degrees C. At 12 bits, the resolution is 1/16 degrees C. The factory default hardware setting is 12 bits. Note that you must have use DS2482SetConfig to set the conversion size first; just reducing the value in this call without changing the DS18B20 configuration will result in invalid readings. |
In the unusual situation that you have sensors of different bit settings, select the largest bit setting.