ADS1115 problems while measuring battery & solar panel voltage

I have the problem that my ads1115 is not measuring properly the voltage of my differential inputs for measuring the voltage of my offgrid LFP batterys (24V) and the voltage of the solar panels (up to 43V).

What is my circuit setup?

  • on the pcb i have two different voltage layers: 5V and 3,3V which are supplied by LM317 circuits on the board. Both LM317 are parallel and powered by the 26-28V of the mppt charger load output

  • for measuring these high voltages i have a voltage dividor for reducing the voltage down to 3,0V.

What i've already done?

  • i calibrated my section of measurements with the integrated potentiometer to 3,0V at the highest voltage of the measurement range. For the battery i have 3,00V at a Voltage of 30V and for the solar voltage i have 3,00V at 50V

  • if i power the pcb and the analog inputs with my laboratory power supplies it seems that everything works fine, but if i wire the pcb voltages are heavily divergenting.*

  • i also tried to connect one of my laboratory power supplies to the pcb while at the inputs the voltages of solar and battery were present

  • i also tried to disconnect all for this problem unnecessary wirings (relay controlling)

  • i replaced testwise the ads1115 break outs

Could this problem caused by a grounding problem? So if i power the pcb through my laboratory power supplies every thing works fine (because they are commonly grounded through the 230V mains?). In the practical use case of the pcb it is powered by the 26-28V of the MPPT charger, then we have divergenting voltages at the analog inputs of the ads (solar voltage and battery) and the voltages at the relay switching contacts which are coming from the battery

Last but not least the code of the ads init and measuring (which is working fine if i power pcb and analog inputs with laboratory power supply)

auto adsInit() -> void
{
  //Wire.setClock(4000000);  // 400kHz I2C clock. Comment this line if having compilation difficulties 

  ads1.setGain(GAIN_ONE);
  ads1.begin();       // default address
  ads1.setDataRate(RATE_ADS1115_860SPS);
  delay(200);
  ads2.setGain(GAIN_ONE);
  ads2.begin(0x4A);  
  ads2.setDataRate(RATE_ADS1115_16SPS);
}

// .... 

auto voltMeasuringAds1115(Adafruit_ADS1115 ads, adsInput input, voltRange vRange) -> float
{
  float fVolt = 0.0;
  float fResult = 0.0;

  // decide which input to use and read voltage
  switch (input)
  {
  case adsInput::ADS_INPUT_0_1:
    fVolt = ads.readADC_Differential_0_1();
    Serial.println("raw Volt:" + String(fVolt));
    break;
  case adsInput::ADS_INPUT_2_3:
    fVolt = ads.readADC_Differential_2_3();
    break;
  default:
    Serial.println("Error: Wrong Input for ADS1115");
    break;
  }

  // decide which range to use
  switch (vRange)
  {
  case voltRange::VOLT_0_30:
    fResult = fmap(fVolt, iAdc2_01Low, iAdc2_01High, iAdc2_01ScaledLow, iAdc2_01ScaledHigh);
    break;
  case voltRange::VOLT_0_50:
    fResult = fmap(fVolt, iAdc2_23Low, iAdc2_01High, iAdc2_23ScaledLow, iAdc2_23ScaledHigh);
    break;
  default:
    Serial.println("Error: Wrong Volt Range for ADS1115");
    break;
  }

  return fResult;
}

The measuring function is called in void loop()

  fBatteryVoltage = voltMeasuringAds1115(ads2, adsInput::ADS_INPUT_0_1, voltRange::VOLT_0_30);
  fSolarVoltage = voltMeasuringAds1115(ads2, adsInput::ADS_INPUT_2_3, voltRange::VOLT_0_50);

full code pls

Hi, @alexandertonn
Welcome to the forum.
This is very confusing, you have two names for the same wire, GND.

Give them a name like , "SYS GND"

Can you explain how your potential dividers work with no GND, or have you given GND some more different labels ?

Please post your entire schematic.

Tom... :grinning: :+1: :coffee: :coffee: :coffee: :australia:
PS. Did you breadboard each section of your project and test it BEFORE making your full circuit PCB?

1 Like

Thank you for welcoming me

This is very confusing, you have two names for the same wire, GND.
Give them a name like , "SYS GND"

Thank you for your detailed answer. You are totally right regarding the GND line of the LM317 power supplies. I thought it would be clever, if i name it differently, but if i think about it now, it makes more confusing than anything else :smile: .I will consider your recommendation.

Can you explain how your potential dividers work with no GND, or have you given GND some more different labels ?

The idea is, that i connect on "PCB: 1" the battery + pole and on "PCB:2" the battery-. The same on the other side with the solar panel. The common grounding should be done by the mppt charger because the pcb is powered by the load output of the mppt charger and plus and minus of the battery are coming from the mppt charger. Only the solar panel have no ground connection to the system (but the results are not changing if i disconnect this line from the pcb)

