Arduino and sensor modules on different ground potentials

I'm in the process of building up a datalogger using a Nano and multiple different modules (INA3221 power monitors, 16-bit ADC, RTC, uSD card, MAX7219). As I was thinking about how the sensors would connect, specifically the INA3221 power monitors, it dawned on me that I have two separate ground potentials that I cannot connect together.

For some background, I have a secondary 12v battery in a vehicle that is charged by a DC-DC charger. The DC-DC charger completely isolates the secondary battery (input and output grounds are not connected together at any point in time, same for the 12v input and output) from the primary (starting) 12v battery in the vehicle. The charger engages when the vehicle is running so that the secondary battery is only getting charged when the vehicle's alternator is working. I need to monitor the current and voltage of circuits on the secondary battery as well as the primary vehicle battery, both when the vehicle is running and when it is not.

The Nano, RTC, uSD card module, and 16-bit ADC will all be connected to the secondary 12v battery. The power monitors (INA3221), however, will be connected to external 100A shunts that are connected to the primary 12v battery. Normally it would be no issue to connect the two battery grounds together, however, that will destroy the DC-DC charger (manual specifically says not to do this. Also, the input ground to the output positive is over 25v when charging.) thus I cannot do that.

Since the INA3221 power monitors require the input power source and measured power source to share a common ground, I cannot power it from the same power source as the Nano. This leaves me with powering the INA3221 from the vehicle's primary battery. I presume this will be a problem for the I2C connection back to the Nano, if it doesn't outright destroy it.

I presume that I will need to isolate the Nano from the INA3221 with an I2C isolator such as a ADuM1250 or similar? Am I making this more complicated than it needs to be? Am I missing something or will that work?

I know I could get around this issue using contactless hall effect current sensors, but I already have the shunts and the hall effect sensors I would need take about a month to get here from China.

You already came to the right conclusion. You are not missing something and it will work.
An isolated unit with an Arduino board, current sensor, shunt, and so on, is needed.

To communicate between two Arduino boards which are isolated from each other, a I2C bus might not be a good choice. Have you done I2C projects before ? It is a weak bus, and it is not supposed to go into a cable. It is not that kind of bus.
An isolated Serial RX-TX communication might be better. Simple optocouplers can do the isolation.

There are also USB-isolaters and many other isolator communication chips.

Sometimes wireless communication is easier than a isolator.

Let us go back to the origin of the problem: the charger.
What is wrong with the charger that it can not be used in a normal way ?
Can you put the charging power through a circuit to make it "normal".

Have you actually checked this with an Ohmmeter?

Another question. How do you use the secondary battery if it's ground is not the same as the primary battery?

@Koepel
Let me go back even further. The secondary battery is lithium based and thus the decision was to completely isolate it from the vehicle. The DC-DC charger that was selected does just that, completely isolates the output from the input. There is no way to have the two battery systems share a common ground point without replacing the charger which is very expensive and not something I can do.

I have done I2C projects before, but nothing that required more than a foot or two of distance. Using a shielded 22AWG cable for those projects worked out great without modifying the pull-up resistors. I figured I would need to do that again for this project, use much lower pull-up resistor values, and drop the clock rate a lot in order to get the ~10ft of length I would need. From the research I have done, 10ft is doable with shielded wire, lower resistor values, and lower clock rates. If it doesn't work, I was planning on using some sort of converter to adapt the I2C signal to something I can push over distance back to the Nano.

@Paul_KD7HB
Yes, the meter reads open when connected to the two grounds and open again when connected to the two power connections. When the charger is operational, the voltage between the input ground and the output power is in excess of 25v.

Everything connected to the secondary battery is only ever powered by the secondary battery. This allows for operation at all times of the day regardless of if the vehicle is running or not. The DC-DC charger is sized large enough to run all of the items connected to the secondary battery in addition to charging it. The secondary battery is acting like a "house" battery in an RV or boat, and is never used to start or run the vehicle, charge the primary battery, or run the factory circuits in the vehicle (those connected to the two factory fuse panels).

Thank you for the great explanation! My only experience is with diode isolated secondary batteries.

Ten feet is three meters. That is a lot for a I2C bus in a environment with other devices that might cause noise.

The official I2C standard says that when it is longer than 10 cm, you have to take special care.

10 cm is about half a banana length :banana:

When you add drivers that turn the I2C bus into something that can travel further, that feels like a bandage on a weak spot. You could also do it right from the start and use serial communication instead of I2C.

@Koepel
I've been looking into using an I2C isolator on the sensor side that then feeds into something like a MAX3232 to convert to RS232. Then on the arduino side, convert from RS232 to the 5v logic UART/serial connection.

