Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ paragraph=Arduino application for Adafruit.io WipperSnapper
category=Communication
url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino
architectures=*
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 SH110X, Adafruit SSD1306
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 SH110X, Adafruit SSD1306
3 changes: 2 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ lib_deps =
adafruit/Adafruit PM25 AQI Sensor
adafruit/Adafruit SH110X
adafruit/Adafruit SSD1306
https://github.com/tyeth/omron-devhub_d6t-arduino.git
https://github.com/pstolarz/OneWireNg.git
https://github.com/milesburton/Arduino-Temperature-Control-Library.git
https://github.com/Sensirion/arduino-sht.git
Expand Down Expand Up @@ -370,7 +371,7 @@ extra_scripts = pre:rename_usb_config.py
extends = common:esp32
board = adafruit_qtpy_esp32s3_nopsram
build_flags = -DARDUINO_ADAFRUIT_QTPY_ESP32S3_NOPSRAM
board_build.partitions = tinyuf2-partitions-4MB.csv
board_build.partitions = tinyuf2-partitions-8MB.csv
extra_scripts = pre:rename_usb_config.py

; Adafruit QT Py ESP32-S3 with PSRAM
Expand Down
11 changes: 11 additions & 0 deletions src/components/i2c/WipperSnapper_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,17 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
_bme680->configureDriver(msgDeviceInitReq);
drivers.push_back(_bme680);
WS_DEBUG_PRINTLN("BME680 Initialized Successfully!");
} else if (strcmp("d6t1a", msgDeviceInitReq->i2c_device_name) == 0) {
_d6t1a = new WipperSnapper_I2C_Driver_D6T1A(this->_i2c, i2cAddress);
if (!_d6t1a->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize D6T1A");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
return false;
}
_d6t1a->configureDriver(msgDeviceInitReq);
drivers.push_back(_d6t1a);
WS_DEBUG_PRINTLN("D6T1A Initialized Successfully!");
} else if (strcmp("dps310", msgDeviceInitReq->i2c_device_name) == 0) {
_dps310 = new WipperSnapper_I2C_Driver_DPS310(this->_i2c, i2cAddress);
if (!_dps310->begin()) {
Expand Down
2 changes: 2 additions & 0 deletions src/components/i2c/WipperSnapper_I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "drivers/WipperSnapper_I2C_Driver_BME680.h"
#include "drivers/WipperSnapper_I2C_Driver_BMP280.h"
#include "drivers/WipperSnapper_I2C_Driver_BMP3XX.h"
#include "drivers/WipperSnapper_I2C_Driver_D6T1A.h"
#include "drivers/WipperSnapper_I2C_Driver_DPS310.h"
#include "drivers/WipperSnapper_I2C_Driver_DS2484.h"
#include "drivers/WipperSnapper_I2C_Driver_ENS160.h"
Expand Down Expand Up @@ -149,6 +150,7 @@ class WipperSnapper_Component_I2C {
_drivers_out; ///< List of i2c output drivers
// Sensor driver objects
WipperSnapper_I2C_Driver_AHTX0 *_ahtx0 = nullptr;
WipperSnapper_I2C_Driver_D6T1A *_d6t1a = nullptr;
WipperSnapper_I2C_Driver_DPS310 *_dps310 = nullptr;
WipperSnapper_I2C_Driver_DS2484 *_ds2484 = nullptr;
WipperSnapper_I2C_Driver_ENS160 *_ens160 = nullptr;
Expand Down
142 changes: 142 additions & 0 deletions src/components/i2c/drivers/WipperSnapper_I2C_Driver_D6T1A.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*!
* @file WipperSnapper_I2C_Driver_D6T1A.h
*
* Device driver for a D6T1A thermal sensor.
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Copyright (c) Tyeth Gundry 2025 for Adafruit Industries.
*
* MIT license, all text here must be included in any redistribution.
*
*/

#ifndef WipperSnapper_I2C_Driver_D6T1A_H
#define WipperSnapper_I2C_Driver_D6T1A_H

#include <OmronD6T.h>

#include "WipperSnapper_I2C_Driver.h"

/**************************************************************************/
/*!
@brief Class that provides a sensor driver for the D6T1A temperature
and pressure sensor.
*/
/**************************************************************************/
class WipperSnapper_I2C_Driver_D6T1A : public WipperSnapper_I2C_Driver {
public:
/*******************************************************************************/
/*!
@brief Constructor for an D6T1A sensor.
@param i2c
The I2C interface.
@param sensorAddress
7-bit device address.
*/
/*******************************************************************************/
WipperSnapper_I2C_Driver_D6T1A(TwoWire *i2c, uint16_t sensorAddress)
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {
_i2c = i2c;
_sensorAddress = sensorAddress;
_deviceTemp = NAN;
_objectTemp = NAN;
_lastRead = 0;
}

/*******************************************************************************/
/*!
@brief Destructor for an D6T1A sensor.
*/
/*******************************************************************************/
~WipperSnapper_I2C_Driver_D6T1A() { delete _d6t1a; }

/*******************************************************************************/
/*!
@brief Initializes the D6T1A sensor and begins I2C.
@returns True if initialized successfully, False otherwise.
*/
/*******************************************************************************/
bool begin() {
_d6t1a = new OmronD6T(OmronD6T::D6T_1A, _i2c);
// attempt to initialize D6T1A
if (!_d6t1a->begin(_sensorAddress))
return false;
return true;
}

/*******************************************************************************/
/*!
@brief Checks if sensor was read within last 1s, or is the first read.
@returns True if the sensor was recently read, False otherwise.
*/
/*******************************************************************************/
bool HasBeenReadInLast200ms() {
return _lastRead != 0 && millis() - _lastRead < 200;
}

/*******************************************************************************/
/*!
@brief Reads the sensor.
@returns True if the sensor was read successfully, False otherwise.
*/
/*******************************************************************************/
bool ReadSensorData() {
// dont read sensor more than once per 200ms
if (HasBeenReadInLast200ms()) {
return true;
}

_d6t1a->read();
_deviceTemp = (float)_d6t1a->ambientTempC();
_objectTemp = (float)_d6t1a->objectTempC(0, 0);
_lastRead = millis();
return true;
}

/*******************************************************************************/
/*!
@brief Gets the D6T1A's current temperature.
@param tempEvent
Pointer to an Adafruit_Sensor event.
@returns True if the temperature was obtained successfully, False
otherwise.
*/
/*******************************************************************************/
bool getEventAmbientTemp(sensors_event_t *tempEvent) {
if (ReadSensorData() && _deviceTemp != NAN) {
// if the sensor was read recently, return the cached temperature
tempEvent->temperature = _deviceTemp;
return true;
}
return false; // sensor not read recently, return false
}

/*******************************************************************************/
/*!
@brief Gets the D6T1A's object temperature.
@param tempEvent
Pointer to an Adafruit_Sensor event.
@returns True if the temperature was obtained successfully, False
otherwise.
*/
/*******************************************************************************/
bool getEventObjectTemp(sensors_event_t *tempEvent) {
if (ReadSensorData() && _objectTemp != NAN) {
// if the sensor was read recently, return the cached temperature
tempEvent->temperature = _objectTemp;
return true;
}
return false; // sensor not read recently, return false
}

protected:
float _deviceTemp; ///< Device temperature in Celsius
float _objectTemp; ///< Object temperature in Celsius
uint32_t _lastRead; ///< Last time the sensor was read in milliseconds
OmronD6T *_d6t1a = nullptr; ///< D6T1A object
};

#endif // WipperSnapper_I2C_Driver_D6T1A
Loading