
Show HN: AnyLeaf – PH Sensor for Microcontrollers - the__alchemist
https://www.anyleaf.org/ph-module
======
gregsadetsky
Some more microcontroller-friendly pH sensors here -- [https://atlas-
scientific.com/ph/](https://atlas-scientific.com/ph/)

Their datasheets are spectacularly well designed and clear!
[https://www.atlas-
scientific.com/files/pH_EZO_Datasheet.pdf](https://www.atlas-
scientific.com/files/pH_EZO_Datasheet.pdf)

~~~
the__alchemist
I love the formatting, pictures, and cautions. Good visual flow too. I'm a bit
surprised it doesn't go into the technical aspects of what's going on with the
transfer functions, which op-amps/ADC are used etc.

~~~
nine_k
Aren't op amps sort of interchangeable here? Provided the correct temperature
compensation, they all are highly linear, have a few MOhm input impedance,
etc.

Same with ADCs; the signal in not particularly high-frequency.

What am I missing?

------
OJFord
OP, I realise AnyLeaf uses an electrode, but you're probably well-placed
having considered it to answer my Ask HN [0] that didn't get any traction: why
aren't (seemingly) ISFETs/BioFETs available to hobbyist/small-scale customers?

MSFET3330 for example is a pH sensor, but try finding someone to sell you one.

[0] -
[https://news.ycombinator.com/item?id=22996014](https://news.ycombinator.com/item?id=22996014)

~~~
akiselev
Haven't worked with these specific sensors before but I've worked with some
microfluidics and other exotic ICs and in my experience, most niche sensors
usually need to sell thousands to break even on the support cost of getting
even one customer up and running with just a tweaked reference design because
the engineers have a lot of competing responsibilities. Oftentimes these
manufacturers are also competing for fab time against ICs with a cheaper setup
cost and higher volume so theres extra pressure to get together as many big
orders as you can, otherwise the extra setup overhead drives the cost through
the roof. Hobbyists and small customers would drive most of these niche
fabless companies to bankruptcy

~~~
jerkstate
I wonder if there could be an open source support option for some of these.
Sell small lots for 1000% of fab cost, provide only a datasheet and host a
forum. A reseller willing to take on some inventory risk could easily do this.

------
SpikedCola
Maybe someone with more experience than myself can chime in. At a previous
startup we used regular pH sensors, from Atlas Scientific (exactly like the
ones in the article), submerged in a tank of nutrient water. After a few days
(a week tops) they would drift out of spec, and would need to be taken out,
re-calibrated, and put back into the process.

Short of a system that takes samples and feeds the probe, and can calibrate
automatically, how do you measure pH in-system long term? Is there a special
kind of probe that stays in calibration for longer?

~~~
the__alchemist
I don't think there's a way around periodic calibration if you want precise
measurements. At least not with normal glass electrodes. If the precision
requirements are loose, you could go months between calibration. If you're
trying to get within 0.1pH, every few weeks or so. For anything that's going
in a scientific paper, calibration before every use is important.

There might be a clever way around this, like with a tech other than glass
electrode, or some type of automation system with motors that raise and lower
the probe into calibration solutions.

Something interesting: pH electrode response is nearly linear, and you can
make the transfer function using entirely 2 (or 3 to compensate for non-
linearity) calibration points. (voltage, pH, temp) No arbitrary coefficient
required, other than maybe temp compensation.

Edit: I wonder if your sampling idea could kill 2 birds with one stone, if
implemented well: By sampling using a mechanical system, you could measure
regularly, and calibrate. Auto calibration, and avoid the lifetime reduction
from immersion. Eg some type of motor/pump system connected to the electrode.

~~~
amerine
What about the 1yr+ claim on [https://atlas-scientific.com/probes/industrial-
ph-probe/](https://atlas-scientific.com/probes/industrial-ph-probe/) ?

~~~
the__alchemist
No idea. Sounds awesome. Might be a higher quality probe, or one designed with
low drift rate in mind, given its marketed as an industrial probe. That length
doesn't specify how much drift is expected, so it's unclear what tolerances
that has in mind.

~~~
amerine
Ahh, it’s the tolerance details that I was missing. Thanks for the insight.

------
syntaxing
Kind of excited for this because I wanted to get into hydroponics but a huge
deterrent was an affordable and accurate PH sensor. Would be cool to see an
example of this being pushed to some "IoT platform" like Adafruit IoT.

~~~
the__alchemist
I'm working with the creator of
[Mycodo]([https://kizniche.github.io/Mycodo/](https://kizniche.github.io/Mycodo/))
on a PR to get it added there. I don't have much experience with Mycodo, but
it seems like a nice consolidated platform for measuring things and sending
outputs from a Raspberry Pi server. It's an open-source project mainly run by
one guy, who's very attentive to issues and PRs.

~~~
syntaxing
This is so awesome! I really love the nonsoldering setup (it's not hard to
solder, just annoying in a small apartment with kids). I'm going to see if
they're equivalent parts with Qwiic / STEMMA connectors instead of header
breakout.

Edit: Did not notice you were OP! Do you have more clarity on the calibration?
Is there a buffer solution you can recommend?

~~~
the__alchemist
Hopefully my reply to xupybd above should share light on calibration. The
device doesn't have onboard memory, so you use the software to get calibration
data, then save it to either your program file, or save/load to a file,
memory, db etc depending on your setup.

I don't have a specific recommendation, but have been using this myself. More
expensive than ideal: [https://www.amazon.com/Biopharm-Calibration-Solution-
Standar...](https://www.amazon.com/Biopharm-Calibration-Solution-Standards-
Traceable/dp/B01LVVAKEM/). The packets are cheaper, but require you to have
distilled water.

------
pryelluw
This is such a nice thing to market because you can laser focus on niches.
However, the copy on this landing page reads like a technical specs sheet.

I suggest you take the three benefits you have below the headline (affordable,
precise, easy to use) and rewrite the copy by expanding on the benefits. Also
use the examples listed. Like, how is this a great buy for a home brewer?

~~~
quickthrower2
Another niche: swimming pool owners. Although it’s only worth it if I can link
it to an action eg add acid but that feels a bit dangerous for diy project!
Maybe a sms to add he acid and how much is good enough

~~~
pryelluw
It sounds like a great idea on paper, but pools arent something people get
really into when compared to sonething like home brewing or aquariums.

~~~
quickthrower2
You might be right. What I might buy for say $50 or so is something that tests
my water and tells me what to do. It’s need to be ready to go, not make it
myself. This saves booking time to get the water tested at a shop. I don’t
want to test using a kit as I don’t trust myself to sue it properly.

------
doctoboggan
I have a fairly automated hydroponics system but I haven’t yet started with
always submerged ph sensors due to the cost. I’ve seen cheap ones but from
what I understand they are so inaccurate as to be useless. Most people seem to
recommend atlas.

I’m hoping these will be good enough.

~~~
pbhjpbhj
If you know the substance you're testing the pH of can't you infer the pH from
some other property? Like maybe pH goes with the square of resistivity or
something??

------
ComputerGuru
Inspired by the recently gone viral “digital pregnancy test just reads a
pregnancy test strip,” I wonder if you can get around the calibration issue
via some sort of electromechanical pH strip autoloader and analyzer.

~~~
bayesian_horse
Nope. It's easier to just put the probe into the damn calibration fluid.

------
xupybd
Can someone explain the calibration code. They enter calibration points.
Wouldn't you then need to calibrate the sensor with solutions at those PH
levels?

How would you do that with the example code?

~~~
the__alchemist
Correct. You need solutions at those levels. As sovreign said, they're
typically available at levels around 4, 7, and 10.

With the example code, you'd insert into the buffer solution, then run (for
example, in Python) ``` # place in buffer of nominal ph of 10 V1, T1 =
sensor.calibrate(CalSlot.ONE, 10, OnBoard()) # place in buffer of nominal ph
of 7 V2, T2 = sensor.calibrate(CalSlot.TWO, 7, OnBoard())

Then save V1, T1, and the buffers you used to a file, your database etc. Or
just write them to your `py file.` The MyCodo version, for example, handles
that automatically.

Then next time you run, load sensor.calibrate_all( CalPt(0.,7., 23),
CalPt(-0.17, 10., 23) ) If you just edited the file. Or those values would be
loaded from a db.

------
awinder
I went deep down the Internet rabbithole on these HOCl cleaning solution
machines (I still can’t figure out if it’s bs or not), but a big component was
ph testing the solution you make. Now I kinda want to pick one of these up,
some simple logic that measured ph and switched off power to the HOCl machine
when it hit the right ph would probably sell extremely well

------
brianhorakh
At first glance this looks just like the one I bought on taobao for 120rmb
(around 23usd) What is the difference?

------
fmakunbound
Cool man. Might check this out for my kombucha and all grain beer brewing
setup.

------
bob29
Looks like the same stuff on Adafruit or ebay but more expensive.

~~~
the__alchemist
I was surprised that this doesn't seem to be the case - For example, I can't
find any pH sensor on Adafruit. There is a model that's easy to find on eBay
or Amazon, sold under various brands - I was unable to get this working,
likely due to documentation or software issues.

~~~
gregsadetsky
I only found one soil pH sensor on Adafruit, but it's currently sold out:

[https://www.adafruit.com/product/4026](https://www.adafruit.com/product/4026)

~~~
flaviu2
That's a capacitive moisture sensor. It is incapable of measuring pH.

~~~
gregsadetsky
Oof, you're right of course. My bad! Thanks

------
jonbronson
How long do these probes last before oxidization destroy them?

~~~
the__alchemist
Unknown - I'm testing them, but can't provide data longer than the time since
start. They're double-junction, which helps with logevity by slowing
contamination of the internal KCl solution. My intent is to have them used for
continuous immersion.

The latest data: Comparing two probes manufactured in the same batch, one
immersed in a hydroponic solution, and one with periodic measurements. 3
months in, the immersed one has drifted by about 0.3 pH after the first 2
months; fixed by calibration. Another 0.1 in the third month. I don't have a
good answer for long-term life, but hope an immersed one will last at least a
year, and one used for periodic measurements for several. Older probes require
more frequent calibration, have slower response, and might experience jitter.

~~~
fuzzfactor
Take a look at these:

[https://metrohm.blog/2020/01/27/common-mistakes-
ph/](https://metrohm.blog/2020/01/27/common-mistakes-ph/)

[https://metrohm.blog/2020/07/06/best-practice-
sensors/](https://metrohm.blog/2020/07/06/best-practice-sensors/)

Notice the Separate pH Electrode is properly stored in distilled water:

[https://www.metrohm.com/en/products-
overview/60150100](https://www.metrohm.com/en/products-overview/60150100)

The corresponding Separate Reference Electrode is properly stored in the same
fluid as its internal electrolyte:

[https://www.metrohm.com/en/products-
overview/60733100](https://www.metrohm.com/en/products-overview/60733100)

Neither of these storage fluids are an actual pH buffer.

Stored separately like this to maintain readiness while unpowered, the
electrode pair is repeatedly rinsed and handled using referee technique to
freshly update its electronics and/or software to reflect the response of that
particular pair to agreed aqueous pH values by comparison to standard buffers.

This can be considered a _neutral_ baseline from which dissimilar sample
matrices can give a most reproducible lab reading, regardless of the
functional interference of the specific matrix with absolute accuracy over the
short term or the long term.

Ideally under laboratory conditions the referee electrode pair's response
shows insignificant drift beyond the needed precision over a longer-than-
needed term, and the electronics an order of magnitude better at least.

It's not impossible to have good reliable readings over a year's period with
clean samples in industrial use, without need to recalibrate.

A combination electrode can be handled in a referee way for good performance
too, but they are usually stored in a buffer, so instead a separate glass
sensor living most of its life in DI water is the theoretically better
baseline device to achieve commonality between labs, especially with unknown
or matrix-affected samples.

Once your laboratory technique, referee electrodes, and calibrated electronics
can be operated as your most reliable _reference instrument_, then
representative samples of the process fluid can be taken to the reference lab
the regular way.

It is not usually preferred to remove a process electrode and calibrate for it
the laboratory way.

Just correct for any deviation the continuously immersed electrode shows at
that time when responding to the same particular fluid as the Reference
Instrument does to a representative sample.

The Reference Instrument is calibrated against the Primary Standard (the
Standard buffers).

The working process instrument is calibrated against the Secondary Standard
(the Reference Instrument). Specific provisions can be made to validate beyond
the process range.

Routine continuous service process electrodes do not have to be the high-
dollar research kind, and referee lab work can be be done with less costly
electrodes than Metrohm.

An aged continuous process electrode, well stabilized by a limited-harm matrix
can be more stable than a brand new replacement even if, or sometimes
especially if its responsivity has been reduced compared to a new replacement.
However there needs to be enough quality analog gain to compensate, and to
further reduce jitter appropriate high-impedance shielding and vulnerable
removable connections having electrochemically compatible metals or platings
without harmful corrosion. Metrohm electrodes and their removable cables are
both gold plated at the electrode and have o-rings which protect from
laboratory vapors once connected. The other end of the cable where it conects
to the instrument matters too. Lag from old electrodes can still sometimes be
a problem but also sometimes the least of your problems.

------
fern856
Not open hardware? :(

[1] [https://github.com/anyleaf](https://github.com/anyleaf)

~~~
the__alchemist
I can post the design if you'd like, although it's easy to tell from the
datasheet, which lists the main parts. It uses a pair of AD8603 op amps
feeding the differential input of a TI ADS1115 ADC. The intent is to use the
op amps in a unity gain config, to deal with the probe's high impedance.

