I am reading voltage through an analog to digital converter on my raspberry pi. My end goal is to get the electrical conductivity of drinking water. Once I get that, I can calculate the parts per million of total dissolved solids.
I have two cups, one is drinking water from a bottle, one is tap water from faucet. I have a 3.3V pin connected to a 1,000 Ohm resistor, which then goes to two wires about 0.25" apart.
With pins touching, the voltage reading is: 3.227126v
pins in drinking water: 1.05v~
pins in tap water: 1.915v~
Now readings from actual TDS & EC meter:
drinking water: EC = 34, PPM = 17 @ 53.6 deg f
tap water: EC = 442, PPM = 210 @ 71.6 deg f
The raspberry pi's calculation isn't as precise as the meter because the wires aren't at an exact distance apart, and it is not adjusting for temperature yet.
Can someone help me with the calculation that results in the EC/PPM? Any suggested reading? I've been reading up on ohm's law.
Re: Electrical Resistance Calculation Help
A search with an Internet tool for the terms electrical conductivity of water came up with this as the first 'hit'.
https://www.lenntech.com/applications/u ... tivity.htm
Perhaps more by luck than judgement, it seems to answer your questions...
https://www.lenntech.com/applications/u ... tivity.htm
Perhaps more by luck than judgement, it seems to answer your questions...
Re: Electrical Resistance Calculation Help
vvarrior wrote: ↑Fri Apr 27, 2018 5:11 pmI am reading voltage through an analog to digital converter on my raspberry pi. My end goal is to get the electrical conductivity of drinking water. Once I get that, I can calculate the parts per million of total dissolved solids.
I have two cups, one is drinking water from a bottle, one is tap water from faucet. I have a 3.3V pin connected to a 1,000 Ohm resistor, which then goes to two wires about 0.25" apart.
With pins touching, the voltage reading is: 3.227126v
pins in drinking water: 1.05v~
pins in tap water: 1.915v~
Now readings from actual TDS & EC meter:
drinking water: EC = 34, PPM = 17 @ 53.6 deg f
tap water: EC = 442, PPM = 210 @ 71.6 deg f
The raspberry pi's calculation isn't as precise as the meter because the wires aren't at an exact distance apart, and it is not adjusting for temperature yet.
Can someone help me with the calculation that results in the EC/PPM? Any suggested reading? I've been reading up on ohm's law.
The tests that you are doing, I would think would be carried out in a controlled environment
Using calibrated instruments to standard settings, Wether the Pi would come under this
I don't know, Not don under controlled conditions ,using non calibrated instruments
I dought wether you would get the same results on two identical tests
Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong
Some Times Right Some Times Wrong

 Posts: 15555
 Joined: Fri Mar 09, 2012 7:36 pm
 Location: Vallejo, CA (US)
Re: Electrical Resistance Calculation Help
Your results will also vary by what is dissolved in the water. Also note that commercial resistors are rated for "tolerance", which is to say, how close the actual value is to the marked one. Stock, cheap resistors these day are typically within 5% of rated value (i.e. your 1K resistor is somewhere between 950 Ohms and 1050 Ohms). Be glad for this...back before laser trimming was used, the tolerance on common resistors was 20%.
The basic equation you need is the usual expression of Ohm's Law: v=iR.
v is potential, measured in volts. i is current measured in Amperes. R is resistance measured in Ohms.
If you really want to work in units of conductance, the one you is the "Mho". (And, yes, that is correct. The unit of measure of conductance is Ohm spelled backwards.)
The basic equation you need is the usual expression of Ohm's Law: v=iR.
v is potential, measured in volts. i is current measured in Amperes. R is resistance measured in Ohms.
If you really want to work in units of conductance, the one you is the "Mho". (And, yes, that is correct. The unit of measure of conductance is Ohm spelled backwards.)
Re: Electrical Resistance Calculation Help
To further clarify conductance. It is literally the inverse of resistance. Current divided by voltage.
Quis custodiet ipsos custodes?
Re: Electrical Resistance Calculation Help
how old are you?W. H. Heydt wrote: If you really want to work in units of conductance, the one you is the "Mho". (And, yes, that is correct. The unit of measure of conductance is Ohm spelled backwards.)
see here
also for USAThe mho was officially renamed to the siemens, replacing the old meaning of the "siemens unit", at a conference in 1881.[3]
NIST's Guide for the Use of the International System of Units (SI) refers to the mho as an "unaccepted special name for an SI unit", and indicates that it should be strictly avoided.[4]

 Posts: 15555
 Joined: Fri Mar 09, 2012 7:36 pm
 Location: Vallejo, CA (US)
