forked from johngineer/ArduinoINA219
-
Notifications
You must be signed in to change notification settings - Fork 16
/
ina219_test.ino
63 lines (44 loc) · 1.38 KB
/
ina219_test.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**********************************************
* INA219 library example
* 10 May 2012 by johngineer
*
* 9 January 2016 Flavius Bindea: changed default values and begin()
*
* this code is public domain.
**********************************************/
#include <Wire.h>
#include <INA219.h>
INA219 monitor;
void setup()
{
Serial.begin(9600);
monitor.begin();
// begin calls:
// configure() with default values RANGE_32V, GAIN_8_320MV, ADC_12BIT, ADC_12BIT, CONT_SH_BUS
// calibrate() with default values D_SHUNT=0.1, D_V_BUS_MAX=32, D_V_SHUNT_MAX=0.2, D_I_MAX_EXPECTED=2
// in order to work directly with ADAFruit's INA219B breakout
}
void loop()
{
Serial.println("******************");
Serial.print("raw shunt voltage: ");
Serial.println(monitor.shuntVoltageRaw());
Serial.print("raw bus voltage: ");
Serial.println(monitor.busVoltageRaw());
Serial.println("--");
Serial.print("shunt voltage: ");
Serial.print(monitor.shuntVoltage() * 1000, 4);
Serial.println(" mV");
Serial.print("shunt current: ");
Serial.print(monitor.shuntCurrent() * 1000, 4);
Serial.println(" mA");
Serial.print("bus voltage: ");
Serial.print(monitor.busVoltage(), 4);
Serial.println(" V");
Serial.print("bus power: ");
Serial.print(monitor.busPower() * 1000, 4);
Serial.println(" mW");
Serial.println(" ");
Serial.println(" ");
delay(10000);
}