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

Interesting!

I didn’t even think of that. . . .

If you can get a 1-1 isolation transformer, you can check that quickly, or - using your idea, take water out of the aquarium to test, you should know quickly if subtle currents are your problem.

Hey! @mountbaldybrewing, I wonder if you were experiencing the same issue?

And yes, in the U.S. we have a saying “buy nice or buy twice”.  Russia says “Are we so rich that we can afford to buy cheap things?”

1 Like

I took a deeper dive into the python code I found here and took the time to take some measurements. Got some pH strips from the pharmacy which only measure between 5.6 and 8 but for a first shot they are OK.
I changed my code so that it takes 20 measurements with 50 msec pause between the readings. The values become more stable but measuring an alkaline solution of household soda (pH according to test strips: > 8) is a complete desaster. If I just look at the raw values the sensor kit reads and don’t hassle with calculating voltages and whatnots I can easily see that the values returned when the probe is in tap water or in a solution of soda are nearly identical. Acidic solutions work better, I will do more testing when I have better pH strips with a wider range next week. These things are somehow hard to come by, stuff that stupid pandemic.
Conclusion: as @jimrh does’t get tired to say: you get what you pay for and this electrode only does half the job if any. It’s time for a beer I think, no make that two …

2 Likes

Reminds me of something I read in a quantitative analysis textbook:

“Phenolphthalein is insensitive to bicarbonate”

I wonder what they made the probe from?

I’m not trying to be a pest. It’s just that, (at my age, at least), I don’t have time for half-baked solutions to problems.

Like your sensor, I have a collection of “cheap” drones that are half-baked versions of the $400 drone I wanted to get the first time.

I’ve spent the $400, but still don’t have a usable drone.

Since mountbaldybrewing already went down that rabbit-hole, I was hoping to spare you the angst.

Of course, in the U.S. we have a figure of speech: “the pot calls the kettle ‘black’.”

I’m still working on my “multi-booting” research, and I have discovered what may be a fatal issue with my current method, so I have to save my “place in the game”, (so to speak), while I explore a different method. :laughing:

Actually, I prefer kvass.

And, as fate would have it, the absolute best Russian kvass is made in Canada!

I had read that as well on the Atlas Scientific website. Their circuit is isolated as well to mitigate these types of issues. Unfortunately, I could not get their device to calibrate either. (The board I have is their OEM board which is different than the one I linked here. The one I linked here IS the board I SHOULD Have bought instead.)

One thing I will say is that the simple “yellow” pH pen made in China works well measuring pH in my hydroponics setup. I just cannot link that directly to a web interface as I am intending.

On a side note… My new probe should get here today or tomorrow. I will post what I find out here than. This probe is, I believe, a better probe than the blue one from the SEEED kit.

Prost!

1 Like

@DocDrum This is the electronically isolated board that Atlas suggests you use for their circuits. This link MAY shed some light on that too.

https://atlas-scientific.com/carrier-boards/electrically-isolated-ezo-carrier-board-gen-2/

1 Like

Viz.:

You get the whole enchilada, including calibration solutions, storage solution, a lab-grade probe, a circuit isolator and so forth for a measly $154.  (Of course, title, tax, and destination charges are always extra!)

A hundred-fifty smackers can buy a LOT of aquarium test-strips!

In your case, assuming you want to do real honest-to-home-brewed-beer process monitoring, that $150 might not mean much.  For an aquarium?  I can think of better things to spend a “buck and a half” on.

But that’s MY opinion - you know; the guy who goes out and drops $80+ every couple of weeks to get more SSD’s for his 'bot to try and multi-boot?  Yea, THAT idiot.  :wink:

:laughing:, but you are right, 150 $ + shipping / taxes is way to much for me, although this kit really seems to do the trick. I found this probe some weeks ago when putting together my shopping list and ruled it out then because of the price. I also stumbled over the yellow chinese pH-pen @mountbaldybrewing mentioned and think this might be plan B for the aquarium. Goal of my project was to learn working with the GPIO and getting the hang of python, and I´d say i’ve hit the spot there.

