2

I am trying to figure out how to connect a INA219 sensor to two Raspberry Pi's. I am currently using 4 wires that connect the main Raspberry Pi and the INA219 sensor. There is no code, I am connecting the second Raspberry Pi device to the ina219 sensor that the other raspberry 3 device is connected to. I am trying to connect them to the INA219 sensor via GPIO (both Pi's on the same device).

This is more of a hardware question I suppose but I don't have any code. On the main Raspberry Pi, I created a code on the pi that can measure the voltage, current, and power of the Raspberry Pi device and store it within a CSV file from the INA219 sensor. Right now, I am trying to connect two of the already connected wires to another Raspberry Pi measurement for the voltage, current, and power of the pi device.

I already have a code for the second Raspberry Pi measurements for the voltage, current, and power of the Raspberry Pi device. Again, I am trying to connect two Raspberry Pi 3 devices to each other using an INA219 sensor to be able to retrieve code from the second Raspberry Pi device.

3
  • please add a link to the INA219 sensor datasheet at a manufacturer's website .... add the link to the question above, NOT in a comment below
    – jsotola
    Jul 13, 2022 at 4:11
  • 1
    Don't think you can connect one sensor using i2c to 2 Pi's. Why not connect sensor to one Pi and send the data via MQTT to the 2nd Pi?
    – CoderMike
    Jul 13, 2022 at 7:44
  • @codermike I would but I was told to do it in a specific way and I was told to do it like that. I am just really lost and new. I am not sure what MQTT is but I’ll look into it. Jul 13, 2022 at 16:09

2 Answers 2

1

Although it is technically possible to connect one sensor to multiple i2c masters, I'd suggest you don't do this, and find some other way of sharing the data.

Not only are there software complications to do with the multiple masters cooperating correctly, but also there are hardware issues; you are effectively connecting the I/O pins of multiple CPUs together, and any interference on these lines will cause major problems. With i2c, the signal transitions are really important, so the smallest spike on one line can cause havoc, especially in a multi-master configuration.

So although you could go down this path, I'd suggest you don't, as I think it will be really difficult to get this working reliably.

1

What you want to do is called Multi Master on I2C. It is possible but there needs to be some hand shaking between the two processors. This link should help: Connect 3 Raspberry pi using i2c This is something I would not recommend to somebody without I2C experience to do.

You want to connect a INA219 sensor to two or more Raspberry Pis. You need to partially understand the I2C is a bus and all communications on it is digital; with ones and zeros. Regardless of how many items you connect within practical limits you only need two wires assuming power and ground are connected, one for SCL and one for SDA. The grounds for all the I2C devices must be connected.

Since the drivers are open collector/ open drain you two pull up resistors in the range of 3K one each connected from +3V3 to the I2C bus. Check your modules some may have pull up resistors already connected. If so determine the value and determine what your total pull up resistance for each bus is. There are a lot of electronic parts involved but try it if you are above 2K and less teh 10K, otherwise adjust the resistance. You will need to run the I2C scanner to be sure each Pi can talk to the INA219 before each other. This should get your started.

The best thing you can do at this point is draw a Schematic, not a frizzy picture as this could become very involved for frizzy. Post that schematic along with links to technical information on each of the hardware items. Also try to generate some code and post that as well. We are here to help you but the design is yours.

1
  • Pi I²C ALREADY have 1.8kΩ pullups - connecting any more is pointless.
    – Milliways
    Jul 16, 2022 at 2:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.