Skip to content

Commit b35c2c2

Browse files
committed
Add OMRON D6T thermal sensor
1 parent 13d4ca9 commit b35c2c2

File tree

5 files changed

+114
-1
lines changed

5 files changed

+114
-1
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ 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 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 SSD1306
10+
depends=OmronD6T - Community Fork, SdFat - Adafruit Fork, Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit INA260 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 SSD1306

platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ lib_deps =
8585
adafruit/Adafruit LED Backpack Library
8686
adafruit/Adafruit PM25 AQI Sensor
8787
adafruit/Adafruit SSD1306
88+
https://github.com/tyeth/omron-devhub_d6t-arduino.git
8889
https://github.com/pstolarz/OneWireNg.git
8990
https://github.com/milesburton/Arduino-Temperature-Control-Library.git
9091
https://github.com/Sensirion/arduino-sht.git

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: 1 addition & 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"
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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 "WipperSnapper_I2C_Driver.h"
20+
#include <OmronD6T.h>
21+
22+
/**************************************************************************/
23+
/*!
24+
@brief Class that provides a sensor driver for the D6T1A temperature
25+
and pressure sensor.
26+
*/
27+
/**************************************************************************/
28+
class WipperSnapper_I2C_Driver_D6T1A : public WipperSnapper_I2C_Driver {
29+
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+
}
45+
46+
/*******************************************************************************/
47+
/*!
48+
@brief Destructor for an D6T1A sensor.
49+
*/
50+
/*******************************************************************************/
51+
~WipperSnapper_I2C_Driver_D6T1A() { delete _d6t1a; }
52+
53+
/*******************************************************************************/
54+
/*!
55+
@brief Initializes the D6T1A sensor and begins I2C.
56+
@returns True if initialized successfully, False otherwise.
57+
*/
58+
/*******************************************************************************/
59+
bool begin() {
60+
_d6t1a = new OmronD6T( OmronD6T.Model.D6T_1A, _i2c);
61+
// attempt to initialize D6T1A
62+
if (!_d6t1a->begin(_sensorAddress))
63+
return false;
64+
return true;
65+
}
66+
67+
/*******************************************************************************/
68+
/*!
69+
@brief Gets the D6T1A's current temperature.
70+
@param tempEvent
71+
Pointer to an Adafruit_Sensor event.
72+
@returns True if the temperature was obtained successfully, False
73+
otherwise.
74+
*/
75+
/*******************************************************************************/
76+
bool getEventAmbientTemp(sensors_event_t *tempEvent) {
77+
tempEvent->temperature = _d6t1a->ambientTempC();
78+
return true;
79+
}
80+
81+
/*******************************************************************************/
82+
/*!
83+
@brief Gets the D6T1A's object temperature.
84+
@param tempEvent
85+
Pointer to an Adafruit_Sensor event.
86+
@returns True if the temperature was obtained successfully, False
87+
otherwise.
88+
*/
89+
/*******************************************************************************/
90+
bool getEventObjectTemp(sensors_event_t *tempEvent) {
91+
tempEvent->temperature = _d6t1a->objectTempC();
92+
return true;
93+
}
94+
95+
96+
protected:
97+
OmronD6T *_d6t1a; ///< D6T1A object
98+
};
99+
100+
#endif // WipperSnapper_I2C_Driver_D6T1A

0 commit comments

Comments
 (0)