Read battery voltages from 2 batteries w/o common ground

If anyone has any suggestions on the particular values of capacitors,

The bigger the capacitor the more the voltage will hold up but the longer you need to charge it up. Start with a 10nF film capacitor.
Note if the voltage is going to be more than 5V the apply the potential divider on the external circuit side of the relay.
No recommendations for the relay there are far too many but you want a 5V coil dual pole change over and break before make contacts.
Any transistor that can handle the coil current is fine.

Hya Peeps,

Thank you for all your input yesterday. It was very enlighting and I´m learning new stuff! Love it.

I have put together a schematic using GM´s idea of a flying capacitor for reading the voltage values without a common ground. I am planning to test this, but I do not have the parts, so just throwing this out there for any comments.

There are some points I want to explain.
1... I did not put the voltage divider on the voltage source, as this will be a continous drain on the batteries.
2... When the relay is not activated I have the capacitor connected to the voltage divider. In my programming I will energise the relay, wait, close relay, and read the voltage. I feel this is better.
3... Sorry Perry I´ve used pin names. I prefer this and its my schematic!!

If anyone has any comments, it will be extremely appreciated, although I´m not looking for someone to give me all the answers... I will test and play around and learn myself!

I´m going to order parts tomorrow, no rush as its easter today!

Maybe it's the lack of actual wires but I don't see any ground connection for the measuring circuit on the Arduino side.

By putting the divider on the capacitor you are making it discharge quickly before the measurement is even made, giving you low readings.

Why have you got a 100μF capacitor across the 12k resistor in the measuring circuit? Is that what GM showed you? What will it do when the relay releases?

Hay Perry,

Duly noted regarding the discharging of the capacitor, I´ll look at moving the voltage divider to the voltage source, but have it disconnected until required. Maybe another set of pins on the relay??

I fixed the errors inthe diagram...

That's better. If you want to keep the divider where it is, and I understand why you do, then use a bigger capacitor. You have to consider how quickly 112k Ohms will discharge the capacitor. With a big enough capacitor the time will be less important. Someone on here will tell you how big it needs to be. If I've remembered my college maths correctly the time constant for what you have is 0.112 seconds, the problem is I can't remember the significance of that! :confused: Someone here will most likely (re)educate both of us.

Probably try a 10μF and see how well it works.

Perry, your a gentleman, thank you.

As for the resistors. I cant see how I can reduce them as I have a potentual of reducing 28v to 3.3. I´ll definitally look for a larger capacitor.

The instantaneous current across the cap will be extremely high. Normally the cap is charged through a resistor resulting in an RC time constant (R * C). Within 1 RC time constant the cap charges to about 63% of the voltage, it takes 5 RC time constants to get the cap to about 99% of the applied voltage.

As drawn you share common ground for both the 12 and 24 volt batteries. I thought each was to be separate?

Ron

Hi Ron,
I have realised I need a resistor before the cap to slow the charge rate. My plan is probably for a 10uf cap and a 100ohm resistor before that, maybe more, I’m speculating at the moment. I’ll know more when I test.

Can you suggest anything?

All the GND are to arduino, so the batteries are kept separate.

I think I’m onto a solution now! Thanks.

Ron_Blain:
The instantaneous current across the cap will be extremely high. Normally the cap is charged through a resistor resulting in an RC time constant (R * C). Within 1 RC time constant the cap charges to about 63% of the voltage, it takes 5 RC time constants to get the cap to about 99% of the applied voltage.
Ron

Thanks for the reminder of what I learnt in college Ron! I should have known that, I did know it once :confused:

2... When the relay is not activated I have the capacitor connected to the voltage divider. In my programming I will energise the relay, wait, close relay, and read the voltage. I feel this is better.

As others have pointed out putting a potential divider on the capacitor is a very poor idea.

A much better thing would be to use another relay to switch up to the battery before you switch the capacitor over if you don't want a continuous drain on the battery.

Perry, one of the few things I remembered. College was a long, long time ago. Transistors were pretty cool at the time but we learned vacuum tube theory too. :slight_smile:

grichfitz:
Hi Ron,
I have realised I need a resistor before the cap to slow the charge rate. My plan is probably for a 10uf cap and a 100ohm resistor before that, maybe more, I’m speculating at the moment. I’ll know more when I test.

Can you suggest anything?

All the GND are to arduino, so the batteries are kept separate.

I think I’m onto a solution now! Thanks.

I just do not see this approach as simple. Earlier I suggested using one of these. Been awhile so I dug one out and set it up. Not having a 12 and 24 volt battery I settled for some 9 volt I had laying around for smoke and CO detectors. I used a single 9 volt and a pair in series for 18 volts.

Now if this were a real work project (retired almost 7 years ago) I would have used a precision divider network and included a calibration trim pot(s) but for kitchen table science I just used a few 10K pots and adjusted one as a 3:1 divider and the other as a 6:1 divider. Since I had an LCD I included it. I didn't really use the programmable gain of my A/D so it was full scale and in the default mode, the setting is +/-6.144 volts. On the bright side it is a 16 bit A/D so even at default my resolution is a scale factor of 0.1875 mV per bit. Pretty good. Also I configured it for two channels of differential input. All of this took less than an hour to cobble together.

Here is what I got.

Looking at the LCD.

Here is what the code looks like:

#include <Wire.h>
#include <Adafruit_ADS1015.h>
#include <LiquidCrystal_I2C.h>

Adafruit_ADS1115 ads;  // Declare an instance of the ADS1115
LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 20 chars and 4 line display


