Tags

Spoiler alert…wait for it…the pH circuit works!  Talk about exciting.  I truly enjoy learning all the skills and different disciplines that goes into building a working pH sensor…math, science, electronics, designing, laying out, and building a PCB, writing the software,..and most importantly – the people I learn from along the way.

Here it is – a thing of beauty – a fully populated Ladybug Shield Alpha V2 hooked into an Arduino:

I got to use my Zallus controlled reflow oven.  I really like the Zallus (toaster) oven controller.  Heck, I really like the idea of popping a PCB in a toaster oven after carefully placing soldering past and SMT parts.  It is so Easy Bake Oven…I can’t help but smile.

# The Goal

The goal of this post is to compare the results of pH circuit tests of the Ladybug Shield with those from an Atlas-Scientific EZO pH stamp.

# Thanks to Those That Went Before

Thanks to Chris Gammell and his Contextual Electronics courses I was able to get to this point where I have pretty much finished the firmware and hardware design for the pH portion of the Ladybug shield.

Thanks to Ryan @SparkysWidgets for embracing/helping us followers of his minipH open source product and project.  I find it amazing to learn so much from all that he has shared.  My hope is this effort is a positive contribution to the minipH effort.

# Open Source

I will be discussing the contents of the Arduino sketches available at this GitHub location.

# Calibrate

pH probes lose their vitality over time and eventually need to be replaced.  In the mean time, the slope of the line mapping pH mV to pH value needs to be calibrated.

I use 2 points to determine the slope of the pH mV/pH value line.  The two points come from reading the pH when the probe is in pH 4 and pH 7 calibrated solutions.  The step between pH values for an ideal probe is 59.16mV.

The calibration sketch I used is located at this GitHub location.

When the probe was in pH 4 calibration solution, the reading was 155mV averaged over 11,551 samples with a standard deviation of .49.  When the probe was in pH 7, the reading was -29mV averaged over 3,859 samples with a standard deviation of .40.

I felt the variability between readings to be smaller than expected.  I don’t have a sound reasoning other than I expected more noise between samples. Maybe < 1standard deviation is what is expected.  The results were expected.

The pH slope = y/x = (155 – -29)/(7-4) = 61.33.

Now when pH values are calculated, a step value of 61.33mV will be used instead of 59.16mV.

See the calcpH() function in the Arduino sketch.

(note: I evolved this part from Ryan – SparkysWidgets – minipH.ino.  Thanks Ryan!).   Converting the mV value from the ADC into a pH value involves two steps:

• compensate for the offset of the pH 7 mV reading of the probe from the ideal of 0 mV
• figure out how many steps away the mV reading is from pH 7.
Since figuring out how many steps away the mV value is from pH 7 assumes the ideal pH 7 = 0mV, start with adjusting the mV value to compensate for the pH 7 mV value.  From calibration, the mV value for pH 7 for the probe I used was -29mV.

When I put the probe into pH 4 calibration solution – this time to read the pH and not calibrate – the mV reading from the ADC was 153mV.  Given the offset, the mV value when pH 7 mV = 0 is 153 – -29 = 153 + 29 = 182.  Calibration provided the probe’s step value at 61.33mV.  The pH value of a 153mV reading given this probe = 7 – 182/61.33 = 4.03.  Wow!  That’s a darn good measurement.

## Compare with Atlas-Scientific EZO pH Stamp

I had an older Atlas-Scientific pH Stamp so I purchased the EZO pH Stamp.  I have to say I am very impressed with it.  With the older pH stamp I had to send a command several times to make sure it pH Stamp reacted.  This was not a challenge with the EZO ph Stamp.  Unpacking the EZO and first use is a pleasurable experience that requires no additional electronic knowledge.  In short, if you want a “high” quality pH sensor that works with an Arduino, the EZO is worth a look.

I compared the readings from the EZO pH Stamp with the Ladybug Shield for two solutions:

• White distilled vinegar
• Baking soda added to filtered water
 EZO Ladybug % difference Vinegar 2.56 2.67 4.21 Baking Soda 7.94 7.85 1.14

The difference in readings is acceptable.

# What’s Next

Work on the pH measurement circuit and firmware is almost done.  I have learned a lot as I traveled this journey.  From the science and math behind a pH measurement to the electronics used to detect a voltage that can then be interpreted in a pH value.  I got a lot of help from folks like Chris Gammell and Ryan @SparkysWidgets.

I haven’t added temperature adjustment.  I’ll do this in an upcoming post.