thought I drop in here, because I too have the grove PH Sensor kit and will try to get it to work on a Pi during the next weeks. Some fun facts about me regarding this discussion so far
I actually have a PhD in Chemistry (never worked as a chemist, so don’t ask me anything )
I work as a software developer, but my Python Skills are very basic
I’m brewing my own beer too
Goal of the project: track ph-values in an aquarium
If you DO decide to go the Arduino <==> Raspberry Pi route, just remember that the Arduino, (at least the one’s I have), are 5v logic devices and you need a level-shifter to interface with Raspberry Pi’s 3.3v logic levels.
At risk of “shouting” - YOU WILL FRY YOUR RASPBERRY PI if you connect 5v logic directly to the Raspberry Pi’s inputs.
That being said, there is a lot of work being done in the Pi with a 'duino paradigm. The Arduino is optimized for a lot of low-level hardware stuff, including nifty things like analog/digital interfaces and higher-voltage i2c stuff - I think. I’ve never used i2c on the Arduino.
I’m sure there’s a lot of information about connecting the two together.
Well, the first thing I found some days ago is that I should better order a Grove-Hat for the pi to avoid the problems when trying to connect the sensor directly to the pi. The hat is in the mail right now, along with a pi zero (as a spare part if terrible things happen). Stay tuned
@jimrh thanks its arrived, I got it connected to my arduino and uploaded the code example. Out the box in the fluid it comes in the voltage is reading wrong and the PH is in minus figures (alien vomit lol). I need to look at how the PH and voltage is calculated in their code example.
Thanks for picking up where I left off. I sadly still have not gotten a GOOD working pH sensor. I’ve gone through 3 probes and I’m on my 3rd flavor of controller. I have also purchased 2 flavors of arduinos in hopes to figure this thing out.
Where I have gone and what I have tried (other than SEEED):
Atlas OEM pH Sensor : Would not reliably give me a reading with the arduino and wouldn’t work at all with a rPi 3B. Support has been not very good (because it’s meant for an OEM or DEV with engineering experience which I am NOT.). Spend the money and get one of Atlas’s EZO circuits. They actually provide support for them and they just work.
AnyLeaf pH and ORP sensor: I just recieved this one and have been working to get it to run. I haven’t been able to get their code to compile yet on an Arduino. I switched over to an Arduino because I was using a SEEED hat on a pi 3B to read a TDS and Temp sensor which this was hooked to. Well that SEEED hat is haunting me. I believe it was causing some weird I2C readings on the pi. I don’t know what was going on but I had to unplug the AnyLeaf board because I was nervous that nefarious things were going on. I’m currently working with the Dev from AnyLeaf to figure out why his Arduino code isn’t compiling. I believe the issue is because the libraries for the Arduino were just updated and that there is a bug some place in one of the Arduino drivers. The good news is that the Dev is very responsive and helpful.
Everything else in my project is running very well. My goal with this portion of the project is to read the sensors with the Arduino Uno and have that post to a MQTT server (on the pi). This is totally doable. I’m also adding a pH doser to my project using a couple 12V perasteltic pumps and two relays. It should be a simple addition. We’ll see what happens!
One side note about Arduino… If you didn’t know, they are all coded in C++. It’s certainly not my wheelhouse, but I can fumble my way through it. LOL!
im running it with a direct cable to the arduino uno - no hat in the way. My next plan is to go through the code samples above - the code itself looks fine (not an expert) in terms of the actions it does, the bit which is broken is how the voltage and ph are calculated - might be a dead end but I’ll have a crack at changing some of the values
“Grove” is a connector pinout paradigm that uses a particularly sized connector with a specific pin assignment.
It does NOT say or imply ANYTHING about logic voltage levels.
The GoPiGo uses Grove connectors, but all the logic is still 3.5v logic - not 5v!
You need to make sure that whatever HAT you use provides level-shifting as well as Grove-style connectors.
Asking @mitch.kremm and @cleoqc to step in and help clarify what is the best way to do the level-shifting you need as I’m not the expert on Grove Hats and Dexter/Modular Robotics hardware/software.
Don’t do anything rash until someone else who knows more about this weighs-in and lets us know what’s safe.
This Grove Base Hat for Raspberry Pi Zero - Seeed Wiki is what I got. So far I connected it to a Pi 3b and installed the libraries but didn’t connect anything to the ports on the hat. Says Output Voltage 3.3V on the Package and in the specs on the Website, so I would guess it should be ok. Maybe @mountbaldybrewing could help? How did you connect the pH-Sensor to your pi?
@DocDrum That is the same board I have. As @jimrh explained, Grove is simply a style of connector wired in a certain pinout. The Grove board just makes it simple to plug things in to the pi and provide Digital/Analog/I2C/PWM/UART connections easily. Yes these are all already built into the pi. It just provides an easy way to connect things.
I am successfully using the TDS and temp sensors provided by SEEED. Their pH probe never gave me accurate readings. I believe it was a problem specific to the probe. I have used their probe on multiple manufacturers boards now and have had similar results. I believe my issue stemmed from the fact that the probe was shipped to me in the middle of Winter and likely experienced sub zero temperatures. I also believe the probe dried out (which will cause faulty readings). To exasperate things, the probe also never would “calibrate” properly as the voltage readings were never stable. If I get time, I’ll test my new probe on the arduino and test my therory.
That said, I DID get the AnyLeaf sensor and probe to work this morning on a raspberry pi zero. The developer is currently fixing the code for the arduino for the AnyLeaf sensor. For more information on AnyLeaf sensors, check this link out. AnyLeaf sensors
I believe the code we had posted in this thread was working. I believe my issue with the faulty unstable readings was more of a function of a faulty sensor. Do give this a go. I think you may be able to get things working.
My project is at the tail end of things and I have now spent more time and money on to try and save a buck. I should have purchased either the Atlas or AnyLeaf sensor from the begining. Lesson learned, you get what you pay for.
I do wish you all the best of luck in your efforts. I do still have a “working” version of the code. I can repost it here ifyou would like it.
When I connected things up I just plugged the hat into the GPIO pins on the pi. It has been up and running the sensors I mentioned for the past few months with zero issues.
Thanks a lot, I would be grateful for a repost of the code. I‘ll try to calibrate the probe, but without standardized buffer solutions this will be tricky. First go will be distilled water which should give a pH of 7. I won’t spend that much money on this project, since it’s more of educational use to me. The aquarium I would like to monitor is a simple beginners fish tank, nothing exotic so no lives depend on an accurate pH there.
Well, well, well …
Plugged everything together, took @cyclicalobsessive code from way above here and this is what I get from the buffer solution the electrode ships with:
Not to bad, I would say. Plus: number of fried Raspberry-Pis: zero
Now where was that vinegar to do some testing of acidic solutions …
OK, edit:
Tap Water (don’t have deonized or distilled water here) gives a straight 7.0
Adding a dash of vinegar: pH drops to 5.4
Washing Powder in Water: pH goes up to 7.8
The chemist in me is happy, I will get distilled water after the easter holidays or try to get my hands on some buffer solutions for finer calibration.
Next steps: try to integrate this sensor into reef-pi (https://reef-pi.github.io/) or code something to record the values and show some nice dashboard.
The supply voltage tells you what the logic levels are. In this case you can use it on either a 3.3v system, (like the Pi), or a 5v system (like the Arduino).
So long as the “supply voltage” is the same, you’re golden.
I really do have to take a moment and endorse what @mountbaldybrewing said about “getting what you pay for”. If you’re doing this “just for the Sh*ts and Grins” of it - then please experiment and let us know what happens. However - if you really want to accomplish something and not just be jerking yourself around, you may want to go with a proven “solution” ( Bad pun, given the context.)
I, myself, tend to go “all lobster” stubborn on a project, invest major time and money, only to find out that had I spent a few extra dollars at the inception of the project, it would have taken 30 minutes instead of three months.
Far be it from me to tell you what to do or how to do it, but - since you are at the project inception stage - you may want to take a step back, a few deep breaths, and think carefully about project goals before going down what may be a rabbit hole.
Of course, I’m the pot calling the kettle black here with that one - I do the same thing all the time!
Maybe this has nothing to do with it at all, or maybe it does, but (unfortunately) the Raspberry Pi Foundation isn’t exactly a Gold Medal Winner when it comes to compliance to established spec’s.
Viz.:
The “hardware” i2c interface on the Raspberry Pi has been plagued with The Infamous Raspberry Pi Clock-Stretching Bug as noted above and is why Dexter/Modular Robotics wrote their own software-based i2c libraries.
Is it Raspberry Pi’s fault? Especially since this seems to go back to The Dawn Of Time with no hint of a resolution, this may actually be a Broadcomm hardware issue as opposed to a balls-up by the Raspberry Pi people. Regardless of who’s to blame, it’s something to be aware of when working with i2c on the Pi.
I noticed this after I posted my reply. . . . Sounds like you’ve got a winner!
(side note to @mountbaldybrewing: I never knew that pH probes could “freeze” or “dry out”. Thanks! It appears yours did both - freeze-dried pH probes?)
You are obviously doing much better than he was, his readings were all over Hell and Half of Texas, and that’s BEFORE he connected power! ()
Seriously, it’s nice to have someone to validate his assumptions and conclusions about his probe having issues. Total respect and many thumbs up!
I don’t know where you are, (the interesting lower-and-upper quotes in one of your replies has my curiosity riz, as the mountain 'folks I’m related to used to say. . .), but here in Russia they sell a nearly 80% “vinegar acid” (acetic acid) in the grocery stores that’s used in dilution for making pickles.
Here in germany (hence the lower/upper quotes) we call it Eisessig, but I think I don’t need that stuff. And from my studies of chemistry some 20 years ago I recall that pH-electrodes are at least sensitive to dry out, so maybe @mountbaldybrewing just had bad luck with his sensor.