One thing we could try adding is a variable to collect the voltage reading it is making. Than collect that voltage with a nuetral solution. Use that voltage in plce of 372 in the code. Than test that?
I really wish a GrovePi person would chime in - the chip on the GrovePi Zero is atmel328p which seems to have only a 10 bit A2D so the divisor should be 1023 not 4096. So that makes Vcal_mv more like 2588 (using raw value 535 * 4.95 / 1023 * 1000) which is close to the 2500 I was guessing.
So change:
Vcal_mv = 2588 # milli-volts (using raw value 535 * 4.95/1023 * 1000) note 10-bit A2D
and
voltage_mv = value * Vref / 1023.0 * 1000
and lets see what happens?
I agree! Iāll give this a go and see.
What would I adjust in the code to calibrate it? The sensor is reading 5.9 in ph 7 solution.
I got it!
Changed the vCal_mv to 2666 based on current voltage reading in 7.0 solution. Bingo hit 7.0
add a print for the reading so we know what the reading is in the ph7 solution - Iām guessing it will be about 604 which would make the Vcal_mv = 2922 I think.
Now let me try it in water and see if it looks off.
By the way, some of the sample code examples collect a number of readings and average the readings before plugging into the PH formula. I donāt know what the variance is, but taking the average of 10 readings will reduce the variance by the square root of the number of readings or to about 1/3 of the variance.
If one reading to the next varies a bunch like 1ph , taking 10 readings might reduce the variance to 0.3 ph.
That appears to have worked. I owe you a beer!
The only thing that would be handy would be to take 20 readings and pull an average of them. But I can probalby figure that one out. Iām not a python genius I just fumble my way through.
I saw that as well. Ha! I appreciate all of your help. It would have taken me much longer. Thank you!!
Same here - python is very powerful but the syntax is not intuitive to me - lists, tuples, dictionaries, multi-dimensional arrays - I really have to brute force it most of the time and hide from the Python Gurus.
I have a good friend who codes python for a living⦠His a database admin for a huge project. Iām going to have him help with the averaging bit. Weāll get this thing dialed in good. I canāt thank you enough!! Iām happy I really happy I found this group.
Next up is integrating this into a control panel via OpenHab. Should be a fun project. That part I can handle. Ha!
I hope you had a good holiday! I finally got to working back on this project again and I wanted to give you an update. This is very odd. I can calibrate the pH probe to pH 7 and get good readings but as soon as I read a solution lower (pH 4) or higher (pH 6), everything goes out of whack. I am getting readings, just nothing that makes any since.
Do you have any ideas perhaps?
Thanks!!
Are you doing single-point averaging?
Or have you tried to calibrate over a range of values, such as pH 3, pH 7, pH 12, to try to get it as linear as possible?
I think weāre all beginning to understand why professional-grade pH monitors cost like oil rights. . . It seems easy enough until your wheels leave the ground!
P.S.
Feel free to toss some of your Mount Baldy Brew this way if youāre ever in Moscow Russia! (grinning!)
P.P.S.
This makes me wonder if the pH monitor isnāt going to end up being a part of the āMount Baldy Brewingā experience?
Now all you need is a particularly interesting brew called āNight on Bald Mountainā.
@jimrh I completely understand! Iām interested to see where this goes.
I have tried averaging my readings but it doesnāt help much. I may try to do more averaging and see but either way itās way off outside of pH 7.
I still brew some. I owned and operated a small homebrewing supply shop for a few years. I also did brew on premise work. So lots of brewing. I brewed many times per week. I havenāt brewed that much in years. I still make plenty of distillates.
This happens to be for another project.
If you ever make it this direction, Montana, USA, let me know. Iām always up for a beer!
Cheers!
Holy Christmas! Ā We gotta be something like 12 time-zones apart. Ā Me, Iām stuck here in Moscow Russia, courtesy of the Coronavirus, and youāre in Montana? Ā Thatās Mountain time, right?
That puts me at GMT +3 and you at GMT -7 - a ten hour difference!
My favorite brew is āKvassā - what you get when you put genuine Russian black bred in a barrel and let it brew for a while. Not terribly alcoholic, but delicious as all get-out. Ā All-Star bakery in Toronto Canada makes an absolutely KILLER kvass from preservative free black bread they have to take back when it goes out of date. Ā Better than a lot of the so-called ākvassā they sell in Russia now - what I call āCoca-Cola Kvassā - all chemicals and no āmeatā. Ā Like the difference between commercial so-called ābeerā and the REAL beer you make yourself. Ā Not even in the same solar-system.
Hope you donāt need a Ph.D in chemistry to get this working. The brute force way is to
-
titer about a minimum of 5 reference solutions
-
collect a 10 to 30 raw reading value average and standard deviation at each reference
-
Use a polyfit calculator to find the best fit polynomial degree and coefficients (there is a great one that allows a limited number of data points and poly fit attempts on the web, Iāll look it up if you decide to use this brute force method.)
-
Process the standard deviation from step 2 through the polynomial equation to estimate your precision
_ repeat the process at a few temperatures to see if the is a significant temperature influence
. . . go out and spend the bux on a professional pH meter.
pH readings over a reasonable range - 1 to 13 or 14, should be linear since the absolute value of the hydrogen-ion concentration is linear - no, itās the logarithm of the hydrogen-ion concentration so it will be a logarithmic variation.
. . . . actually, it depends on the sensor - does the sensor translate the absolute value of the log of the hydrogen-ion concentration into a linear representation?
Oh fuzz this!
Just go out and get some pH test strips and check against the color chart!
Just kidding! Ā Though you wouldnāt think youād need a Ph.D. (or is that a āpHā D) in chemistry to do all of this, now wouldnāt you?
In whose lab?
With whose burettes and standard solutions?
Titrating all those standards, at standard temp & pressure, isnāt a simple task.
Maintaining the concentration of the standards for any reasonable period of time sufficient to make enough measurements, without calculating the appropriate buffers, isnāt a trivial task either. Ā There are entire labs in college level quantitative analysis courses that study the deterioration of standard solutions over time and how to calculate the amount of the appropriate buffers to hold them stable.
IMHO, if we need to borrow someoneās college chem-lab somewhere with all the equipment and chemicals just to calibrate a simple pH sensor, then weāre all doing something terribly wrong here.
Either this particular sensor is a total balls-up or weāre missing some fundamental aspect of this kind of measurement outright.
We shouldnāt have to re-design the internal combustion engine just to start the car and go buy a half-gallon of milk.
Thanks for the responses!
@jimrh I apprecaite the banter. I agree that this shouldnāt be rocket science. I could spend another $150 USD on an atlas scientific module that I know works but Iām cheap and enjoy learning about the processes. I stated with a sensor that had no code. Iām getting readings but we have not deciefered the formula yet.
@cyclicalobsessive I discovered that the voltage written on the board for the port that this device is connected to is 3.3v. I did change the value in the formula and I have gotten many readings that are closer. I believe the real issue here is creating an array to store a statistically significant amount of readings and collecting the average of those values.
I do not personally have a degree in chemistry. My close friend retired from 20 years working in a chem lab. I also work at a school where their are far smarter folks in chem. I know i could do all of those steps but it would likely utlimately cost me more in the long run than buying an out of the box solution.
The goal here is to be able to monitor pH of a hydroponic solution. It should be within a range of 5.6 - 6.2. Monitoring the pH to see if itās out of that reference is my end goal. I am also collecting TDS, Temp and Humidity values as well. For the most part all of these numbers should be realitviely constant unless their is issue.
Thank you again for the input! I am currently working on creating an array to collect data and see if averagingthe data can create any significant difference in the data set.