Need help with an INA219 Voltage Sensor

Can anyone tell me which pins on the Photon I need to connect the SDA and SCL interfaces to?

I’m using the ADAFRUIT-INA219 library on the Web IDE, but I don’t see where these connections are defined in the code…

Thanks

Yes, the datasheet can
https://docs.particle.io/datasheets/photon-(wifi)/photon-datasheet/#pin-description

1 Like

Thanks for the link, I have my wires connected to the right pins, how do I know whether the code I’m using is addressing the same pins?

If the pin name printed near it is the same as you are using to address it in code chances are that you got them right :wink:
Or do you mean SDA/SCL (aka I2C or Wire pins)?
In that case you are not addressing the pins directly but the Wire object takes care of the hardware communication.

I mean the SDA/SCL connections for I2C. I know on the Photon they are on the D0 and D1 pins. What I don’t know (or can’t work out) is how my app and it’s library for the INA219 sensor is addressing those pins.

The app isn’t giving me the output I’m expecting, so I’m trying to confirm that I’ve not missed anything.

If you look in the library you’ll find sections like this

And as said the Wire object takes care of the communication as it is tied to D0/D1 on the Photon.

Have you tried the sample that comes with the library?
Are your A0/A1 pins on the INA board pulled to GND?

Aha, ok. That makes sense, I just went and read up on the wire code, that’s very cool.

The app I’m running is the sample from this library. I’ll have to do some more reading, I may have something wrong elsewhere.

Thanks for your help!

Have you seen the comment about A0/A1 (on the sensor)?

No? Must have missed that, is that a comment in the library?

Yes
https://build.particle.io/libs/adafruit-ina219/0.0.1/tab/adafruit-ina219.h

And in my post

I’ve been following this guide:

As far as I can tell, I don’t need to change any configuration on the INA board, as I’m only using one of them. Is that correct?

In that case the default setting of the board should be fine.
You can always use this sketch to check the addresses connected to the bus
https://build.particle.io/build/58513e73e5e8ae2c11000394

You have connected the board as follows?

INA   Photon
Vcc   Vin
GND   GND
SDA   D0
SCL   D1

Yes, that’s how I have it connected. I suspect my issue is with the battery side of the circuit. I’m trying to use the INA to measure the voltage of a 12v car battery. I’m thinking now that my wiring for the battery circuit is incorrect. I will do some more reading.

Many thanks for your help!

This page reiterates what @ScruffR already detailed from the .h code:

https://learn.adafruit.com/adafruit-ina219-current-sensor-breakout/library-reference

If you don’t specify the new I2C address during instantiation, the first board defaults to 0x40. The second board is 0x41 by default.