Adafruit INA260 Arduino Library
Go to the documentation of this file.
17 #ifndef _ADAFRUIT_INA260_H
18 #define _ADAFRUIT_INA260_H
20 #include "Arduino.h"
21 #include <Adafruit_I2CDevice.h>
22 #include <Adafruit_I2CRegister.h>
23 #include <Wire.h>
25 #define INA260_I2CADDR_DEFAULT 0x40
26 #define INA260_REG_CONFIG 0x00
27 #define INA260_REG_CURRENT 0x01
28 #define INA260_REG_BUSVOLTAGE 0x02
29 #define INA260_REG_POWER 0x03
30 #define INA260_REG_MASK_ENABLE \
31  0x06
32 #define INA260_REG_ALERT_LIMIT 0x07
33 #define INA260_REG_MFG_UID 0xFE
34 #define INA260_REG_DIE_UID 0xFF
41 typedef enum _mode {
58 typedef enum _conversion_time {
74 typedef enum _count {
90 typedef enum _alert_type {
105 typedef enum _alert_polarity {
115 typedef enum _alert_latch {
127 public:
128  Adafruit_INA260();
129  bool begin(uint8_t i2c_addr = INA260_I2CADDR_DEFAULT,
130  TwoWire *theWire = &Wire);
131  void reset(void);
132  float readCurrent(void);
133  float readBusVoltage(void);
134  float readPower(void);
135  void setMode(INA260_MeasurementMode mode);
138  bool conversionReady(void);
139  bool alertFunctionFlag(void);
141  float getAlertLimit(void);
142  void setAlertLimit(float limit);
144  void setAlertLatch(INA260_AlertLatch state);
146  void setAlertPolarity(INA260_AlertPolarity polarity);
148  void setAlertType(INA260_AlertType alert);
157  Adafruit_I2CRegister *Config,
158  *MaskEnable,
159  *AlertLimit;
161 private:
162  Adafruit_I2CDevice *i2c_dev;
163 };
165 #endif
Averaging Count options.
Definition: Adafruit_INA260.h:74
Trigger on conversion ready.
Definition: Adafruit_INA260.h:91
Measurement time: 558us.
Definition: Adafruit_INA260.h:62
void setCurrentConversionTime(INA260_ConversionTime time)
Sets the current conversion time.
Definition: Adafruit_INA260.cpp:186
bool conversionReady(void)
Checks if the most recent one shot measurement has completed.
Definition: Adafruit_INA260.cpp:221
float readCurrent(void)
Reads and scales the current value of the Current register.
Definition: Adafruit_INA260.cpp:97
Window size: 64 samples.
Definition: Adafruit_INA260.h:78
Mode options.
Definition: Adafruit_INA260.h:41
void setVoltageConversionTime(INA260_ConversionTime time)
Sets the bus voltage conversion time.
Definition: Adafruit_INA260.cpp:209
Trigger on bus voltage under limit.
Definition: Adafruit_INA260.h:93
Window size: 512 samples.
Definition: Adafruit_INA260.h:81
Adafruit_I2CRegister * Config
BusIO Register for Config.
Definition: Adafruit_INA260.h:157
void reset(void)
Resets the harware. All registers are set to default values, the same as a power-on reset...
Definition: Adafruit_INA260.cpp:87
Window size: 1 sample (Default)
Definition: Adafruit_INA260.h:75
INA260_AveragingCount getAveragingCount(void)
Reads the current number of averaging samples.
Definition: Adafruit_INA260.cpp:151
void setAlertPolarity(INA260_AlertPolarity polarity)
Sets Alert Polarity Bit.
Definition: Adafruit_INA260.cpp:290
Active low open-collector.
Definition: Adafruit_INA260.h:107
enum _alert_polarity INA260_AlertPolarity
Alert pin polarity options.
Window size: 1024 samples.
Definition: Adafruit_INA260.h:82
Measurement time: 2.116ms.
Definition: Adafruit_INA260.h:64
Alert pin polarity options.
Definition: Adafruit_INA260.h:105
float readPower(void)
Reads and scales the current value of the Power register.
Definition: Adafruit_INA260.cpp:119
Class that stores state and functions for interacting with INA260 Current and Power Sensor...
Definition: Adafruit_INA260.h:126
Window size: 16 samples.
Definition: Adafruit_INA260.h:77
INA260_AlertPolarity getAlertPolarity(void)
Reads the current alert polarity setting.
Definition: Adafruit_INA260.cpp:278
Trigger on bus voltage over limit.
Definition: Adafruit_INA260.h:94
Alert trigger options.
Definition: Adafruit_INA260.h:90
Measurement time: 332us.
Definition: Adafruit_INA260.h:61
enum _mode INA260_MeasurementMode
Mode options.
Measurement time: 4.156ms.
Definition: Adafruit_INA260.h:65
bool begin(uint8_t i2c_addr=INA260_I2CADDR_DEFAULT, TwoWire *theWire=&Wire)
Sets up the HW.
Definition: Adafruit_INA260.cpp:52
enum _alert_latch INA260_AlertLatch
Alert pin latch options.
Window size: 256 samples.
Definition: Adafruit_INA260.h:80
INA260_MeasurementMode getMode(void)
Returns the current measurement mode.
Definition: Adafruit_INA260.cpp:130
void setMode(INA260_MeasurementMode mode)
Sets a new measurement mode.
Definition: Adafruit_INA260.cpp:141
Definition: Adafruit_INA260.h:42
Definition: Adafruit_INA260.h:45
Adafruit_I2CRegister * AlertLimit
BusIO Register for AlertLimit.
Definition: Adafruit_INA260.h:157
Window size: 128 samples.
Definition: Adafruit_INA260.h:79
void setAlertLimit(float limit)
Sets the Alert Limit.
Definition: Adafruit_INA260.cpp:267
Trigger on power over limit.
Definition: Adafruit_INA260.h:92
Window size: 4 samples.
Definition: Adafruit_INA260.h:76
Trigger on current over limit.
Definition: Adafruit_INA260.h:96
Definition: Adafruit_INA260.h:48
enum _alert_type INA260_AlertType
Alert trigger options.
Measurement time: 8.224ms.
Definition: Adafruit_INA260.h:66
Do not trigger alert pin (Default)
Definition: Adafruit_INA260.h:97
Measurement time: 1.1ms (Default)
Definition: Adafruit_INA260.h:63
float getAlertLimit(void)
Reads the current alert limit setting.
Definition: Adafruit_INA260.cpp:255
Definition: Adafruit_INA260.h:116
bool alertFunctionFlag(void)
Checks if the Alert Flag is set.
Definition: Adafruit_INA260.cpp:324
float readBusVoltage(void)
Reads and scales the current value of the Bus Voltage register.
Definition: Adafruit_INA260.cpp:108
Definition: Adafruit_INA260.h:118
void setAveragingCount(INA260_AveragingCount count)
Sets the number of averaging samples.
Definition: Adafruit_INA260.cpp:163
INA260_AlertType getAlertType(void)
Reads the current parameter that asserts the ALERT pin.
Definition: Adafruit_INA260.cpp:232
INA260_ConversionTime getVoltageConversionTime(void)
Reads the current bus voltage conversion time.
Definition: Adafruit_INA260.cpp:197
INA260_ConversionTime getCurrentConversionTime(void)
Reads the current current conversion time.
Definition: Adafruit_INA260.cpp:174
INA260_AlertLatch getAlertLatch(void)
Reads the current alert latch setting.
Definition: Adafruit_INA260.cpp:301
Trigger on current under limit.
Definition: Adafruit_INA260.h:95
Measurement time: 140us.
Definition: Adafruit_INA260.h:59
Measurement time: 204us.
Definition: Adafruit_INA260.h:60
Instantiates a new INA260 class.
Definition: Adafruit_INA260.cpp:42
enum _count INA260_AveragingCount
Averaging Count options.
Conversion Time options.
Definition: Adafruit_INA260.h:58
Alert pin latch options.
Definition: Adafruit_INA260.h:115
Active high open-collector (Default)
Definition: Adafruit_INA260.h:106
void setAlertLatch(INA260_AlertLatch state)
Sets Alert Latch Bit.
Definition: Adafruit_INA260.cpp:313
INA260 default i2c address.
Definition: Adafruit_INA260.h:25
enum _conversion_time INA260_ConversionTime
Conversion Time options.
void setAlertType(INA260_AlertType alert)
Sets which parameter asserts the ALERT pin.
Definition: Adafruit_INA260.cpp:244
Adafruit_I2CRegister * MaskEnable
BusIO Register for MaskEnable.
Definition: Adafruit_INA260.h:157