Skip to content

Commit c9e728c

Browse files
committed
Merge branch 'upstream-main' into ina238
2 parents a1cdc01 + 9a80336 commit c9e728c

File tree

6 files changed

+159
-3
lines changed

6 files changed

+159
-3
lines changed

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name=Adafruit WipperSnapper
2-
version=1.0.0-beta.104
2+
version=1.0.0-beta.105
33
author=Adafruit
44
maintainer=Adafruit <adafruitio@adafruit.com>
55
sentence=Arduino application for Adafruit.io WipperSnapper
66
paragraph=Arduino application for Adafruit.io WipperSnapper
77
category=Communication
88
url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino
99
architectures=*
10-
depends=SdFat - Adafruit Fork, Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit INA260 Library, Adafruit INA237 and INA238 Library, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, Sensirion I2C SEN66, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VCNL4200 Library, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS28, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork, Adafruit BusIO, Adafruit Unified Sensor, Sensirion Core, Adafruit GFX Library, Adafruit LED Backpack Library, Adafruit LiquidCrystal, Adafruit SH110X, Adafruit SSD1306
10+
depends=OmronD6T - Community Fork, SdFat - Adafruit Fork, Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit INA260 Library, Adafruit INA237 and INA238 Library, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, Sensirion I2C SEN66, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VCNL4200 Library, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS28, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork, Adafruit BusIO, Adafruit Unified Sensor, Sensirion Core, Adafruit GFX Library, Adafruit LED Backpack Library, Adafruit LiquidCrystal, Adafruit SH110X, Adafruit SSD1306

platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ lib_deps =
8787
adafruit/Adafruit PM25 AQI Sensor
8888
adafruit/Adafruit SH110X
8989
adafruit/Adafruit SSD1306
90+
https://github.com/tyeth/omron-devhub_d6t-arduino.git
9091
https://github.com/pstolarz/OneWireNg.git
9192
https://github.com/milesburton/Arduino-Temperature-Control-Library.git
9293
https://github.com/Sensirion/arduino-sht.git

src/Wippersnapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
#endif
143143

144144
#define WS_VERSION \
145-
"1.0.0-beta.104" ///< WipperSnapper app. version (semver-formatted)
145+
"1.0.0-beta.105" ///< WipperSnapper app. version (semver-formatted)
146146

147147
// Reserved Adafruit IO MQTT topics
148148
#define TOPIC_IO_THROTTLE "/throttle" ///< Adafruit IO Throttle MQTT Topic

