16 #ifndef WipperSnapper_I2C_Driver_DS2484_H 17 #define WipperSnapper_I2C_Driver_DS2484_H 19 #define DS18B20_FAMILY_CODE 0x28 20 #define DS18B20_CMD_CONVERT_T 0x44 21 #define DS18B20_CMD_MATCH_ROM 0x55 22 #define DS18B20_CMD_READ_SCRATCHPAD 0xBE 25 #include <Adafruit_DS248x.h> 66 _ds2484 =
new Adafruit_DS248x();
78 if (!
_ds2484->presencePulseDetected()) {
85 bool found_device =
false;
88 while (!found_device &&
_ds2484->OneWireSearch(
_rom)) {
116 if (!
_ds2484->OneWireReset()) {
120 if (!
_ds2484->presencePulseDetected()) {
121 tempEvent->temperature = NAN;
126 for (
int i = 0; i < 8; i++) {
135 if (!
_ds2484->OneWireReset()) {
137 "Failed to do a OneWire bus reset after starting temp conversion");
141 for (
int i = 0; i < 8; i++) {
148 for (
int i = 0; i <
sizeof(data) /
sizeof(data[0]); i++) {
149 _ds2484->OneWireReadByte(&data[i]);
153 int16_t raw = (data[1] << 8) | data[0];
154 tempEvent->temperature = (float)raw / 16.0;
176 #endif // WipperSnapper_I2C_Driver_DS2484 #define WS_DEBUG_PRINT(...)
Prints debug output.
Definition: Wippersnapper.h:49
bool begin()
Initializes the DS2484 sensor and begins I2C.
Definition: WipperSnapper_I2C_Driver_DS2484.h:64
WipperSnapper_I2C_Driver_DS2484(TwoWire *i2c, uint16_t sensorAddress)
Constructor for a DS2484 sensor.
Definition: WipperSnapper_I2C_Driver_DS2484.h:45
#define WS_DEBUG_PRINTHEX(...)
Prints debug output.
Definition: Wippersnapper.h:55
Class that provides a sensor driver for the DS2484 I2C OneWire converter hosting a DS18b20 temperatur...
Definition: WipperSnapper_I2C_Driver_DS2484.h:33
Adafruit_DS248x * _ds2484
DS2484 driver object.
Definition: WipperSnapper_I2C_Driver_DS2484.h:172
Base class for I2C Drivers.
Definition: WipperSnapper_I2C_Driver.h:30
uint8_t _rom[8]
DS18B20 ROM.
Definition: WipperSnapper_I2C_Driver_DS2484.h:173
uint16_t _sensorAddress
The I2C driver's unique I2C address.
Definition: WipperSnapper_I2C_Driver.h:1322
bool getEventAmbientTemp(sensors_event_t *tempEvent)
Gets the DS2484's current temperature.
Definition: WipperSnapper_I2C_Driver_DS2484.h:167
bool processTemperatureEvent(sensors_event_t *tempEvent)
Processes a temperature event.
Definition: WipperSnapper_I2C_Driver_DS2484.h:115
#define WS_DEBUG_PRINTLN(...)
Prints line from debug output.
Definition: Wippersnapper.h:52
#define DS18B20_FAMILY_CODE
DS18B20 family code.
Definition: WipperSnapper_I2C_Driver_DS2484.h:19
#define DS18B20_CMD_CONVERT_T
Convert T command.
Definition: WipperSnapper_I2C_Driver_DS2484.h:20
~WipperSnapper_I2C_Driver_DS2484()
Destructor for an DS2484 sensor.
Definition: WipperSnapper_I2C_Driver_DS2484.h:56
#define DS18B20_CMD_READ_SCRATCHPAD
Read Scratchpad command.
Definition: WipperSnapper_I2C_Driver_DS2484.h:22
TwoWire * _i2c
Pointer to the I2C driver's Wire object.
Definition: WipperSnapper_I2C_Driver.h:1321
#define DS18B20_CMD_MATCH_ROM
Match ROM command.
Definition: WipperSnapper_I2C_Driver_DS2484.h:21