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 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
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
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ lib_deps =
adafruit/Adafruit DPS310
adafruit/Adafruit DS248x
adafruit/Adafruit INA219
adafruit/Adafruit INA260 Library
adafruit/Adafruit HDC302x
adafruit/Adafruit HTS221
adafruit/Adafruit HTU21DF Library
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 @@ -391,6 +391,17 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
_ina219->configureDriver(msgDeviceInitReq);
drivers.push_back(_ina219);
WS_DEBUG_PRINTLN("INA219 Initialized Successfully!");
} else if (strcmp("ina260", msgDeviceInitReq->i2c_device_name) == 0) {
_ina260 = new WipperSnapper_I2C_Driver_INA260(this->_i2c, i2cAddress);
if (!_ina260->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize INA260");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
return false;
}
_ina260->configureDriver(msgDeviceInitReq);
drivers.push_back(_ina260);
WS_DEBUG_PRINTLN("INA260 Initialized Successfully!");
} else if (strcmp("ltr390", msgDeviceInitReq->i2c_device_name) == 0) {
_ltr390 = new WipperSnapper_I2C_Driver_LTR390(this->_i2c, i2cAddress);
if (!_ltr390->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 @@ -35,6 +35,7 @@
#include "drivers/WipperSnapper_I2C_Driver_HTU21D.h"
#include "drivers/WipperSnapper_I2C_Driver_HTU31D.h"
#include "drivers/WipperSnapper_I2C_Driver_INA219.h"
#include "drivers/WipperSnapper_I2C_Driver_INA260.h"
#include "drivers/WipperSnapper_I2C_Driver_LC709203F.h"
#include "drivers/WipperSnapper_I2C_Driver_LPS22HB.h"
#include "drivers/WipperSnapper_I2C_Driver_LPS25HB.h"
Expand Down Expand Up @@ -150,6 +151,7 @@ class WipperSnapper_Component_I2C {
WipperSnapper_I2C_Driver_HTU21D *_htu21d = nullptr;
WipperSnapper_I2C_Driver_HTU31D *_htu31d = nullptr;
WipperSnapper_I2C_Driver_INA219 *_ina219 = nullptr;
WipperSnapper_I2C_Driver_INA260 *_ina260 = nullptr;
WipperSnapper_I2C_Driver_LTR329_LTR303 *_ltr329 = nullptr;
WipperSnapper_I2C_Driver_LTR390 *_ltr390 = nullptr;
WipperSnapper_I2C_Driver_MCP3421 *_mcp3421 = nullptr;
Expand Down
99 changes: 99 additions & 0 deletions src/components/i2c/drivers/WipperSnapper_I2C_Driver_INA260.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*!
* @file WipperSnapper_I2C_Driver_INA260.h
*
* Device driver for the INA260 DC Current and Voltage Monitor
*
* 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_INA260_H
#define WipperSnapper_I2C_Driver_INA260_H

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

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

/*******************************************************************************/
/*!
@brief Destructor for an INA260 sensor.
*/
/*******************************************************************************/
~WipperSnapper_I2C_Driver_INA260() { delete _ina260; }

/*******************************************************************************/
/*!
@brief Initializes the INA260 sensor and begins I2C.
@returns True if initialized successfully, False otherwise.
*/
/*******************************************************************************/
bool begin() {
_ina260 = new Adafruit_INA260();
if (!_ina260->begin(_sensorAddress, _i2c)) {
WS_DEBUG_PRINTLN("INA260 failed to initialise!");
return false;
}
// TODO: use setCalibration()

return true;
}

/*******************************************************************************/
/*!
@brief Reads a voltage sensor and converts the
reading into the expected SI unit.
@param voltageEvent
voltage sensor reading, in volts.
@returns True if the sensor event was obtained successfully, False
otherwise.
*/
/*******************************************************************************/
bool getEventVoltage(sensors_event_t *voltageEvent) {
voltageEvent->voltage = _ina260->readBusVoltage();
return true;
}

/**
* @brief Get the current sensor event.
*
* @param currentEvent Pointer to the current sensor event.
*
* @returns True if the sensor event was obtained successfully, False
* otherwise.
*/
bool getEventCurrent(sensors_event_t *currentEvent) {
currentEvent->current = _ina260->readCurrent();
return true;
}

protected:
Adafruit_INA260 *_ina260; ///< Pointer to INA260 sensor object
};

#endif // WipperSnapper_I2C_Driver_INA260
Loading