## Electrical Resistance Calculation Help

vvarrior
Posts: 89
Joined: Fri Jan 02, 2015 3:03 am

### Electrical Resistance Calculation Help

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.

B.Goode
Posts: 10401
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

### 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...

boyoh
Posts: 1483
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

### Re: Electrical Resistance Calculation Help

vvarrior wrote:
Fri Apr 27, 2018 5:11 pm
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.

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

W. H. Heydt
Posts: 12951
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.)

drgeoff
Posts: 10922
Joined: Wed Jan 25, 2012 6:39 pm

### Re: Electrical Resistance Calculation Help

To further clarify conductance. It is literally the inverse of resistance. Current divided by voltage.
Quis custodiet ipsos custodes?

KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

### Re: Electrical Resistance Calculation Help

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.)
how old are you?
see here
The mho was officially renamed to the siemens, replacing the old meaning of the "siemens unit", at a conference in 1881.

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.
also for USA

W. H. Heydt
Posts: 12951
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

### Re: Electrical Resistance Calculation Help

KLL wrote:
Sat Apr 28, 2018 10:46 am
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.)
how old are you?
Old enough to have seen it in use.

vvarrior
Posts: 89
Joined: Fri Jan 02, 2015 3:03 am

### Re: Electrical Resistance Calculation Help

B.Goode wrote:
Fri Apr 27, 2018 5:20 pm
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...
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.

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.

boyoh
Posts: 1483
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

### Re: Electrical Resistance Calculation Help

vvarrior wrote:
Mon Apr 30, 2018 4:38 pm
B.Goode wrote:
Fri Apr 27, 2018 5:20 pm
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...
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.

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.
BoyOh
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

vvarrior
Posts: 89
Joined: Fri Jan 02, 2015 3:03 am

### Re: Electrical Resistance Calculation Help

boyoh wrote:
Mon Apr 30, 2018 9:56 pm
vvarrior wrote:
Mon Apr 30, 2018 4:38 pm
B.Goode wrote:
Fri Apr 27, 2018 5:20 pm
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...
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.

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.
BoyOh
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.
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.

mahjongg
Forum Moderator Posts: 13210
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.

KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

### Re: Electrical Resistance Calculation Help

mahjongg wrote:
Tue May 01, 2018 12:14 am
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.
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?
then there is nothing linear, a power DC system in seawater acts like a battery being loaded ( need a day to settle (and can also give power back! ))

there is a reason why this stuff is so expensive

mahjongg
Forum Moderator Posts: 13210
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 lab-measurement, not for a permanent one.

KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

### Re: Electrical Resistance Calculation Help

mahjongg wrote:
Tue May 01, 2018 11:45 am

mahjongg
Forum Moderator Posts: 13210
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

### Re: Electrical Resistance Calculation Help

KLL wrote:
Tue May 01, 2018 12:27 pm
mahjongg wrote:
Tue May 01, 2018 11:45 am
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 Spam-sensibility.

boyoh
Posts: 1483
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

### Re: Electrical Resistance Calculation Help

Do not worry about your difficulties in Mathematics. I can assure you mine are still greater.

Albert Einstein
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

vvarrior
Posts: 89
Joined: Fri Jan 02, 2015 3:03 am

### Re: Electrical Resistance Calculation Help

mahjongg wrote:
Tue May 01, 2018 12:14 am
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.
After a lot of reading, I am still left uncertain how to calculate ohms from a voltage reading.
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?

B.Goode
Posts: 10401
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

### Re: Electrical Resistance Calculation Help

...
Is 1.88v the conductivity?
From the initial paragraph of the document linked in my first response to your query:
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]
So if you are measuring it in Volts (Potential Difference) it can't be the Conductivity, which is measured in Seimens per meter.

Forris
Raspberry Pi Certified Educator Posts: 319
Joined: Fri Jan 06, 2012 7:46 pm

### Re: Electrical Resistance Calculation Help

How precise do you need to be?

vvarrior wrote:
Fri Apr 27, 2018 5:11 pm
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
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.

vvarrior
Posts: 89
Joined: Fri Jan 02, 2015 3:03 am

### 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?

CosmoNerd
Posts: 3
Joined: Thu May 03, 2018 12:09 pm

### Re: Electrical Resistance Calculation Help

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.
Using 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.

boyoh
Posts: 1483
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

### Re: Electrical Resistance Calculation Help

Forris wrote:
Thu May 03, 2018 7:10 am
How precise do you need to be?

vvarrior wrote:
Fri Apr 27, 2018 5:11 pm
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
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.
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 BoyO
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

vvarrior
Posts: 89
Joined: Fri Jan 02, 2015 3:03 am

### Re: Electrical Resistance Calculation Help

CosmoNerd wrote:
Thu May 03, 2018 1:59 pm
Using 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.
The answer!!! That, my friend, is exactly what I was looking for! Thank you very much for your informed reply.

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.

drgeoff
Posts: 10922
Joined: Wed Jan 25, 2012 6:39 pm

### Re: Electrical Resistance Calculation Help

vvarrior wrote:
Thu May 03, 2018 12:40 am
After a lot of reading, I am still left uncertain how to calculate ohms from a voltage reading.
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?

vvarrior
Posts: 89
Joined: Fri Jan 02, 2015 3:03 am

### Re: Electrical Resistance Calculation Help

CosmoNerd,
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 (v-vd > 0 and mA > 0): cur = (v-vd)/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