int16_t rawADCvalue1;  // The is where we store the value we receive from the ADS1115
int16_t rawADCvalue2;
float scalefactor = 0.1875F; // This is the scale factor for the default +/- 6.144 Volt Range we will use
float volts1 = 0.0; // The result of applying the scale factor to the raw value
float volts2 = 0.0;

void setup(void)
{
  Serial.begin(115000); 
  ads.begin();
   // Initialize LCD screen
  lcd.init();                      // initialize the lcd 
  lcd.init();
  lcd.backlight();
}

void loop(void)
{  
  rawADCvalue1 = ads.readADC_Differential_0_1(); 
  rawADCvalue2 = ads.readADC_Differential_2_3();
  volts1 = (rawADCvalue1 * scalefactor)/1000.0;
  volts2 = (rawADCvalue2 * scalefactor)/1000.0;

  //Serial Print Sata
  Serial.print("Battery 1 =  "); 
  Serial.print((volts1 * 3),3);
  Serial.println (" Volts");
  Serial.print("Battery 2 =  "); 
  Serial.print((volts2 * 6),3);
  Serial.println (" Volts");
  Serial.println();

  // LCD Data
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Battery 1 = ");
  lcd.print(( volts1 * 3),3); // Using 3:1 Voltage Divider so volts1 * 3
  lcd.print(" V");
  lcd.setCursor(0,1);
  lcd.print("Battery 2 = ");
  lcd.print(( volts2 * 6),3);
  lcd.print(" V");
  
  delay(1000);
}

The merit of using a few 10K 10 turn trim pots is you can tweak and peak for accuracy. While I know this can be done in code I like being able to just adjust for a nominal value. The ADS1115 also uses a simple I2C interface so it just connects right to the Arduino. Considering on Amazon the break out board modules cost about $7.00 it's hard to look away.

Granted this is your project but I just don't see using a cap charging and discharging as a good solution. Depending on timing there is also relay transition times. This is a good getting started tutorial on the method I suggest.

Ron

Ron (and wvmarle) your my heros today!

When I read your earlier msg I just didnt research this enough to understand the possibilty. I still had the assumption I required a ground.

So anyway, I had a dig around and happen to have an ADS1115.

A quick setup and bingo! I can now read voltages independent of grounds, using two analog inputs in differential mode.

Why we ended up going down this other route I dont know.

Does anyone have any reason not to use this simple solution??

Thanks again Ron.

Hi,
Can you post your working code and schematic please so we can see your solution?

Thanks.. Tom... :slight_smile:

I can now read voltages independent of grounds

You sure of that?

Hya,

Yup Im sure of it!

So I have only used what I have lying around. I only have one 12v supply, I used a 3v battery for the other test battery. I would use other resistor values in the main project, but again, it is what I have lying around and it gives results.

The voltage for the 12 volts does fluctuate a little, but this could be the power supply.

I added a LCD so I could display the results, this is not on the schematic.

The code is Ron´s, not mine, but adjusted slightly.

If anyone has some input, it will be appreciated, but I think this is the solution.

LCD:

Schematic:

Code:

#include <Wire.h>
#include <Adafruit_ADS1015.h>
#include <LiquidCrystal_I2C.h>

Adafruit_ADS1115 ads;  // Declare an instance of the ADS1115
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 20 chars and 4 line display


int16_t rawADCvalue1;  // The is where we store the value we receive from the ADS1115
int16_t rawADCvalue2;
float scalefactor = 0.1875F; // This is the scale factor for the default +/- 6.144 Volt Range we will use
float volts1 = 0.0; // The result of applying the scale factor to the raw value
float volts2 = 0.0;

void setup(void)
{
  ads.begin();
   // Initialize LCD screen
  lcd.init();                      // initialize the lcd
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);               // Go to column 0, row 0
  lcd.print("Volt Meter");
  lcd.setCursor(0, 1);               // Go to column 0, row 1
  lcd.print("Ready for Input.");
}

void loop(void)
{ 
  rawADCvalue1 = ads.readADC_Differential_0_1();
  rawADCvalue2 = ads.readADC_Differential_2_3();
  volts1 = (rawADCvalue1 * scalefactor)/1000.0;
  volts2 = (rawADCvalue2 * scalefactor)/1000.0;
  
  // LCD Data
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Battery 1 = ");
  lcd.print((volts1),3); //Not using a divider
  lcd.setCursor(0,1);
  lcd.print("Battery 2 = ");
  lcd.print(( volts2 * 5.7),3);
 
  delay(1000);
}

Are you saying that the circuit you have posted in reply #35 works? That doesn't seem likely as there is no ground between the ADS1115 and the Uno. I2C needs a common ground like everything else.

Also, ground or no ground this does not meet your requirements of no common ground. Even if the ADS1115 is somehow working without a ground to the Arduino the batteries you are measuring are not isolated from Uno because they are connected via SDA and SCL.

++Karma; // For experimenting and trying to learn stuff and keeping us updated with what you are doing.

Hay Perry,

I was avoiding drawing lines everywhere, the voltage supply and gnd for the Ardunio and ADS1115 are the same...

I only said the batteries do not share a common ground, I didnt say I wanted to isolate them from the uno. with this setup I can place a relay on the batteries before the voltage divider. Thus not having a drain when not reading the voltage.
Close the relay, take the voltage, open the relay. Simple.

Unless you think otherwise??

But thanks, it does work.

But thanks, it does work.

That's what matters. If it does what you want then it's fine.

I still suspect that there is something not quite the way you think it is, but if I am right you will discover it yourself, and if I am wrong then it doesn't matter.

Mmmmm. I hope your suspicion doesn’t arise as this is only a small part of a larger project and I’ve spent enough time on this bit!

Hi,
If you are going to use that circuit and the batteries are connected in series you will exceed this parameter.

Tom... :slight_smile: