# Using two current sensors (ina219), how to write the code?

**URL:** <https://forum.arduino.cc/t/using-two-current-sensors-ina219-how-to-write-the-code/1277312>\
**Category:** Programming\
**Created:** [July 1, 2024, 4:58pm UTC](https://forum.arduino.cc/t/using-two-current-sensors-ina219-how-to-write-the-code/1277312 "2024-07-01T16:58:13Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![bluejets](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bluejets/32/1013044_2.png) [@bluejets](https://forum.arduino.cc/u/bluejets)\
**Post date:** [July 2, 2024, 12:44am UTC](https://forum.arduino.cc/t/using-two-current-sensors-ina219-how-to-write-the-code/1277312/21 "2024-07-02T00:44:00Z")

</div>

> [@bergerino](#):
>
> The way i connect them to arduino UNO is this:  
> ina219 #1: scl -\> A5  
> ina219 #1: sda -\> A4  
> ina219 #2: scl -\> A3  
> ina219 #2: sda -\> A2

A4 and A5 are the only I2C connections.  
Refer below page 8 on selection of different address for your 2 sensors.  
[https://cdn-learn.adafruit.com/downloads/pdf/adafruit-ina219-current-sensor-breakout.pdf](https://cdn-learn.adafruit.com/downloads/pdf/adafruit-ina219-current-sensor-breakout.pdf)

As above DC not AC measurement.

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [July 2, 2024, 12:50am UTC](https://forum.arduino.cc/t/using-two-current-sensors-ina219-how-to-write-the-code/1277312/22 "2024-07-02T00:50:35Z")

</div>

Hi. @bergerino

> [@bergerino](#):
>
> ```arduino
> Adafruit_INA219 ina219_5(0x40);
> Adafruit_INA219 ina219_12(0x41);
> 
> ```

You have two I2C devices with DIFFERENT addresses, why have you got them on separate inputs?  
The reason for two DIFFERENT addresses is so you can operate BOTH on the same I2C bus.

Thanks.. Tom... 😃 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![bergerino](https://avatars.discourse-cdn.com/v4/letter/b/8797f3/32.png) [@bergerino](https://forum.arduino.cc/u/bergerino)\
**Post date:** [July 2, 2024, 10:03am UTC](https://forum.arduino.cc/t/using-two-current-sensors-ina219-how-to-write-the-code/1277312/23 "2024-07-02T10:03:49Z")

</div>

Yeah exactly. Someone else suggested before, i just didn't know you should put them both in the same pin and solder them to change their address. I haven't got the chance to test this out yet but probably that's the problem

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [July 2, 2024, 11:50am UTC](https://forum.arduino.cc/t/using-two-current-sensors-ina219-how-to-write-the-code/1277312/24 "2024-07-02T11:50:00Z")

</div>

> [@bergerino](#):
>
> ```arduino
> Adafruit_INA219 ina219_5(0x40);
> Adafruit_INA219 ina219_12(0x41);
> 
> ```

> [@bergerino](#):
>
> i just didn't know you should put them both in the same pin and solder them to change their address.

Why do you use two different addresses here, 0X40 and 0X41.  
Which address are they both setup for?

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/1/3/9/13990ae7b438d351eb361cecc10beee8e05bf435.jpeg)

If you have not soldered any pads then BOTH sensors will be 0X40.

```arduino
Adafruit_INA219 ina219_5(0x40);
Adafruit_INA219 ina219_12(0x40);

```

Tom.. 😃 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![bergerino](https://avatars.discourse-cdn.com/v4/letter/b/8797f3/32.png) [@bergerino](https://forum.arduino.cc/u/bergerino)\
**Post date:** [July 2, 2024, 8:24pm UTC](https://forum.arduino.cc/t/using-two-current-sensors-ina219-how-to-write-the-code/1277312/25 "2024-07-02T20:24:47Z")

</div>

Got it! I've soldered A0 with my shitty soldering skills, but it works! Thanks alot everyone

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/a/4/c/a4cffcbb7e463b7155e78e39abd0f50945063f2a.png)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [December 29, 2024, 8:25pm UTC](https://forum.arduino.cc/t/using-two-current-sensors-ina219-how-to-write-the-code/1277312/26 "2024-12-29T20:25:24Z")

</div>

Closed on December 29, 2024, 8:25pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.

[Previous page](https://forum.arduino.cc/t/using-two-current-sensors-ina219-how-to-write-the-code/1277312.md?page=1)
