Isolated circuit for pH module to solve ground loop problem

Hello,

I'm trying to get stable pH readings for my aquarium computer project, but my pH readings goes all over the place.
I'm pretty sure this is because of ground loops, because I have a stable pH when I measure the same water in a cup, or when i have my Arduino powered by a 9V battery.

So now I want to build a isolated circuit with a DC/DC converter chip (Murata NME0505SC) and an 6N137 optocoupler for my pH meter, following this self made schematic:

Because I'm still new to all of this, I'm hoping that someone can tell me if this will/ might work.

  • update: I forgot one gnd line, so I fixed that and uploaded a new version of my schematic -

Optocouplers can be used for analog data but it is not easy. Stick with the attitude that optocouplers are for digital data.

It would have been nice to see what you were trying to deal with. Ground loops are often avoidable by using a single point ground.

I agree with Vaj4088, you are asking for trouble using an opto coupler like that. Based on my own experience I would expect the calibration to drift all over the place with temperature and other factors.

If you can post a schematic of the circuit you are having problems with along with some clear photos it might be obvious what is causing the problem. It is important to be able to see where the grounds are physically connected and routed in order to judge if they might be the problem.

++Karma; for making a serious effort to resolve the problem.

Linear analog opto couplers exist, they use two matched photo diodes - you drive them with an opamp feedback circuit to correct for drift.

I agree with @vaj4088 that is is best to resolve the problem with more basic methods if possible. My first thought is the DC-DC converter could introduce another source of noise into the system. And even if you used the isolated Analog - Analog as MarkT mentioned the DC-DC could still cause issues by injecting noise at the sensor.

  1. If you posted more information about the physical layout of the "system". i.e. where the board gets power, how long the wires are.... it would help.

  2. What issues are you seeing?

  3. The arduino analog inputs require at a minimum and RC filter at the board. Assuming the PH sensor does not generate a fast output signal I would add:

Arduino A0 ---- 100 ohms ----------|------------5k ohms---------twisted wires to your ph sensor
1 µF
to gnd.

All three components should be located right at the arduino board. The specific values are not very important.

The 100 ohms is to protect the arduino input from the voltage at the 1µ if the arduino is suddenly grounded at its power input. (limits current from the 1µ to the processor)

The 1µ (must be ceramic or film type) is to shunt the noise to ground and not allowing it to reach the 100 ohms.

The 5K limits the noise current to the 1µf to aid it in shunting the noise to ground. The 5k can go higher but Atmel suggests this resistor not exceed 10k.

Did you try removing everything else electrical from the aquarium and testing your meter then?

At that point your aquarium should be the same as a cup of water. Then add your pump/heater/lights back in one at a time and see which is affecting your project.

Thanks for the response guys.

I've attached some photo's of my test setup. Hope that'll make some things more clear.

The issue is that when i have my probe in the aquarium, the pH reading goes all over the place - from pH 4 up to 11. When I measure the same water in a cup, I'm getting a steady reading.
Turning off all my other electrical devices doesn't seem to solve it.

JohnRob:
3) The arduino analog inputs require at a minimum and RC filter at the board. Assuming the PH sensor does not generate a fast output signal I would add:

Arduino A0 ---- 100 ohms ----------|------------5k ohms---------twisted wires to your ph sensor
1 µF
to gnd.

All three components should be located right at the arduino board. The specific values are not very important.

The 100 ohms is to protect the arduino input from the voltage at the 1µ if the arduino is suddenly grounded at its power input. (limits current from the 1µ to the processor)

The 1µ (must be ceramic or film type) is to shunt the noise to ground and not allowing it to reach the 100 ohms.

The 5K limits the noise current to the 1µf to aid it in shunting the noise to ground. The 5k can go higher but Atmel suggests this resistor not exceed 10k.

Just to make sure I understand correctly:


Is this what you mean?
And is it a problem if I use a breadboard to connect it all? Or should I twist and solder the leads and wires together?

Thanks.
In your schematic there are 3 wires, 0v, +5 and a signal wire from the PH meter to the Mega. In the photos I can see, I think, 4 wires. Please clarify.

Is the PH meter the thing with the bright green LED? It has another cable to its probe I think, that's not shown on the schematic.

What is the 5k and 100 ohm resistor for? That doesn't make sense like that (Although I don't think it's the cause of the problem).

I don't think you have a ground loop problem. I was rather hoping you did, then I would make suggestions. Based on what I can see I don't know what to suggest. Hopefully someone else will know.

OK, so I didn't read properly :confused:

I can see what the resistors are for now I read the previous post! They are not as John Rob suggested. The capacitor should be at the junction of the 2 resistors, not connected to A0. They should also be located close to the Mega, not close to the PH meter.

(As an aside, what does PH mean? I mean, I know enough chemistry to know what it measures, but what does PH stand for or is short for?)

No you have it wrong. Sorry I should have known ASCII diagrams are not useful.

See attached.

Another Question. If you set the cup of water on top of the aquarium is it still stable.

1 Like

Bet you also have an air pump and and a water circulation pump all run from AC.

Paul

JohnRob:
No you have it wrong. Sorry I should have known ASCII diagrams are not useful.

See attached.

Ok thanks, I will have to get a 1uF capacitor; once I have one I will try this setup and then I'll be back with the results...

JohnRob:
Another Question. If you set the cup of water on top of the aquarium is it still stable.

Not as stable as when I have it away from the aquarium, but stable enough: On top of the aquarium it goes from 7.6 to 7.9 and away from the aquarium it stays between 7.7 an 7.8