1 Like

One other caveat. . .

The good doctor lives in Germany as far as I can tell, and I don’t know how difficult it is to get that kind of stuff there.

I totally understand what it’s like.  Being exiled to the darkest reaches of Moscow Russia for a while kinda cramps my style as far as getting stuff is concerned.

News Flash!  Peanut Butter is now “a thing” in Russia - or at least in Moscow - and I actually saw one, count 'em, ONE, bottle of “Genuine Lea & Perrins Worcestershire Sauce” - and I grabbed it!

Of course, availability is relative.

All the fast-food places here sell beer on tap and one of the “impulse purchase” items in the supermarket checkout lines are pre-filled 50 ml glasses of vodka and sample-size bottles of whisky, schnapps, rum or other distilled spirits.  It’s your choice:  Rot your teeth on the candy and gum on the one shelf, or rot your liver on the booze on the shelf above it.

It’s still a cultural shock to see the electronic menu-boards in McDonald’s advertising their current Happy Meal on one side and a “two-fer” for draft beers on the other. :crazy_face: :woozy_face:

Then again, I remember reading an article about school lunches in Paris France, where part of the menu is a glass of wine. . .

Part of what I really like about these discussions, (and this discussion in particular), is the ebb-and-flow of information and ideas.  I’ve learned more about electrochemistry in the last two weeks than I have in the last twenty years - and that’s great!

Being able to discover sources for things like pH probes is interesting.  Now, don’t get me wrong, I don’t have anything against pH probes or measurements, but I would not have thought a thread about using a pH probe would get more hits and more replies than just about every other thread on the entire site combined!  (This thread has 112+ postings as of this point in time. . .)

Obviously there’s an interest in automating process management, and pH seems to be a popular process to manage.

I’m tickled pink that we can even try to help.  I’m learning a lot and I am glad it’s so useful for everyone else too.

Maybe $150 is too much for me and maybe it’s too much for you, but who knows - someone else may stumble upon this thread, see the code and the links and say “WOW!  Where have you BEEN all my life?!!”

I hate to sound like a Micky-Dee’s commercial, but I’m lovin’ it!

Well… I have success! My new probe arrived yesterday and I have it up and going. I agree 100% with both of you. The $150 price tag was why I didn’t go that route. I actually did order their OEM product. It is much tougher to setup and has a much higher learning curve. I couldn’t get it to work with the pi at all AND it would not calibrate properly with the probe I had. That said, it’s the same probe I had problems with. My guess… It was the probe all along. UGH!

For me, my project is actually growing things hydroponically. Mountbaldybrewing was a homebrew supply shop I once ran. I no longer have the business but the name stuck. :smile: My hydroponic operation requires pH to be specific 5.8 - 6.2. I have a device that keeps my pH in check (Tourus Hydro pH Perfect) but I wanted to be able to integrate a pH reading into my interface (it has humidity, temperature, TDS, water temperature, pH, fan condition, heat relay, humidifier relay and pump relay, light relay.). I am using Openhab for my interface. It works very well. I’m using multiple relays from Shelly for my controls with mains power.

I’m happy to say that AnyLeaf pulled through. The owner sent me a new probe free of charge. His kit was $60 US. He is very responsive and helpful. I will order other things from him in the future. He has other sensors that may interest @DocDrum for aquarium usage too.

Next step… Incorporate two peristaltic pumps to dose pH remotely via MQTT. I’m real close to getting this to work. :wink:

Thanks for keeping with it! Hopefully this thread helps others in the future.

3 Likes

Well - quick update from me - I also got it working once I installed the grove hat on the pizero. In the reference solution it’s reading 6.7 ish which is fine.

I wonder if the homelab isolator could be added to this sensor to make this work in the aquarium (I havent tried that part yet but I suspect I might get electrical interference).

Also - Does anyone know how to access the built in temp sensor? I have a 1 wire waterproof sensor on another pi which is pretty easy.

2 Likes

btw I have a perialstatic pump working fine for the last ~3 years - cheap ~£6 off ebay with a relay hat which controls a separate 12v supply. Be interested in how you are switching/powering yours

