Problem with Ground Loop - Gertduino(Arduino Uno)

Hi everyone

Please note, my knowledge of electronics is basic at best, my forte is programming.

I have a Gertduino (Virtually the same as Arduino Uno). And i have 2 sensors (One for EC and one for PH readings). My problem is that although they are plugged into separate ground slots, they ground to the same pin, and because of this, when I submerge both sensors i get inaccurate inaccurate readings and i assume this is because they are grounding to the same pin and therefore do not have an accurate zero(ground) reference.

Is there a way around this, has anyone come across this problem before? Can i buy an additional shield or something?

Thanks for your help and taking the time to read this

Hi pieperu

Can you post links to datasheets for the sensors?

when I submerge both sensors i get inaccurate inaccurate readings

Do you get accurate readings when only one sensor or the other is connected?

Please post your code, too.

Thanks

Ray

Thanks for your reply Ray

I dont have a datasheet, but these are the sensors i bought, the Model A1005

http://webpages.charter.net/tdsmeter/products.html

And here is a link to the user manual that might help you

http://webpages.charter.net/tdsmeter/manuals/1005m.pdf

Please let me know if this doesnt provide the info you need, and i'll do some more digging

Yes i get accurate readings when one or the other are submerged, for example, when it is just the PH, it reads water at 7.2 (which is correct, when i submerge the EC in the same solution it jumps up to 10.x.

I'll dig out my sketch and send it over

And here is my sketch (also attached)

Please note that the processedPhValue/processedEcValue and the finalPhValue/finalEcValue variables are just used to process the readings in a different way, i just wanted to see what the difference was between methods. Just thought i would mention that in case it throws you off :slight_smile:

/*
1.00 2014-05-22 PP -Created

This sketch is used to read the PH and EC values
from the A1005 transmitter.
*/
//Define and set constants
#define EC_PIN_NUM 0
#define PH_PIN_NUM 1
#define EC_LED 3
#define PH_LED 4

int ecPin = A0; //The analog input pin used by the EC sensor
int phPin = A1; //Thw analog input pin used by the PH sensor

//Variables to store the processed values
float finalPhValue = 0;
float finalEcValue = 0;

//Define variables used in methods here
int rawPhReading = 0, rawEcReading = 0;
int processedEcValue = 0, processedPhValue = 0;

void setup()
{
Serial.begin(9600);
}

void loop()
{
ProcessPH(true);
ProcessEC(true);
Serial.println("---------------------------");
delay(1000);
}

void ProcessPH(bool printToConsole)
{
rawPhReading = analogRead(PH_PIN_NUM);
processedPhValue = map(rawPhReading, 0.00, 1023, 0, 14.00);
finalPhValue = rawPhReading*14.00/1024;
analogWrite(PH_LED, processedPhValue);

if (printToConsole)
{
Serial.print("PH > ");
PrintParamsToConsole(rawPhReading, processedPhValue, finalPhValue);
}
}

void ProcessEC(bool printToConsole)
{
rawEcReading = analogRead(EC_PIN_NUM);
processedEcValue = map(rawEcReading, 0, 1023, 0, 5000.00);
finalEcValue = rawEcReading*5000.00/1024;
//Readible EC
finalEcValue = finalEcValue / 100.00;

analogWrite(EC_LED, processedEcValue);

if (printToConsole)
{
Serial.print("EC > ");
PrintParamsToConsole(rawEcReading, processedEcValue, finalEcValue);
}
}

void PrintParamsToConsole(int rawReading, int processedValue, float finalCalculation)
{
Serial.print("[Raw=");
Serial.print(rawEcReading);
Serial.print("] “);
Serial.print(”[Processed=");
Serial.print(processedEcValue);
Serial.print("] “);
Serial.print(”[Final=");
Serial.print(finalCalculation);
Serial.println("]");
}

PhAndEcReader.ino (1.86 KB)

I read through that manual, and it is quite strange that they insist on an isolated ground, and yet state that it connects to arduino. the Arduino only has a common ground. The only thing I can think of is that you connect the ground of the sensors to two of the Arduino pins (e.g. pin 2, 3) and then set the pinMode to output, and digitalWrite(0) to it on one of them, while the pinMode on the other is set to input, do your reading, and then swop the pin states to read the other sensor.
I.e.
pin 2 connected to gnd of pH
pin 3 connected to gnd of EC
pin A0 connected to pH+
pin A1 connected to EC+
first:
pinMode(2, INPUT), pinMode(3, OUTPUT), digitalWrite(3, LOW), digitalRead(A1)
then:
pinMode(3, INPUT), pinMode(2, OUTPUT), digitalWrite(2, LOW), digitalRead(A0)

Also, the recommend adding a 0.01 uF capacitor across the pH sensor.

Thanks for posting all the information. Afraid I've not seen a sensor before with this requirement for isolated ground.

Found this thread which talks about external hardware to isolate the sensor output from the Arduino supply.

http://forum.arduino.cc/index.php?topic=136059.0

TRex:
The only thing I can think of is that you connect the ground of the sensors to two of the Arduino pins (e.g. pin 2, 3) and then set the pinMode to output, and digitalWrite(0) to it on one of them, while the pinMode on the other is set to input, do your reading, and then swop the pin states to read the other sensor.
I.e.
pin 2 connected to gnd of pH
pin 3 connected to gnd of EC
pin A0 connected to pH+
pin A1 connected to EC+
first:
pinMode(2, INPUT), pinMode(3, OUTPUT), digitalWrite(3, LOW), digitalRead(A1)
then:
pinMode(3, INPUT), pinMode(2, OUTPUT), digitalWrite(2, LOW), digitalRead(A0)

Also, the recommend adding a 0.01 uF capacitor across the pH sensor.

Thanks for this, i’ll try this out when i get home tonight. I already have a 10nf capacitor in place (on a breadboard as i am just prototyping)

Hackscribble: Thanks for posting all the information. Afraid I've not seen a sensor before with this requirement for isolated ground.

Found this thread which talks about external hardware to isolate the sensor output from the Arduino supply.

http://forum.arduino.cc/index.php?topic=136059.0

Thanks for the link, i'll look into this when i get home.

I bought the transmitter and probes already put together so i'm unsure of how it is put together, but i'm debating buying the shields for Ph and EC and making my own. My reservation here is my lack of knowledge of electronics

Hi can you try this.
With both sensors in the water and connected to the transmitter, only connect the PH to the arduino and see if you get a proper reading.
With both sensors in the water and connected to the transmitter, only connect the EC to the arduino and see if you get a proper reading.
In each case disconnect both + and - from the arduino of the un-connected sensor.
Also is the 12V supply for the transmitter connected as per the diagram, that is, it is not also connected to an arduino gnd?

Tom… :slight_smile:
It sounds as If you will need an isolator on one of the transmitter outputs, if you do then its not a “Developer and hobbyist” product.

TomGeorge: Hi can you try this. With both sensors in the water and connected to the transmitter, only connect the PH to the arduino and see if you get a proper reading. With both sensors in the water and connected to the transmitter, only connect the EC to the arduino and see if you get a proper reading. In each case disconnect both + and - from the arduino of the un-connected sensor. Also is the 12V supply for the transmitter connected as per the diagram, that is, it is not also connected to an arduino gnd?

I believe that yes i get accurate readings when i put one in at a time, but i will run through this process tonight and feedback the results.

Assuming that the readings for each are correct, do you have a solution in mind to get around this? :)

Also,

Tom..... :) It sounds as If you will need an isolator on one of the transmitter outputs, if you do then its not a "Developer and hobbyist" product.

This comment lost me a bit haha

The issue is that each sensor puts the solution at a particular potential w.r.t. to its own ground, so you must either

1) isolate the liquid and use only one sensor at a time in the liquid 2) isolate at least one of the sensors and the liquid and then you can use both at once.

Isolating the liquid is easy - just use glass or plastic container. Isolating a sensor requires a separate isolated supply and a way to pass the reading across the isolation barrier, such as opto coupler.

Hey all

Thanks for your replies, unfortunately i didnt get a chance to play around with the sensors last night due to some family commitments (and the world cup) :slight_smile: However will get on it tonight

MarkT, thanks for your reply:

MarkT:
The issue is that each sensor puts the solution at a particular potential w.r.t. to
its own ground, so you must either

  1. isolate the liquid and use only one sensor at a time in the liquid
  2. isolate at least one of the sensors and the liquid and then you can
    use both at once.

Isolating the liquid is easy - just use glass or plastic container. Isolating a sensor
requires a separate isolated supply and a way to pass the reading across
the isolation barrier, such as opto coupler.

Assuming i went with this solution, i would need an additional power supply and an octocoupler? Is that right? Can you go into a little more detail.

I’m more interested in these potential solutions as i’m pretty sure that the problem has been established. All i want to do is get steady readings for both sensor, from a single microprocessor, if this is a viable way to achieve these then i am fully on board for trying it :slight_smile:

Hi pieperu

An "old school" solution, assuming that power consumption is not an issue, would be to use a double pole changeover (double pole / double throw) relay controlled by an Arduino digital pin. Connect the Arduino analog pin and GND to the common poles and each sensor to a pair of the switched poles. That way, only one sensor has [u]any[/u] connection with the Arduino at any time.

Isolation with optocoupler would be more elegant and lower power consumption, so I suggest the relay only as a last resort.

If you use a relay, check out the the connection advice in and linked from this post:

http://forum.arduino.cc/index.php?topic=22448.0

Having read the manual I see its a single sensor with two differential outputs.

I think you need an ADC with 12V supply and two differential input channels. All their talk of "grounds" is confusing, they are just providing differential output signals of 0..5V magnitude AFAICT.

Alternatively use two opamps as different amplifiers of gain 1 to level shift their signals to 0..5V range and feed to analog pins via 10k protection resistors?

MarkT: Having read the manual I see its a single sensor with two differential outputs.

I think you need an ADC with 12V supply and two differential input channels. All their talk of "grounds" is confusing, they are just providing differential output signals of 0..5V magnitude AFAICT.

Alternatively use two opamps as different amplifiers of gain 1 to level shift their signals to 0..5V range and feed to analog pins via 10k protection resistors?

Thanks for the reply, i'll have to do some googling around your reply so i understand it :) But essentially, yes, there are 2 sensors connectored to the Transmitter but i suppose the transmitter acts as 1 sensor with 2 outputs.

Would it be easier to build my own, buy the necessary PCB kits for PH and EC and connect them myself to my Arduino, or will i face the same issue with this ground loop?

I'm not married to the idea of this transmitter, if there is a better solution i'm all ears

Thanks again for the reply, as i said, i'll do some research so i understand your response and i'll respond