PerryBebbington:
Thanks.
In your schematic there are 3 wires, 0v, +5 and a signal wire from the PH meter to the Mega. In the photos I can see, I think, 4 wires. Please clarify.

Is the PH meter the thing with the bright green LED? It has another cable to its probe I think, that's not shown on the schematic.

You're right. I couldn't find the right ph module part for Fritzing, so I used another one.
My module has a second ground pin, supposedly one for the module and another one for the probe.
The thing with the brigt green LED is indeed my pH module, and yes it does have another cable going to the probe. I don't know how to add that to the schematic...

PerryBebbington:
(As an aside, what does PH mean? I mean, I know enough chemistry to know what it measures, but what does PH stand for or is short for?)

I'm not sure, but the p might stand for potential or power, and the H for hydrogen

PerryBebbington:
(As an aside, what does PH mean? I mean, I know enough chemistry to know what it measures, but what does PH stand for or is short for?)

Its pH, not PH. p means power, as in power of ten, which is the same idea as decibels - a logarithmic scale.
H represents the hydrogen ion concentration. In fact its even more obsure than that as its negative powers of
ten, so a concretration of 10^-7 moles/litre of hydrogen ions (protons) is given pH 7 (not -7).

pH 7.0 is pretty close to neutral in water, as water self-dissociates into H+ and OH- ions each at that
concentration (at room temperature).

pH is easy to remember and use than the more complete -log10([H+])

Because protons are very mobile (can go through any material pretty much), they can diffuse through the very thin glass wall in the pH meter probe, which is the principle used to detect/measure the concentration.

[ This overlooks some details, like the fact protons react with water molecules to form H3O+ ions, which are treated as if they are H+. Most of the time protons are bound to some other molecule, acidic protons are very free to jump between molecules, basically an acid can donate protons ]

vaj4088:
Optocouplers can be used for analog data but it is not easy.

SOME optocouplers can be used for analog data; the 6N137 is definitely not one of them. It's designed for fast digital transfer; I'm using it in my own isolated pH module to communicate by 9600 bps Serial (the module has an ATtiny on board that does the ADC conversion, then sends the measured pH, EC and temperature data over Serial).

wvmarle:
SOME optocouplers can be used for analog data; the 6N137 is definitely not one of them. It's designed for fast digital transfer; I'm using it in my own isolated pH module to communicate by 9600 bps Serial (the module has an ATtiny on board that does the ADC conversion, then sends the measured pH, EC and temperature data over Serial).

That sounds very interesting!
Can you tell me more about it, maybe point me in the right direction for making one myself? For instance, what did you use to power your module? Do you have a schematic or photo of your setup?

Using a Murata just like yours for separating power - it's powered off an Arduino (normal 5V supply, doesn't take much).


Not tested this incarnation yet; my previous version had an error unfortunately so not giving you that circuit. I have the PCB of this one mostly built (the SMD parts that is; still have to solder on the connectors, upload the software, and test it out).
Particularly the "enable" part is untested, that is to be able to shut down the device when not in use as it draws some 25-30 mA continuously.

Thinking about your results with the cup on the aquarium. Its likely the pickup is 60Hz from the mains.

Can you tell us more about the PH probe? Where does it get is power and what type of output is provided?

This is the probe and module I'm using:

The probe gets its power from the module, and the module gets it from the arduino...

MarkT:
Its pH, not PH. p means power, as in power of ten, which is the same idea as decibels - a logarithmic scale.
H represents the hydrogen ion concentration. In fact its even more obscure than that as its negative powers of
ten, so a concentration of 10^-7 moles/litre of hydrogen ions (protons) is given pH 7 (not -7).

pH 7.0 is pretty close to neutral in water, as water self-dissociates into H+ and OH- ions each at that
concentration (at room temperature).

pH is easy to remember and use than the more complete -log10([H+])

Because protons are very mobile (can go through any material pretty much), they can diffuse through the very thin glass wall in the pH meter probe, which is the principle used to detect/measure the concentration.

[ This overlooks some details, like the fact protons react with water molecules to form H3O+ ions, which are treated as if they are H+. Most of the time protons are bound to some other molecule, acidic protons are very free to jump between molecules, basically an acid can donate protons ]

Thank you Mark, good explanation but leaves me with a question... First, My knowledge of chemistry is an O Level in 1977 followed by a general interest in science ever since, but it is electronics I really understand.

If pH measures hydrogen ion concentration then that does not explain how from 7 to 14 is alkali, nor how a pH meter measuring hydrogen ions migrating through glass can measure OH- ions. I realise I am risking going completely off the original topic into chemistry not electronics...

Thanks

pH does not measure OH- ions, it measures H+ ions, which in fact are present in an alkaline solution as well: water all the time spontaneously breaks apart in H+ and OH-, which then very quickly also reconnect to form H2O again. The presence of OH- ions makes that the chance an H+ ion finds a partner increases, thus reducing the concentration of H+ ions in the solution.

Also note that pH only really makes sense for watery solutions. The pH of highly concentrated acids is higher than you may expect just looking at the concentration itself as the acid is not fully dissociated. E.g. in highly concentrated sulphuric acid not all molecules break apart to 2 H+ and 1 SO42-, you will find lots of HSO4- ions as well. Same on the other end of the scale of course.

While we usually talk about H+ ions, that's also technically not correct as these protons are pretty much all bound to another water molecule, forming H3O+ ions. And that, considering the highly complex chemistry of water thanks to it forming those strong H-bridges between the molecules when in liquid or solid state, is also just a simplification...