pH Controller

Source

The pH of the medium a plant is grown in can have a large impact on its growth. This device is a simple pH controller for a hydroponic plant set up.

The brain of the operation is a PyBoard microcontroller. Any microcontroller would do, but I prefer them to your typical arduino uno/nano for several reasons. First I am most comfortable in python, and can get more done quickly, second it has a built in SD card for data storage, third, and most importantly, it has a REPL. The REPL allows instance access to the peripherals, making prototyping, testing and bug-hunting much easier.

pH Controller diagram
Parts List

I found all of these parts on ebay for a total less than £50. I have avoided exact part names here because they don't matter, but feel free to send me an email for further guidance. To keep things neat you will also want a box to put them in, I 3D printed one, but any box you can cut some holes in will do.

pH controller Photo

The screen and buttons aren't essential, however, they are useful for checking it is working as intended, and allowing users who can't code to keep the pH meter calibrated. I also included a cheap and cheerful temperature/humidity sensor, so the data can also be tracked along with the pH.

The L298N stepper motor driver is an absolute workhorse. It allows the whole set-up to be powered from one supply, as it will step down 10V to 5V to run the pyBoard, as well as allowing control of the higher voltage peristaltic pumps. In terms of putting the whole thing together I would suggest an incremental approach. Add each component one at a time, and use the REPL to check they are working as expected. As can be seen below the wiring can turn into a bit of a rats nest, so adding them one at a time ensures no crossed wires. The pin outs can all be found in main.py.

pH meter internals

The code in the github link above should be used more as a guideline for your particular set-up. Test everything thoroughly before you actually use it! One final note: I would recommend putting freewheeling diodes across your peristaltic pumps.

Calibration

You can calibrate the pH meter with just two points, however I wanted to do three to confirm the response was linear in the region of interest. The result is shown in the graph below (sorry there are no error bars). Fitting the data points gives a gradient of 157 and a y-intercept of 1185. The "units" on the y-axis are just the straight analog read value, a number between 0 and 4095 (12 bits of resolution). Re-arranging to make x the subject of the equation provides the pH of the reservoir as a function of the measured voltage.

Calibration Graph
Future Improvements