INA219 Arduino Library by Soldered 1.0.0
This is a library for the INA219 easyC sensor Module
Loading...
Searching...
No Matches
INA219.h
Go to the documentation of this file.
1/*
2INA219.h - Header file for the Zero-Drift, Bi-directional Current/Power Monitor Arduino Library.
3
4Version: 1.0.0
5(c) 2014 Korneliusz Jarzebski
6www.jarzebski.pl
7
8This program is free software: you can redistribute it and/or modify
9it under the terms of the version 3 GNU General Public License as
10published by the Free Software Foundation.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#ifndef INA219_h
22#define INA219_h
23
24#if ARDUINO >= 100
25#include "Arduino.h"
26#else
27#include "WProgram.h"
28#endif
29
30#define INA219_ADDRESS (0x40)
31
32#define INA219_CMD_READ (0x01)
33
34#define INA219_REG_CONFIG (0x00)
35#define INA219_REG_SHUNTVOLTAGE (0x01)
36#define INA219_REG_BUSVOLTAGE (0x02)
37#define INA219_REG_POWER (0x03)
38#define INA219_REG_CURRENT (0x04)
39#define INA219_REG_CALIBRATION (0x05)
40
41typedef enum
42{
46
54
62
77
89
90
91class INA219
92{
93 public:
94 bool begin(uint8_t address = INA219_ADDRESS);
99 bool calibrate(float rShuntValue = 0.1, float iMaxExcepted = 2);
100
106
107 float readShuntCurrent(void);
108 float readShuntVoltage(void);
109 float readBusPower(void);
110 float readBusVoltage(void);
111
112 float getMaxPossibleCurrent(void);
113 float getMaxCurrent(void);
114 float getMaxShuntVoltage(void);
115 float getMaxPower(void);
116
117 private:
121
122 void writeRegister16(uint8_t reg, uint16_t val);
123 int16_t readRegister16(uint8_t reg);
124};
125
126#endif
ina219_gain_t
Definition INA219.h:48
@ INA219_GAIN_320MV
Definition INA219.h:52
@ INA219_GAIN_40MV
Definition INA219.h:49
@ INA219_GAIN_80MV
Definition INA219.h:50
@ INA219_GAIN_160MV
Definition INA219.h:51
ina219_range_t
Definition INA219.h:42
@ INA219_RANGE_16V
Definition INA219.h:43
@ INA219_RANGE_32V
Definition INA219.h:44
ina219_busRes_t
Definition INA219.h:56
@ INA219_BUS_RES_10BIT
Definition INA219.h:58
@ INA219_BUS_RES_9BIT
Definition INA219.h:57
@ INA219_BUS_RES_11BIT
Definition INA219.h:59
@ INA219_BUS_RES_12BIT
Definition INA219.h:60
ina219_mode_t
Definition INA219.h:79
@ INA219_MODE_POWER_DOWN
Definition INA219.h:80
@ INA219_MODE_SHUNT_CONT
Definition INA219.h:85
@ INA219_MODE_SHUNT_TRIG
Definition INA219.h:81
@ INA219_MODE_ADC_OFF
Definition INA219.h:84
@ INA219_MODE_BUS_TRIG
Definition INA219.h:82
@ INA219_MODE_BUS_CONT
Definition INA219.h:86
@ INA219_MODE_SHUNT_BUS_CONT
Definition INA219.h:87
@ INA219_MODE_SHUNT_BUS_TRIG
Definition INA219.h:83
ina219_shuntRes_t
Definition INA219.h:64
@ INA219_SHUNT_RES_12BIT_8S
Definition INA219.h:71
@ INA219_SHUNT_RES_12BIT_32S
Definition INA219.h:73
@ INA219_SHUNT_RES_10BIT_1S
Definition INA219.h:66
@ INA219_SHUNT_RES_12BIT_16S
Definition INA219.h:72
@ INA219_SHUNT_RES_12BIT_64S
Definition INA219.h:74
@ INA219_SHUNT_RES_12BIT_128S
Definition INA219.h:75
@ INA219_SHUNT_RES_9BIT_1S
Definition INA219.h:65
@ INA219_SHUNT_RES_12BIT_1S
Definition INA219.h:68
@ INA219_SHUNT_RES_12BIT_2S
Definition INA219.h:69
@ INA219_SHUNT_RES_12BIT_4S
Definition INA219.h:70
@ INA219_SHUNT_RES_11BIT_1S
Definition INA219.h:67
Definition INA219.h:92
ina219_gain_t getGain(void)
Definition INA219.cpp:178
void writeRegister16(uint8_t reg, uint16_t val)
Definition INA219.cpp:252
float currentLSB
Definition INA219.h:119
ina219_busRes_t getBusRes(void)
Definition INA219.cpp:189
int8_t inaAddress
Definition INA219.h:118
bool configure(ina219_range_t range=INA219_RANGE_32V, ina219_gain_t gain=INA219_GAIN_320MV, ina219_busRes_t busRes=INA219_BUS_RES_12BIT, ina219_shuntRes_t shuntRes=INA219_SHUNT_RES_12BIT_1S, ina219_mode_t mode=INA219_MODE_SHUNT_BUS_CONT)
Definition INA219.cpp:38
float vBusMax
Definition INA219.h:120
float readBusPower(void)
Definition INA219.cpp:138
float readBusVoltage(void)
Definition INA219.cpp:157
bool calibrate(float rShuntValue=0.1, float iMaxExcepted=2)
Definition INA219.cpp:75
float readShuntCurrent(void)
Definition INA219.cpp:143
float getMaxPossibleCurrent(void)
Definition INA219.cpp:101
float readShuntVoltage(void)
Definition INA219.cpp:148
float getMaxPower(void)
Definition INA219.cpp:133
float vShuntMax
Definition INA219.h:120
int16_t readRegister16(uint8_t reg)
Definition INA219.cpp:221
float rShunt
Definition INA219.h:120
bool begin(uint8_t address=INA219_ADDRESS)
Definition INA219.cpp:31
ina219_shuntRes_t getShuntRes(void)
Definition INA219.cpp:200
float getMaxShuntVoltage(void)
Definition INA219.cpp:120
float getMaxCurrent(void)
Definition INA219.cpp:106
ina219_range_t getRange(void)
Definition INA219.cpp:167
ina219_mode_t getMode(void)
Definition INA219.cpp:211
float powerLSB
Definition INA219.h:119