I have to spend more money either way, so do you think that way would be easiest, or should I get another Nano and serial isolator of some sort instead? I have not done MCU-MCU communication before.

Why do you need to separate the grounds? I understand that the DC=DC charger that you have does this - i.e. it has an internal transformer - but I doubt that connecting its output ground to the input will cause any problems - after all you measured zero continuity between them so how could any current flow. Yes, you saw a PD of 25V - did you measure this with your DMM which has a very high input impedance? The PD could be due to very small leakage currents or even switching pulse breakthrough. Does the charger manual say DO NOT COMMON INPUT AND OUTPUT GROUND!?

You don't need RS-232. Just normal logic TTL-level digital signals of RX and TX. Put the signals through optocouplers or a dedicated chip and it is isolated.
RS-232 is something from 30 years ago and has no advantages. RS-485 on the other hand is still used and is still as solid as 30 years ago. So if you need a distance of 50 meters, then a isolated RS-485 is the best choice.

@Paul_KD7HB @Koepel @jhaine

I was getting frustrated at this whole situation and I was in the middle of a somewhat rude response to jhaine when I decided to check myself. Glad I did because I reviewed the manual again for the DC-DC charger and I was wrong. I don't recall if at some point I specifically read in the manual not to connect the grounds together, if I was looking at the wrong manual, if I read that on a different charger I was considering, or if I just made an assumption, but the manual specifically states that the grounds SHOULD be connected together (but not required). That solves the isolation problem.

I must thank all 3 of you for your concern about not connecting the grounds together! The three of you forced me to reconsider my understanding and fix my misunderstanding. My apologies.

Now, I forgot that I have a spare ATmega2560 board that I have never used. I think I will port my current code over to that and use the Nano on the INA3221 to convert the I2C over to serial. I'll use a shielded cable to run between the two boards.

Anything else I am missing or does my plan sound tangible now that I don't have to deal with isolation?

1 Like

Can you draw a picture ? Write the lengths of the cables, draw the ground and power lines as well.

Yeah, give me a bit to mock something up!

Here is the rough layout of things. After thinking about it a bit, I moved around where the shunts and hall effect sensors would go. Also moved the MAX7219 over to the Nano (board B) since I can run a shorter cable for the SPI connection to the display module than if I ran it off of the Mega (board A).

On the shunt channels, channel C would be the longest at about 3ft (1m). The other two would be within 1ft (30cm).

On the hall effect sensors, the wires should be 1.5ft (50cm) or shorter. They will be getting +5v and ground from board B.

It is hard to tell if there will be high ground currents through the wrong ground wires or if there is a ground loop.

Do you use a ADS115 for hall current sensors ? If the datasheet says that hall sensors are 1% accurate, then you may assume that they are 20% (in)accurate in real life.
The Mega and Nano have no problem reading a analog value when you use a internal voltage reference.

Yes, the original plan was to have the ADS1115 on the hall effect sensors to digitize the readings and send them back to the Nano over a distance. Now that there isn't a need for that, I could just use the analog pins to measure the voltage instead. I'm already building a voltage divider to measure the primary battery voltage so removing the ADS1115 would simplify things.

I managed to fry my Mega's Serial2 lines. I belive the Nano lost its power somehow and shorted the serial lines. The Mega still works, but it constantly pulls around 200mA, gets really hot, and the Serial2 lines don't work at all. I have since replaced it and put 390Ω resistors in series with the TX and RX pins on the Mega side of things. Hopefully that is enough to limit the current and keep both MCUs safe in the event that either of them lose power suddenly while the other is still on.

Turns out that the hall effect current sensors don't operate quite like how I thought they did. After looking at the sparse datasheet again, the sensors only output 2.5V +/- 0.625v meaning it only operates from 1.875v to 3.125v nominally, not the 0v to 5v I had initially thought. That meant that with the 10-bit ADC of the Nano, my current resolution was somewhere around 600mA on the 100A sensor. While that is probably good enough, I wanted more resolution.

I went back and added in the ADS1115. With some small changes to the code and using the gain option of "GAIN_ONE", I have been able to get the resolution down to 17mA on the 100A sensor and 34mA on the 200A sensor. But the fact that each sensor has its own gain setting and zero point adjustment meant that the output voltage range was not following 2.5v +/- 0.625. I had to use my amp clamp meter to measure the same wire as the sensors, find the raw values at 0A and at ~14A, then extrapolate to see what the raw values should be at -100A/-200A and +100A/+200A. It seems fairly accurate, usually within 0.2A of my meter with some sway to as much as 0.5A. We'll see how accurate the readings are when I get it out of my testing environment and start measuring 50A+.

Also, I removed the need for the display module so the Nano isn't using SPI for anything at the moment. Saves a good bit of dynamic memory space, not that I was running out before.

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