2 Likes

Congrats on getting your stuff working!

I am using a similar pump. It is 12v as well and was very low cost.

Well, I finally got everything actually hooked up last night and working. I am just using a 4 relay board I picked up off of ebay. This relay actually works fine using the 3.3 volts supplied by the pi GPIO pins. In fact it would not fire the relays using 5 volts (using a converter).

https://www.ebay.com/itm/4-Channel-5V-Relay-Shield-Module-Board-for-Arduino-Raspberry-Pi-ARM-AVR-CN/222518087646

I’m powering mine with an old power supply from a scrapped Linksys router (12 v). I did wire in a capacitor at the VCC and GND on the relay board to prevent any flyback.

So far so good!

For the record, I"m interfacing all of this with Openhab v 3. I haven’t taken the time to make it pretty yet but that’s on the radar to do in the future.

excellent - thats almost exactly the same way I’m controlling my pump including the old router power supply! I did use a more expensive relay controller designed for robotics as thats all that was available when I built it but the options are much more varied now. I calibrated mine by timing power on/off cycles and pushing liquid into a measuring tube. Mine is roughly 1ml/second which makes it nice an easy as I only need 20ml each dose and it doesnt need to be super accurate

1 Like

Gratulations to @mountbaldybrewing and @aemee for geting their stuff to work, thumbs up. Could you both post wich ph-electrode you ended up with? @mountbaldybrewing, do you use the AnyLeaf-Probe and Board now?
@aemee, are you still on the seeed-Probe? Is the 6.7 you measure in the storage KCl-Solution the electrode ships with? I´ve got the same value there but can´t get good values for alkaline solutions. I finally got my universal indicator strips to do some rough calibrating but couldn´t find the time yet. But i fear that my seeed-electrode just won´t work in the alkaline range.
The AnyLeaf-gear looks good, but
a) the pH-probe is out of stock
b) 60$ + shipping and taxes to germany (OK, half the price of Atlas Scientific, but still …)
c) 10-20 days shipping to europe

I’ll have to meditate on this, after all it is just a small aquarium.

Edit: I wonder if it would be wise to buy one of the million different pH-electrodes with a BNC-connector out there and leave the rest of my setup (seeed-interface → groveHat → Pi) in place. After all the electrode just delivers a small current to the interfaceboard and all the calculations and calibrations take place in my script. Or am I missing something there?

Big favor from both of you please:

This thread is rather long and convoluted, and things have become somewhat confused.  Would you two please provide a quick summary of what you did, and what eventually worked, so that the rest of us mere mortals can piece together the issues and how you solved them?

@aemee
Did you try this at other pH values both above and below?  @DocDrum had problems with pH values away from neutral, especially higher pH values.  Simply because the one reference solution reads OK doesn’t mean the range of values is correct.  I would check if I were you.

@jimrh my summary:

Equipment used:

  • Blue seeed probe which comes with grove interface board and cable
  • Pizero (fully updated raspberry pi O/S)
  • Grove base HAT for pizero

Build history:

  • Blue seeed probe arrived, no code available for pi zero despite saying on the site it is compatible.
  • Bought an arduino and used the available seeed code. Results totally innaccurate in the reference solution.
  • Bought a grove base hat, installed it using the following command and have accurate results on the reference solution:
curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s -

Copied and pasted the code below into a python script but needed to add the utf encoding at the top as the file format wasnt compatible when pasted from my browser:

# -*- coding: utf-8 -*-
import math
import sys
import time
from grove.adc import ADC

# CONSTANTS
Vref = 4.95   # volts
Vcal_mv = 646  # milli-volts (using raw value 535 * 4.95/4096 * 1000)
#Vcal_mv = 2588  # milli-volts (using raw value 535 * 4.95/1023 * 1000)  note 10-bit A2D
mv_per_ph = 59.6
ph_per_mv = 1.0 / mv_per_ph