Re: Electrical Resistance Calculation Help
While this document is a good resource for explaining TDS and EC relationship, I don't read where it details how to arrive at EC using voltage. I will play around with the equation v = iR and post my results.B.Goode wrote: ↑Fri Apr 27, 2018 5:20 pmA search with an Internet tool for the terms electrical conductivity of water came up with this as the first 'hit'.
https://www.lenntech.com/applications/u ... tivity.htm
Perhaps more by luck than judgement, it seems to answer your questions...
Because I already know the V of the equation and the resistor value of 1000, I should be able to arrive at the resistance of the water. I am not looking for exact results, just close.
Re: Electrical Resistance Calculation Help
BoyOhvvarrior wrote: ↑Mon Apr 30, 2018 4:38 pmWhile this document is a good resource for explaining TDS and EC relationship, I don't read where it details how to arrive at EC using voltage. I will play around with the equation v = iR and post my results.B.Goode wrote: ↑Fri Apr 27, 2018 5:20 pmA search with an Internet tool for the terms electrical conductivity of water came up with this as the first 'hit'.
https://www.lenntech.com/applications/u ... tivity.htm
Perhaps more by luck than judgement, it seems to answer your questions...
Because I already know the V of the equation and the resistor value of 1000, I should be able to arrive at the resistance of the water. I am not looking for exact results, just close.
In your tests, you said you are not looking for exact results
If you carried out several tests, and all showed slightly different
results, you will be left with a delemer witch one is correct.
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong
Some Times Right Some Times Wrong
Re: Electrical Resistance Calculation Help
While you are correct, I am going to be using the calculation in an application that doesn't require precise results, only consistent results. I will cross the bridge of accuracy once I have figured out how to get to the result I am looking for. I have some ideas in mind how to get consistent and accurate results, but like I said, I need to calculate end result first.boyoh wrote: ↑Mon Apr 30, 2018 9:56 pmBoyOhvvarrior wrote: ↑Mon Apr 30, 2018 4:38 pmWhile this document is a good resource for explaining TDS and EC relationship, I don't read where it details how to arrive at EC using voltage. I will play around with the equation v = iR and post my results.B.Goode wrote: ↑Fri Apr 27, 2018 5:20 pmA search with an Internet tool for the terms electrical conductivity of water came up with this as the first 'hit'.
https://www.lenntech.com/applications/u ... tivity.htm
Perhaps more by luck than judgement, it seems to answer your questions...
Because I already know the V of the equation and the resistor value of 1000, I should be able to arrive at the resistance of the water. I am not looking for exact results, just close.
In your tests, you said you are not looking for exact results
If you carried out several tests, and all showed slightly different
results, you will be left with a delemer witch one is correct.
 mahjongg
 Forum Moderator
 Posts: 14282
 Joined: Sun Mar 11, 2012 12:19 am
 Location: South Holland, The Netherlands
Re: Electrical Resistance Calculation Help
The conductivity of water can vary on a scale of 1:50000 depending on how much and which impurities the water contains, the less impurities the higher the resistance (the lower the conductivity in Siemens, same thing).
Finding the resistance is just implementing ohms law R=V/I where R=Resistance in Ohm, V = voltage in volt, I = current in Ampere.
place some voltage over electrodes dipped in water, and measure the current flow, and you can calculate the resistance between the electrodes.
If you put electrodes on opposite sides of a cube, (so square electrodes placed the length of a side of the square apart) then you can measure the "cubic resistance" of the water, independent of the actual size of the cube.
Finding the resistance is just implementing ohms law R=V/I where R=Resistance in Ohm, V = voltage in volt, I = current in Ampere.
place some voltage over electrodes dipped in water, and measure the current flow, and you can calculate the resistance between the electrodes.
If you put electrodes on opposite sides of a cube, (so square electrodes placed the length of a side of the square apart) then you can measure the "cubic resistance" of the water, independent of the actual size of the cube.
Re: Electrical Resistance Calculation Help
unless your measurement starts a electrolysis ( 1.25V already overpotential)mahjongg wrote: ↑Tue May 01, 2018 12:14 amFinding the resistance is just implementing ohms law R=V/I where R=Resistance in Ohm, V = voltage in volt, I = current in Ampere.
place some voltage over electrodes dipped in water, and measure the current flow, and you can calculate the resistance between the electrodes.
see also here how to measure (like using AC).
also what electrodes are used? they can be
 eaten away (+ electrode (anode))
 accrete stone ( electrode (cathode))
 add a electro voltage offset like the Ti Mo Mn electrodes (anode) we use for seawater electrolysis ?3V?
