Grove - PH Sensor Kit (E-201C-Blue) Raspberry pi Zero

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?

1 Like

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?

1 Like

I agree! Iā€™ll give this a go and see.

1 Like

@cyclicalobsessive
Thatā€™s better! Let me try that in my reference solution.

1 Like

@cyclicalobsessive

What would I adjust in the code to calibrate it? The sensor is reading 5.9 in ph 7 solution.

1 Like

I got it!

Changed the vCal_mv to 2666 based on current voltage reading in 7.0 solution. Bingo hit 7.0 :slight_smile:

2 Likes

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.

2 Likes

Now let me try it in water and see if it looks off.

1 Like

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.

2 Likes

That appears to have worked. I owe you a beer! :smiley:

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!!

3 Likes

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.

2 Likes

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!

2 Likes

@cyclicalobsessive

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!!

1 Like

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ā€. :wink:

@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. :smiley:

This happens to be for another project. :smiley:

If you ever make it this direction, Montana, USA, let me know. Iā€™m always up for a beer!

Cheers!

1 Like

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.

1 Like

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

2 Likes

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

2 Likes

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.

1 Like