class GrovePH:

    def __init__(self, channel):
        self.channel = channel
        self.adc = ADC()


    @property
    def PH(self):
        value = self.adc.read(self.channel)
        if value != 0:
            voltage_mv = value * Vref / 4096.0 * 1000
            #voltage_mv = value * Vref / 1023.0 * 1000
            PHValue = 7 - ((voltage_mv - Vcal_mv) * ph_per_mv)
            return PHValue
        else:
            return 0



def main():

    #if len(sys.argv) < 2:
    #    print(‘Usage: {} adc_channel’.format(sys.argv[0]))
    #    sys.exit(1)

    #sensor = GrovePH(int(sys.argv[1]))
    sensor = GrovePH(0)

    print('Detecting PH...')

    while True:
        try:
            print('PH Value: {:2.1f}'.format(sensor.PH))
            time.sleep(1)
        except KeyboardInterrupt:
            print("\nExiting...")
            sys.exit(0)

if __name__ == '__main__':
    main()

TODO:

  1. Test in multiple solutions for accuracy
  2. Find out how to code the built in temp sensor (if indeed there is one)
  3. Maybe add a noise isolator if 1) doesnt work when I test it in my tank (no idea how successful this will be)
  4. Integrate the code into a bash script which will:
  • Turn on my CO2 supply at a specified time via a wifi sonoff or similar before so I dont have to integrate with 240v supply or I may get a separate DC power supply and use a relay hat on the PI to control it.
  • Detect the PH, when it reaches ~ph 6, switch off the power on my co2 solenoid.
  • Send all the debug and results via pushover to my phone.
1 Like

For anyone trying to follow this thread and get a pH board working with a Raspberry Pi…

Below describes one solution to get a pH probe working with the Raspberry Pi.

Equipment used:
Raspberry Pi Zero
Anyleaf Board and pH probe

Code:
https://pypi.org/project/anyleaf/

Parting Notes:
The AnyLeaf board has its own set of challenges. First and foremost, the Raspberry Pi 3B is a poor choice for any of the pH probes I have tried. I could not get any of them to work with the 3B and the dev recommended to try a zero or a 4. If you have any issues with values that don’t make sense, get a new probe. Your pH values should not bounce around wildly. The calibration routine built into the example script is a bit cumbersome but it works. If you get any readings that seem off par, recalibrate.

I have noticed that the probe stays in calibration until you add any new peripheral device to the pi via GPIO. I have had my settings persist after reboot but be prepared to calibrate it often. If the probe is in your tank 24 / 7, I don’t think you will need to recalibrate as often. I will find out here in a few weeks how well calibration stays.

I really appreciate everyone in this forum. Thank you for the support!

1 Like

After some more testing my final verdict for the blue seeed pH-electrode: don´t buy it. Not surprisingly, I know. I tested with different solutions of known pH (4, 7, 9) and checked the raw values coming from the board. While there is a clear difference between the values of pH 4 and 7 there is nearly no difference between 7 and 9. So all calibration attempts are useless.
Just out of curiosity I will order a pH-electrode with a BNC-connector for aquaristics and plug it into my setup. I`ll set myself a cost limit of 50 Euro and see what I can get for the money. Will post the findings here, but it might take some time.

1 Like

OK, after all that time the aquapi has finally reached its destination.

I am using a pH-electrode from an aquaristics supply vendor at the moment, the rest of the setup is unchanged. However, I wasn´t able to calibrate the new electrode. I had the same behaviour as with the seeed electrode, at pH 7 the raw value was more or less constant when moving into higher pH-ranges. Maybe it´s a problem with the interface board, I don´t know and leave it at that. So right now the pH-values are more of a qualitative nature, one could see sudden drops in value but the explicit value measured ist more or less a guideline.
Another interesting fact: as soon as the lights go down in the aquarium the pH-value goes up significantly to stay at that higher level until the lights go on again. This fits nicely with something stated way above this post: small currents leaking from the devices in the aquarium into the water can have a huge effect on measurements. I will code some time-based correction factor into my script, as I know exactly when the lights are on or off.
Thats it from me, I learned a lot with this project and really appreciate the friendly discussion and support here.

3 Likes