there is a reason why this stuff is so expensive
 mahjongg
 Forum Moderator
 Posts: 14282
 Joined: Sun Mar 11, 2012 12:19 am
 Location: South Holland, The Netherlands
Re: Electrical Resistance Calculation Help
@KLL Yes, you should use AC to measure, or risk electrolysis, especially if you measure permanently.
my "use case" was for a 10 second labmeasurement, not for a permanent one.
Also spamming isn't allowed here, so I removed your spam link.
my "use case" was for a 10 second labmeasurement, not for a permanent one.
Also spamming isn't allowed here, so I removed your spam link.
 mahjongg
 Forum Moderator
 Posts: 14282
 Joined: Sun Mar 11, 2012 12:19 am
 Location: South Holland, The Netherlands
Re: Electrical Resistance Calculation Help
It's the discretion of the moderator to decide as to what or what isn't Spam on this forum, as an exact definition is impossible to give, so I won even try to give one.
In this case it was a link (URL:) to a commercial site selling material to measure the resistance of water, you added after your sentence beginning with "there is a reason why this stuff..." that triggered my Spamsensibility.
Re: Electrical Resistance Calculation Help
Do not worry about your difficulties in Mathematics. I can assure you mine are still greater.
Albert Einstein
Albert Einstein
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong
Some Times Right Some Times Wrong
Re: Electrical Resistance Calculation Help
After a lot of reading, I am still left uncertain how to calculate ohms from a voltage reading.mahjongg wrote: ↑Tue May 01, 2018 12:14 amFinding the resistance is just implementing ohms law R=V/I where R=Resistance in Ohm, V = voltage in volt, I = current in Ampere.
place some voltage over electrodes dipped in water, and measure the current flow, and you can calculate the resistance between the electrodes.
Voltage reading is normally 3.323v with <0.1ohm (probes touching). How do I arrive at the ohm reading if that same voltage reading is then measured at 1.88v when probes are submerged? The difference is 1.49v but using an EC meter, the reading is 500 us/cm or 500 milliohms per centimeter.
Is 1.88v the conductivity? Which would mean the resistivity is 1.49v?
i = v / R or i = 1.88/1.49 or 1.262 = 1.88/1.49? mA = 1.262?
Re: Electrical Resistance Calculation Help
From the initial paragraph of the document linked in my first response to your query:After a lot of reading,
...
Is 1.88v the conductivity?
So if you are measuring it in Volts (Potential Difference) it can't be the Conductivity, which is measured in Seimens per meter.Water Conductivity
Definition and description
Conductivity of a substance is defined as 'the ability or power to conduct or transmit heat, electricity, or sound'. Its units are Siemens per meter [S/m]
Re: Electrical Resistance Calculation Help
How precise do you need to be?
In your OP you give results for your experiments with your Pi setup and 'proper' equipment.
You could then use those figures to try to calculate the conversion formula for other readings. However, this is all quite rough and you would need to be aware that there would be a significant error margin in your results. To get better results, you would need to do the same experiments with a wider range of water samples. Given a larger set of data you should be able to work out a rough formula for the conversion.
Mu advice would be to use more samples, take more readings, plot those on a graph. You should, hopefully, be able to see a pattern.
In your OP you give results for your experiments with your Pi setup and 'proper' equipment.
Assuming that these readings were taken using the same water samples for both sets of readings, you can extrapolate that a voltage reading of 1.05v is equal to and EC value of 34, and a voltage reading of 1.915v is equal to an EC value of 442.
You could then use those figures to try to calculate the conversion formula for other readings. However, this is all quite rough and you would need to be aware that there would be a significant error margin in your results. To get better results, you would need to do the same experiments with a wider range of water samples. Given a larger set of data you should be able to work out a rough formula for the conversion.
Mu advice would be to use more samples, take more readings, plot those on a graph. You should, hopefully, be able to see a pattern.
Re: Electrical Resistance Calculation Help
B Goode, I have read the document you've linked no fewer than 5 times. I can't seem to find on the page where it details how to determine Ohms from only a voltage reading.
Originally I was looking for EC/TDS but to find the EC, Ohms is necessary. The only measurement I have available is voltage through an analog to digital converter.
I realize different salts create different ohms while temperatures, container size, and distance from probes have an effect. These are not relevant at the moment, just Ohms. I also realize the proper way to measure EC in water is with AC current, not DC as it will polarize the water. I am using a GPIO pin that is turned on to provide 3.3v for the reading, then shut off with at least 10 seconds in between cycles. I can also reduce the volts to further reduce polarization with resistors.
I am not trying to be extremely precise, just relatively close. Is there a formula to calculate ohms based on what the volts should be (3.323v  zero resistance) and what they actually are (1.915v  submerged in tap water)?
Forris, you mention a conversion formula. Do you know the specifics on what the formula is or do you have a reference to it?
Originally I was looking for EC/TDS but to find the EC, Ohms is necessary. The only measurement I have available is voltage through an analog to digital converter.
I realize different salts create different ohms while temperatures, container size, and distance from probes have an effect. These are not relevant at the moment, just Ohms. I also realize the proper way to measure EC in water is with AC current, not DC as it will polarize the water. I am using a GPIO pin that is turned on to provide 3.3v for the reading, then shut off with at least 10 seconds in between cycles. I can also reduce the volts to further reduce polarization with resistors.
I am not trying to be extremely precise, just relatively close. Is there a formula to calculate ohms based on what the volts should be (3.323v  zero resistance) and what they actually are (1.915v  submerged in tap water)?
Forris, you mention a conversion formula. Do you know the specifics on what the formula is or do you have a reference to it?
Re: Electrical Resistance Calculation Help
Using Ohm's Law, for the drinking water:I have a 3.3V pin connected to a 1,000 Ohm resistor
With pins touching, the voltage reading is: 3.227126v
pins in drinking water: 1.05v~
pins in tap water: 1.915v~
Can someone help me with the calculation that results in the EC/PPM? Any suggested reading? I've been reading up on ohm's law.
The current is I = V/R so working in Volts, kOhms and mA we get current = (3.227  1.050)/1.0 = 2.227 mA
The resistance of the water is R = V/I = 1.050 / 2.227 = 0.471 kOhm
The conductance is 1/R = I/V = 2.12 mSiemens
Short version:
The conductance = (1  Vsupply / Vmeasured) / Rfeed
However, converting conductance to conductivity depends on the geometry of your vessel and probes:
https://en.wikipedia.org/wiki/Electrica ... nductivity
The result probably also depends on the metal your probes are made from too.
Re: Electrical Resistance Calculation Help
The tests that you are doing, I would think would be carried out in a controlled environmentForris wrote: ↑Thu May 03, 2018 7:10 amHow precise do you need to be?
In your OP you give results for your experiments with your Pi setup and 'proper' equipment.
Assuming that these readings were taken using the same water samples for both sets of readings, you can extrapolate that a voltage reading of 1.05v is equal to and EC value of 34, and a voltage reading of 1.915v is equal to an EC value of 442.
You could then use those figures to try to calculate the conversion formula for other readings. However, this is all quite rough and you would need to be aware that there would be a significant error margin in your results. To get better results, you would need to do the same experiments with a wider range of water samples. Given a larger set of data you should be able to work out a rough formula for the conversion.
Mu advice would be to use more samples, take more readings, plot those on a graph. You should, hopefully, be able to see a pattern.
Using calibrated instruments to standard settings, Wether the Pi would come under this
I don't know, Not don under controlled conditions ,using non calibrated instruments
I dought wether you would get the same results on two identical tests
Regards BoyO
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong
Some Times Right Some Times Wrong
Re: Electrical Resistance Calculation Help
The answer!!! That, my friend, is exactly what I was looking for! Thank you very much for your informed reply.CosmoNerd wrote: ↑Thu May 03, 2018 1:59 pmUsing Ohm's Law, for the drinking water:
The current is I = V/R so working in Volts, kOhms and mA we get current = (3.227  1.050)/1.0 = 2.227 mA
The resistance of the water is R = V/I = 1.050 / 2.227 = 0.471 kOhm
The conductance is 1/R = I/V = 2.12 mSiemens
Short version:
The conductance = (1  Vsupply / Vmeasured) / Rfeed
However, converting conductance to conductivity depends on the geometry of your vessel and probes:
https://en.wikipedia.org/wiki/Electrica ... nductivity
The result probably also depends on the metal your probes are made from too.
One question, where did you get the initial Rfeed value (1.0)? Is this the mA supplied by the GPIO BCM pin? I read somewhere the pins shouldn't be supplying more than 50mA but can go up to 250mA depending on the power supply.
BoyO, the environment will be "controlled enough" once I get the calculation correct. I am going to be using these values in a range and calibrating to known water electrical conductivity.
Re: Electrical Resistance Calculation Help
To calculate a resistance value from your voltage reading you use the fact that you have two resistances forming a voltage divider. One is your known 1000 ohms resistor, the other is the unknown resistance of the water. Call that Rw
The 3.3 volts (approximately) is across the two resistors in series. The total resistance of two in series is just the sum. 1000 + Rw. By Ohms Law the current through the two is 3.3/(1000 + Rw).
You measure Vw as the voltage between your probes. That is the voltage across Rw. Using that voltage and the current above, apply Ohms Law to the voltage, current and resistance of the water..
Vw = 3.3/(1000 + Rw) x Rw.
Rearranging gives Vw x (1000 + Rw) = 3.3 x Rw
1000 x Vw + (Vw x Rw) = 3.3 x Rw
1000 x Vw = Rw x (3.3  Vw)
1000 x Vw/(3.3  Vw) = Rw
Quis custodiet ipsos custodes?
Re: Electrical Resistance Calculation Help
CosmoNerd,
Here are some readings with your formula:
Channel 1: 3.293843v  1.554259v, 3.479168mA, 0.446733ohms, 2.238474us, EC = 446.732955, 299.311080 ppm
Channel 1: 3.296314v  1.420825v, 3.750978mA, 0.378788ohms, 2.640000us, EC = 378.787879, 253.787879 ppm
Channel 1: 3.296314v  1.433180v, 3.726268mA, 0.384615ohms, 2.600000us, EC = 384.615385, 257.692308 ppm
and the python code:
Notice I changed the mA in the calc fuction from 1.0 to 0.5 and the EC/TDS came down to much closer to my EC/TDS meter (for both drinking and tap water)
Here are some readings with your formula:
Channel 1: 3.293843v  1.554259v, 3.479168mA, 0.446733ohms, 2.238474us, EC = 446.732955, 299.311080 ppm
Channel 1: 3.296314v  1.420825v, 3.750978mA, 0.378788ohms, 2.640000us, EC = 378.787879, 253.787879 ppm
Channel 1: 3.296314v  1.433180v, 3.726268mA, 0.384615ohms, 2.600000us, EC = 384.615385, 257.692308 ppm
and the python code:
Code: Select all
def calc(v,vd,mA,e=0.67):
if (vvd > 0 and mA > 0): cur = (vvd)/mA
else: cur = 0
if (cur>0 and vd>0): ohms = vd/cur
else: ohms = 0
if (cur>0 and vd>0): us = cur/vd
else: us = 0
ec = ohms*1000
tds = ec*e
return v, vd, cur, ohms, us, ec, tds
v, vd, cur, ohms, us, ec, tds = calc(v=adc.read_voltage(8),vd=adc.read_voltage(1),mA=.5)
print("Channel 1: %02fv  %02fv, %02fmA, %02fohms, %02fus, EC = %02f, %02f ppm" % (v,vd,cur,ohms,us,ec,tds))