Link to my Git Repo: The KiCad Sheet with all pages can be found here - KiCad 7 is necessary
(if you don't have KiCad 7 i can post the necessary pages here but i would like to prevent overfloating images :slight_smile: . Note: The Code in the Github repo have not the latest changes, especially for the adc part)

PS. Did you breadboard each section of your project and test it BEFORE making your full circuit PCB?
I tested the LM317 3,3V and 5V at first and after that created the sockets and connections for the modules (ads1115, rtc, relay modules, mkr socket, ili9341). I tested the voltage dividers with laboratory power supplies and the code mentioned above without any problems

My current assumption is, that i have somewhere ripple voltages or a problem with the grounding if i connect the pcb in practice conditions: Today i will try to figure out with my oszilloscope whether i can find anything.

Generally, if you give signals different names the CAD software will assume they are separate signals - so it will assume there is no connection between them.

The whole point of giving signals names is that those with the same name are the same signal, and those wit different names are different signals!

1 Like
#ifndef ADC_H
#define ADC_H

#include <Adafruit_ADS1X15.h>     // https://github.com/adafruit/Adafruit_ADS1X15/blob/master/examples/differential/differential.ino

Adafruit_ADS1115 ads1;  // ADC for PV current
Adafruit_ADS1115 ads2;  // ADC for voltage measuring

enum class adsInput{
    ADS_INPUT_0_1,
    ADS_INPUT_2_3,
    };
enum class voltRange{
    VOLT_0_30,
    VOLT_0_50
};

float fCurrMppt = 0.0;                  // Current to MPPT Charger
float fCurrInverter = 0.0;              // Current to DC/AC Inverter
uint16_t uiInverterSamples = 0;        // Counter for Inverter Samples
uint16_t uiMpptSamples = 0;           // Counter for MPPT Samples

auto adsInit() -> void;
auto sctMeasuringAds1115(Adafruit_ADS1115 ads, adsInput input, uint16_t &uiCurrentSamples ,uint16_t uiTargetSample, float fCurrentValue) -> float;
auto voltMeasuringAds1115(Adafruit_ADS1115 ads, adsInput input, voltRange vRange) -> float;

#endif

You deleted your question, but yes i'm using two different modules. You also can see this while the init

auto adsInit() -> void
{
  //Wire.setClock(4000000);  // 400kHz I2C clock. Comment this line if having compilation difficulties 

  ads1.setGain(GAIN_ONE);
  ads1.begin();       // default address
  ads1.setDataRate(RATE_ADS1115_860SPS);
  delay(200);
  ads2.setGain(GAIN_ONE);
  ads2.begin(0x4A);  
  ads2.setDataRate(RATE_ADS1115_16SPS);
}

// .... 

Yesterday i inserted manually ads1.begin(0x38) in the ads1 object for playing safe that the standard i2c address is used but without success (as expected, because the code is basically working)

do you mean T3 on your schematic?

48?

1 Like

The ads1 object is for measuring the current through HST016L hall sensors but this is currently not used. So the inputs at this moment are not connected with anything. 0x38 is the standard i2c address for ADS1115

then i don't understand your problem. T3(0x48) "is not measuring properly" and is not connected to its inputs, T5(0x4A) with dividers R5-R10 working well. i would say it is not program issue.

Hi,
I think we need to see a complete schematic, batteries, PV panels and all connected, rather than net names.

Net names may be okay for PCB design, but are minefield when trying to do signal flow while troubleshooting. Showing how the hardware is electrically connected is vital to understanding your project.

A good start, but needs refining.
Although you can use the 1115 to do differential measurements their is a voltage limit to how high each measurement can be above the 1115 gnd.

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

+1

All ADS1115 inputs must stay within the GND/Supply limits of the ADS.
Leo..

Hi, @alexandertonn
Can you draw a basic connection diagram, showing how you have the PV panels and the battery connected the 1115.

Please be careful and include gnd of the 1115 and how it is connected to the potential dividers.

Forget the display and controller, just the basic power measurement circuit inputting to the 1115.

Thanks... Tom.. :grinning: :+1: :coffee: :australia:

i had some tests and one differential channel of ads1115 now showing -2913 without any voltage applied. a second channel is still about 0. but both channels seems to be usable because readings are linear in both positive and negative range.

Is this comment in the wrong thread?

You posted it in this thread also

TO has not described what means

so maybe it is similar case.

there is a voltage limit to how high each measurement can be above the 1115 gnd.

Hey Tom, this sounds plausible, I also figured out that i getting a lot of noise induced by the inverter. If I turn it off, the noise at the battery is zero, but I obviously get also noise somewhere from the mppt charger (probably load and/or charge output). If I turn off the inverter, the noise at the inputs of the pcb is not sinking significant

I think that this amount of noise also could influence the measuring, isn't it? I add a few pictures of the measuring with low sampling rate for having an overview of the noise.

Noise at 230V AC Inverter Input

**Noise at Power Supply of PCB (delivered by mppt charger) **
The noise at the measuring inputs looks similar.

The circuit diagram with the connections at the voltage dividers

Hi, @alexandertonn
Thanks for the battery labelling. :+1:
Where is the MPPT unit, it must be connected in there somewhere.

Where does system gnd connect relative to the batteries and the PV panels.

Even though you are using differential voltage measurement, the ADC needs to have a gnd reference to the two power sources.

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

I created a new sheet and took the parts which are necessary for the pcb. Basically, i power the pcb through the load output of the mppt charger.

I'm only wondering why it works with my two laboratory power supplies. Is it because they are common grounded by the earth wire of the 230V mains supply? I also tried to connect the grounds of the different voltages (Minus pole of solar voltage and minus pole of battery pole).

Didn't read the whole thread, but I see a ground symbol on the solar panel negative. Can't do that, because that's disabling (shorting) the MPPT charger and likely connecting the panel directly to the battery. Most, if not all solar chargers, regulate the negative leg of the panel, so the panel must not be grounded. Panel+ is likely internally directly connected to batt+, and panel negative could have up to negative 19volt (43-24), possibly creating a problem for the ADS1115.

Why do you think panel voltage is important. Only panel power is.
If the MPPT charger has a 95% efficiency, then you can calculate panel power from battery voltage and charge current.
Leo..

1 Like