HUM: DIGITAL AMMETER + VOLTMETER INA219
You are a beginner with Croduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by e-radionica where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect module with Croduino and the basic code. Everything else is left to your imagination.
The information about the amount of current on the load is useful in many projects which is why we have decided to design this module. Common microcontrollers can not measure current over a few dozen milliamps on their analog inputs. This problem can easily be solved using this module which allows measurement of current ranging from ±3.2A. Breakout board uses INA219 chip and comes with an already-installed precise shunt resistor of small amount which ensures that the measuring member does not significantly affect the rest of the circuit.
Power supply voltage: 3V – 5V
Maximum measured voltage: 26V
Maximum measured current: 3.2A
ADC’s precision : 12 bit
Communication interface: I2C
Shunt resistor: 0.1Ω
Dimensions: 18 mm x 20 mm
HOW DOES IT WORK?
The module works the same as a traditional ammeter in a way that it is serial connected to the circuit. When the module is serial connected, the same current will flow through the module and the rest of the circuit. This current will generate a voltage drop on the already mentioned shunt resistor, proportional to the current power, which corresponds to Ohm’s law. This voltage is then converted via analog-digital converter to digital information we can easily transmit through communication interface.
HOW TO CONNECT IT?
VCC: voltage 2.7V – 5.5V
SDA: serial data I2C
SCL: serial clock
VIN+: current input
VIN-: current output
The module is connected as follows. We connect the SDA and SCL connectors to the homonymous connectors on the Croduino. The module’s power supply is obtained by connecting +5V off the Croduino to module’s Vcc and by connecting module’s ground to the controller’s ground. In this example, we use few LEDs and a 20Ω resistor as a load. VIN+ connector is connected to the +5V on the Croduino, and VIN- connector to one side of the resistor. Resistor is then connected to LEDs’ anode (+), and LEDs’ cathode to the ground. If you want to change the module’s address on the I2C communication, you must solder jumpers marked A1 and A0. In this way you can achieve four different addresses depending on which jumper is soldered.
Using this module is very simple and can easily be embeded into your project. For proper execution of the following code, it is necessary to download a library from this link. In case you do not know how to install the library, read our tutorial. With this very simple code in the Serial Monitor we read the amount of current on the load, every two seconds.
"Mjerenje struje: "
struja_mA = 0;
//variable for saving current values
struja_mA = ina219.getCurrent_mA();
//current reading from the sensor
"Struja iznosi: "
); Serial.print(struja_mA); Serial.println(