Here is what I added to my calculation function.
Code: Select all
def calc(v,vd,mA,e=0.67,r=10000):
if (v-vd > 0 and mA > 0): cur = (v-vd)/mA # current with supplied V and measured V
else: cur = 0 # poss 0's
if (cur>0 and vd>0): ohms = vd/cur # ohms with supplied V and current
else: ohms = 0 # poss 0's
if (cur>0 and vd>0): us = cur/vd # siemens with current and supplied V
else: us = 0 # poss 0's
ec = ohms*1000 # EC (more calcs to come with volume of container
# temperature consideration eventually
tds = ec*e # TDS conversion using e
return v, vd, cur, ohms, us, ec, tds
vd = volts measured through water
e = TDS conversion for water solutioin
r = resistor value
The results don't match though. I've tried using your formula (1000 x Vw/(3.3 - Vw) = Rw) in my code's ohm calculation like so:
Code: Select all
ohms = r * (vd/(v-vd))
# instead of
ohms = vd/cur
ohms = 10,000 * (0.415128 / (3.296314 - 0.415128))
ohms = 10,000 * (0.415128 / 2.881186)
ohms = 10,000 * 0.144082332761578
ohms = 1,440.082332761578
But I don't think the ohms are 1,440~... I am getting an ohm reading of 0.072041 ohms when EC/TDS results get close to matching with the first code above.
The difference in supplied volts is (no ohms, pins touching):
with 10k resistor: 2.055872v
without resistor: 3.313611v