Skip to content

Commit

Permalink
Merge pull request #460 from tyeth/add-tmp117
Browse files Browse the repository at this point in the history
Add TMP117
  • Loading branch information
brentru authored Aug 1, 2023
2 parents dfa04f4 + 2ac5ee0 commit f629bc3
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1 deletion.
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 client for Adafruit.io WipperSnapper
category=Communication
url=https://github.com/adafruit/Adafruit_IO_Arduino
architectures=*
depends=Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit SleepyDog Library, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit DPS310, Adafruit SCD30, Adafruit SGP30 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit PM25 AQI Sensor, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit PCT2075, hp_BH1750
depends=Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit DPS310, Adafruit SCD30, Adafruit SGP30 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit PM25 AQI Sensor, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit PCT2075, hp_BH1750
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ lib_deps =
adafruit/Adafruit Si7021 Library
adafruit/Adafruit MCP9808 Library
adafruit/Adafruit MCP9600 Library
adafruit/Adafruit TMP117
adafruit/Adafruit TSL2591 Library
adafruit/Adafruit_VL53L0X
adafruit/Adafruit PM25 AQI Sensor
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 @@ -325,6 +325,17 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
_mcp9808->configureDriver(msgDeviceInitReq);
drivers.push_back(_mcp9808);
WS_DEBUG_PRINTLN("MCP9808 Initialized Successfully!");
} else if (strcmp("tmp117", msgDeviceInitReq->i2c_device_name) == 0) {
_tmp117 = new WipperSnapper_I2C_Driver_TMP117(this->_i2c, i2cAddress);
if (!_tmp117->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize TMP117!");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
return false;
}
_tmp117->configureDriver(msgDeviceInitReq);
drivers.push_back(_tmp117);
WS_DEBUG_PRINTLN("TMP117 Initialized Successfully!");
} else if (strcmp("tsl2591", msgDeviceInitReq->i2c_device_name) == 0) {
_tsl2591 = new WipperSnapper_I2C_Driver_TSL2591(this->_i2c, i2cAddress);
if (!_tsl2591->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 @@ -41,6 +41,7 @@
#include "drivers/WipperSnapper_I2C_Driver_SHTC3.h"
#include "drivers/WipperSnapper_I2C_Driver_SI7021.h"
#include "drivers/WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor.h"
#include "drivers/WipperSnapper_I2C_Driver_TMP117.h"
#include "drivers/WipperSnapper_I2C_Driver_TSL2591.h"
#include "drivers/WipperSnapper_I2C_Driver_VEML7700.h"
#include "drivers/WipperSnapper_I2C_Driver_VL53L0X.h"
Expand Down Expand Up @@ -100,6 +101,7 @@ class WipperSnapper_Component_I2C {
WipperSnapper_I2C_Driver_BME680 *_bme680 = nullptr;
WipperSnapper_I2C_Driver_HTS221 *_hts221 = nullptr;
WipperSnapper_I2C_Driver_MCP9808 *_mcp9808 = nullptr;
WipperSnapper_I2C_Driver_TMP117 *_tmp117 = nullptr;
WipperSnapper_I2C_Driver_TSL2591 *_tsl2591 = nullptr;
WipperSnapper_I2C_Driver_VEML7700 *_veml7700 = nullptr;
WipperSnapper_I2C_Driver_SCD4X *_scd40 = nullptr;
Expand Down
81 changes: 81 additions & 0 deletions src/components/i2c/drivers/WipperSnapper_I2C_Driver_TMP117.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*!
* @file WipperSnapper_I2C_Driver_TMP117.h
*
* Device driver for the TMP117 Temperature 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 2023 for Adafruit Industries.
*
* MIT license, all text here must be included in any redistribution.
*
*/
#ifndef WipperSnapper_I2C_Driver_TMP117_H
#define WipperSnapper_I2C_Driver_TMP117_H

#include "WipperSnapper_I2C_Driver.h"
#include <Adafruit_TMP117.h>

/**************************************************************************/
/*!
@brief Class that provides a driver interface for a TMP117 sensor.
*/
/**************************************************************************/
class WipperSnapper_I2C_Driver_TMP117 : public WipperSnapper_I2C_Driver {
public:
/*******************************************************************************/
/*!
@brief Constructor for a TMP117 sensor.
@param i2c
The I2C interface.
@param sensorAddress
7-bit device address.
*/
/*******************************************************************************/
WipperSnapper_I2C_Driver_TMP117(TwoWire *i2c, uint16_t sensorAddress)
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {
_i2c = i2c;
_sensorAddress = sensorAddress;
}

/*******************************************************************************/
/*!
@brief Destructor for an TMP117 sensor.
*/
/*******************************************************************************/
~WipperSnapper_I2C_Driver_TMP117() {
// Called when a TMP117 component is deleted.
delete _tmp117;
}

/*******************************************************************************/
/*!
@brief Initializes the TMP117 sensor and begins I2C.
@returns True if initialized successfully, False otherwise.
*/
/*******************************************************************************/
bool begin() {
_tmp117 = new Adafruit_TMP117();
return _tmp117->begin((uint8_t)_sensorAddress, _i2c);
}

/*******************************************************************************/
/*!
@brief Gets the TMP117'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) {
return _tmp117->getEvent(tempEvent);
}

protected:
Adafruit_TMP117 *_tmp117; ///< Pointer to TMP117 temperature sensor object
};

#endif // WipperSnapper_I2C_Driver_TMP117

0 comments on commit f629bc3

Please sign in to comment.