src/components/i2c/WipperSnapper_I2C.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,17 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
292292
_bme680->configureDriver(msgDeviceInitReq);
293293
drivers.push_back(_bme680);
294294
WS_DEBUG_PRINTLN("BME680 Initialized Successfully!");
295+
} else if (strcmp("d6t1a", msgDeviceInitReq->i2c_device_name) == 0) {
296+
_d6t1a = new WipperSnapper_I2C_Driver_D6T1A(this->_i2c, i2cAddress);
297+
if (!_d6t1a->begin()) {
298+
WS_DEBUG_PRINTLN("ERROR: Failed to initialize D6T1A");
299+
_busStatusResponse =
300+
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
301+
return false;
302+
}
303+
_d6t1a->configureDriver(msgDeviceInitReq);
304+
drivers.push_back(_d6t1a);
305+
WS_DEBUG_PRINTLN("D6T1A Initialized Successfully!");
295306
} else if (strcmp("dps310", msgDeviceInitReq->i2c_device_name) == 0) {
296307
_dps310 = new WipperSnapper_I2C_Driver_DPS310(this->_i2c, i2cAddress);
297308
if (!_dps310->begin()) {

src/components/i2c/WipperSnapper_I2C.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "drivers/WipperSnapper_I2C_Driver_BME680.h"
2828
#include "drivers/WipperSnapper_I2C_Driver_BMP280.h"
2929
#include "drivers/WipperSnapper_I2C_Driver_BMP3XX.h"
30+
#include "drivers/WipperSnapper_I2C_Driver_D6T1A.h"
3031
#include "drivers/WipperSnapper_I2C_Driver_DPS310.h"
3132
#include "drivers/WipperSnapper_I2C_Driver_DS2484.h"
3233
#include "drivers/WipperSnapper_I2C_Driver_ENS160.h"
@@ -154,6 +155,7 @@ class WipperSnapper_Component_I2C {
154155
_drivers_out; ///< List of i2c output drivers
155156
// Sensor driver objects
156157
WipperSnapper_I2C_Driver_AHTX0 *_ahtx0 = nullptr;
158+
WipperSnapper_I2C_Driver_D6T1A *_d6t1a = nullptr;
157159
WipperSnapper_I2C_Driver_DPS310 *_dps310 = nullptr;
158160
WipperSnapper_I2C_Driver_DS2484 *_ds2484 = nullptr;
159161
WipperSnapper_I2C_Driver_ENS160 *_ens160 = nullptr;
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*!
2+
* @file WipperSnapper_I2C_Driver_D6T1A.h
3+
*
4+
* Device driver for a D6T1A thermal sensor.
5+
*
6+
* Adafruit invests time and resources providing this open source code,
7+
* please support Adafruit and open-source hardware by purchasing
8+
* products from Adafruit!
9+
*
10+
* Copyright (c) Tyeth Gundry 2025 for Adafruit Industries.
11+
*
12+
* MIT license, all text here must be included in any redistribution.
13+
*
14+
*/
15+
16+
#ifndef WipperSnapper_I2C_Driver_D6T1A_H
17+
#define WipperSnapper_I2C_Driver_D6T1A_H
18+
19+
#include <OmronD6T.h>
20+
21+
#include "WipperSnapper_I2C_Driver.h"
22+
23+
/**************************************************************************/
24+
/*!
25+
@brief Class that provides a sensor driver for the D6T1A temperature
26+
and pressure sensor.
27+
*/
28+
/**************************************************************************/
29+
class WipperSnapper_I2C_Driver_D6T1A : public WipperSnapper_I2C_Driver {
30+
public:
31+
/*******************************************************************************/
32+
/*!
33+
@brief Constructor for an D6T1A sensor.
34+
@param i2c
35+
The I2C interface.
36+
@param sensorAddress
37+
7-bit device address.
38+
*/
39+
/*******************************************************************************/
40+
WipperSnapper_I2C_Driver_D6T1A(TwoWire *i2c, uint16_t sensorAddress)
41+
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {
42+
_i2c = i2c;
43+
_sensorAddress = sensorAddress;
44+
_deviceTemp = NAN;
45+
_objectTemp = NAN;
46+
_lastRead = 0;
47+
}
48+
49+
/*******************************************************************************/
50+
/*!
51+
@brief Destructor for an D6T1A sensor.
52+
*/
53+
/*******************************************************************************/
54+
~WipperSnapper_I2C_Driver_D6T1A() { delete _d6t1a; }
55+
56+
/*******************************************************************************/
57+
/*!
58+
@brief Initializes the D6T1A sensor and begins I2C.
59+
@returns True if initialized successfully, False otherwise.
60+
*/
61+
/*******************************************************************************/
62+
bool begin() {
63+
_d6t1a = new OmronD6T(OmronD6T::D6T_1A, _i2c);
64+
// attempt to initialize D6T1A
65+
if (!_d6t1a->begin(_sensorAddress))
66+
return false;
67+
return true;
68+
}
69+
70+
/*******************************************************************************/
71+
/*!
72+
@brief Checks if sensor was read within last 1s, or is the first read.
73+
@returns True if the sensor was recently read, False otherwise.
74+
*/
75+
/*******************************************************************************/
76+
bool HasBeenReadInLast200ms() {
77+
return _lastRead != 0 && millis() - _lastRead < 200;
78+
}
79+
80+
/*******************************************************************************/
81+
/*!
82+
@brief Reads the sensor.
83+
@returns True if the sensor was read successfully, False otherwise.
84+
*/
85+
/*******************************************************************************/
86+
bool ReadSensorData() {
87+
// dont read sensor more than once per 200ms
88+
if (HasBeenReadInLast200ms()) {
89+
return true;
90+
}
91+
92+
_d6t1a->read();
93+
_deviceTemp = (float)_d6t1a->ambientTempC();
94+
_objectTemp = (float)_d6t1a->objectTempC(0, 0);
95+
_lastRead = millis();
96+
return true;
97+
}
98+
99+
/*******************************************************************************/
100+
/*!
101+
@brief Gets the D6T1A's current temperature.
102+
@param tempEvent
103+
Pointer to an Adafruit_Sensor event.
104+
@returns True if the temperature was obtained successfully, False
105+
otherwise.
106+
*/
107+
/*******************************************************************************/
108+
bool getEventAmbientTemp(sensors_event_t *tempEvent) {
109+
if (ReadSensorData() && _deviceTemp != NAN) {
110+
// if the sensor was read recently, return the cached temperature
111+
tempEvent->temperature = _deviceTemp;
112+
return true;
113+
}
114+
return false; // sensor not read recently, return false
115+
}
116+
117+
/*******************************************************************************/
118+
/*!
119+
@brief Gets the D6T1A's object temperature.
120+
@param tempEvent
121+
Pointer to an Adafruit_Sensor event.
122+
@returns True if the temperature was obtained successfully, False
123+
otherwise.
124+
*/
125+
/*******************************************************************************/
126+
bool getEventObjectTemp(sensors_event_t *tempEvent) {
127+
if (ReadSensorData() && _objectTemp != NAN) {
128+
// if the sensor was read recently, return the cached temperature
129+
tempEvent->temperature = _objectTemp;
130+
return true;
131+
}
132+
return false; // sensor not read recently, return false
133+
}
134+
135+
protected:
136+
float _deviceTemp; ///< Device temperature in Celsius
137+
float _objectTemp; ///< Object temperature in Celsius
138+
uint32_t _lastRead; ///< Last time the sensor was read in milliseconds
139+
OmronD6T *_d6t1a = nullptr; ///< D6T1A object
140+
};
141+
142+
#endif // WipperSnapper_I2C_Driver_D6T1A

0 commit comments

Comments
 (0)