Measuring pH with the BS2 and Arduino pH Circuit
CJC504
Posts: 11
in BASIC Stamp
Hi,
I am trying to find an inexpensive way to measure and monitor the pH of a nutrient solution. I tried one method a couple of years ago with the probe linked below and some other components, but I was unsuccessful. Recently browsing amazon, I came across the pH circuit linked below. Can someone please let me know if this circuit is compatible with the BS2. I own several BS2 controllers, but I do not have Arduino controllers, nor am I familiar with Arduino's coding so I would prefer to stick with the BS2 if possible.
pH Probe
amazon.com/American-Marine-PINPOINT-pH-Probe/dp/B001EHJO64/ref=pd_bxgy_147_img_2?ie=UTF8&refRID=1Q7DC1YH43JBTWGWK8QG
pH Circuit
atlas-scientific.com/product_pages/circuits/ezo_ph.html
Since the Arduino has already written the programming for the pH circuit (atlas-scientific.com/product_pages/circuits/ezo_ph.html), another possibility would be for me to by the Arduino controller and have it communicate with a BS2 controller. Would that be possible, it seems like I could do this through serial communication. What do you think> Any feedback would be greatly appreciated. Thanks!
Chris Claudet
I am trying to find an inexpensive way to measure and monitor the pH of a nutrient solution. I tried one method a couple of years ago with the probe linked below and some other components, but I was unsuccessful. Recently browsing amazon, I came across the pH circuit linked below. Can someone please let me know if this circuit is compatible with the BS2. I own several BS2 controllers, but I do not have Arduino controllers, nor am I familiar with Arduino's coding so I would prefer to stick with the BS2 if possible.
pH Probe
amazon.com/American-Marine-PINPOINT-pH-Probe/dp/B001EHJO64/ref=pd_bxgy_147_img_2?ie=UTF8&refRID=1Q7DC1YH43JBTWGWK8QG
pH Circuit
atlas-scientific.com/product_pages/circuits/ezo_ph.html
Since the Arduino has already written the programming for the pH circuit (atlas-scientific.com/product_pages/circuits/ezo_ph.html), another possibility would be for me to by the Arduino controller and have it communicate with a BS2 controller. Would that be possible, it seems like I could do this through serial communication. What do you think> Any feedback would be greatly appreciated. Thanks!
Chris Claudet
Comments
Just send the sensor a "R" followed by a carriage return and the device will send the pH back.
I've used these sorts of sensors myself. If you have trouble getting it to work post the code you're using and and we can take a look at it to see if we can spot any problems.
It "can" communicate via I2C but don't you think asynchronous serial would be the easiest way to use the device with a BS2?
I'd think a simple SEROUT followed by a SERIN would do the job.
Edit: Fixed my butchered serial in/out command mistakes.
Edit again: The "SERIN_SEROUT1.BS2" and "SERIN_SEROUT2.BS2" examples are good places to start.
Full range pH reading from .001 to 14.000
• Accurate pH readings down to the thousandths place (+/- 0.02)
Edit: I hope this isn't going to be one of those cases where the BS-2 can't turn around fast enough to catch a SERIN that follows a SEROUT. May have to resort to I2C after all. EndEdit
I read the data in one character at a time in order to check for the decimal point. I doubt this is a good approach.
The little PBASIC I learned is very rusty.
Here's my untested attempt.
The variable "value" should contain the pH multiplied by the value of "multiplier". Hopefully this will allow the pH level to be compared in a meaningful way.
There's got to be a better way to do this. Hopefully someone with more PBASIC knowledge will improve the code.
Read it all into a byte array then parse the result afterwards.
where # is the number of bytes expected. If this is variable, then use the largest value and set a timeout. If the result is terminated with a CR, then you could stop at that too (add \CR after \#)
Thanks. I didn't know how to do this in PBASIC.
I made the change suggested by Sapphire.
Here's the latest version. It's still untested.
Hopefully Tom's fear about the timing isn't warranted.
This, in fact, is the only sensible idea using the BS2 and serial with this device. Nice suggestion, Sapphire.
I just thought of a possible way around this problem, if it turns out to be a problem. The sensor can be set to continuously output data. With a continuous stream of data, the BS2 shouldn't have a problem reading the sensor.
Here is a little program that just receives data from the module in continuous mode, as suggested by Duane in the previous comment. The module comes up in continuous mode, so you don't need to program it all if you are happy with the factory settings.
The Str2Bin bit converts the floating point string into "millipH" so you could easily compare to some limit and, say, set an alarm if the tested fluid becomes too acid or alkaline.
This program does not allow one to query the device as to its name or device info. I plan to address that by:
1. Try a lower baud rate
2. If that doesn't work, go to a BS-2p so I can use I2C.
Several of the Microcontroller KickStarts on Learn use these routines.
http://learn.parallax.com/KickStart/29133
http://learn.parallax.com/KickStart/27911
I2C does have the advantage that the BS2 is in control of when and how quickly data is received.
In chemistry one usually wants to use distilled water when water is used so it's a relatively common mistake for people to use distilled water as a soaking solution. Soaking a pH electrode in distilled water is very bad for it. Tap water isn't as bad as distilled water but a probe will last much longer if you use a proper soaking solution.
Calibrating a pH meter is very important if you want accurate readings. I don't think this sensor will let you calibrate the device at many pH levels but you really should calibrate a meter with buffers both higher in pH and lower in pH than the sample being measured.
pH extremes are bad for probes. If you need to measure a sample with either a really high or really low pH, try to minimize the time the probe is exposed to the sample. You'll likely need to recalibrate the meter after measuring a sample with an extreme pH. It's a good idea to calibrate the meter each day it will be used.
This sensor lets you do 1-, 2-, or 3-point calibration.
Turns out that probes are a whole lot more complicated to use than I would ever have thought. The particular probe referenced in the original posting has a lot of bad reviews on Amazon. People complained that the soaking solution dried out (which happened with the one I got). I have subsequently purchased another from atlas-scientific.