Creating a pH meter using the pH FeatherWing

In this blog post we demonstrate how to create a pH meter using the pH FeatherWing, an Adafruit Feather M4 Express and a few additional components. The meter will display a continuous readout of the current pH and can be calibrated, via button press, at pH values of 4, 7 and 10.

In this example we require the following items:

The pH Feather Wing is capable of measuring both pH and temperature, however in this example we will only be using the pH sensor. In a subsequent blog post we will have examples demonstrating how to use the temperature sensor and how to compensate the pH readings for changes in temperature.

Step 1: Assembling the Hardware

Set-up the hardware onto the tripler base as shown in the images below.

The order in which the components are placed onto the tripler base is not important. However, if you plan on using a battery we have found it useful to position the Feather M4 Express at the top of the tripler base with the battery connnector pointing out as shown in the image above. This positioning makes it easier to connect the battery to the device.

In this example we are using the Feather M4 Express development board, but almost any Feather development board which can run CircuitPython will work for this example.

Step 2: Installing Firmware

For this demonstration we will use IO Rodeo's pH meter example firmware. The firmware is written in Python and requires that CircuitPython is installed on the Feather development board.

CircuitPython

An introduction to CircuitPython and instructions for installing CircuitPython on your development board can be found in Adafruit's Welcome to CircuitPython tutorial. For this example we recommend installing the latest release of CircuitPython from github which at the time of this writing was CircuitPython 4.0.0 Beta 5.
When CircuitPython is installed on the Feather development board and the board in plugged into your computer via the USB cable the Feather development board will show up on your computer as a USB drive named CIRCUITPY. This drive location is where we will install the required libraries and firmware files for the pH meter example.

CircuitPython Library Bundle

In addition to the CircuitPython itself you also need to have the CircuitPython Library bundle installed on the Feather development board in order to use the Quad Alphanumeric FeatherWing display. Instructions for installing the CircuitPython Library Bundle can be found on Adafruit's CircuitPython Libraries tutorial. The version of the CircuitPython Library Bundle must match the major version of CircuitPython that is installed on the Feather. For example, in this demonstration we are using CircuitPython 4.0.0 so we are using the 4.x version of the library bundle. The latest relases of the library bundle can be downloaded from here: CircuitPython Library Bundle latest releases

pH meter firmware

The pH meter example firmware can be downloaded from here: pH Meter Firmware. The firmware consists of single Python source file named code.py. To install the firmware on the Feather we simply copy this file to the CIRCUITPY drive associated with the Feather. The firmware should automatically be loaded after the file is copied to CIRCUITPY. The Feather's status LED should display a steady green color after the firmware loads.

Troubleshooting: If the status LED is not showing a steady green color it indicates that the firmware is not running and that there may be an issue. For example, if the status LED shows a steady white color it means the CircuitPython REPL (Read-Evaluate-Print-Loop) is running and you need to re-start the firmware (via Ctl-D). If the status light is pulsing yellow it indicates that the firmware has crashed and CircuitPython has entered Safe Mode. Trouble shooting information and further information regarding the LED status codes can be found on the Adafruit's CircuitPython Troubleshooting Tutorial

Step 3: Connecting pH probe and calibrating

The pH meter firmware continuously samples from the pH probe and displays the current pH measurement on the alphanumeric display.

When the firmware first starts, before it displays any measurements, it will check to see if there is an existing calibration saved to non-volatile memory. If it finds an existing calibration it will load and use this calibration. If it does not find a calibration it will load and use a default calbration for a generic pH probe. To get the best results you should always generate a calibration for your pH probe.

The firmware enables the user to create a calbration via the "pH 7" and "pH 4/10" buttons. There buttons are shown in the figure below.

The first button is labelled "pH7" for calibrating with the pH 7 solution. The second button is labelled "pH 4/10" for calibration with either pH 4 or pH 10.

In order to start a calibration the buttons should be pressed for one second. The display will then show "CAL" followed by either "PH7", "PH4", or "PH10". The pH 7 value should be calibrated first followed by either pH4 or pH10. The CircuitPython firmware will automatically detect whether the probe is in pH 4 or pH 10 solution. The firmware can use either a 2-point or 3-point calibration.

If the values sampled during the calibration procedure are not within the acceptable range for either pH 4 or pH 10 the firmware will display "ERR" on the alphanumeric display. If this occurs check the solutions and try again.

Resetting to the default calibration

The calibration can be reset to the generic default calibration as follows.

  • Press and hold the "pH 7" button and then while still holding the "pH 7" button press the "pH 4/10" button. This needs to be done within one second.
  • The display will show "----" followed by "CLR" and "CAL".
  • The default generic calibration will be reloaded and any existing calibrations will be deleted from non-volatile memory.

Example calibration

In this example we are use 2-point calibration with pH 7 and 10.

  • Connect the pH probe to the pH FeatherWing as shown in the image below
  • Set-up the two calibration solutions. We are using the calibration solutions shown below. Packet contents were transferred to two clean beakers.
  • Rinse the probe in distilled water and place into the beaker with the pH 7 solution.
  • Once the reading has settled, press and hold the "pH7" button for one second on the pH FeatherWing
  • The display flashes "CAL" followed by "PH7" during which time the device is collecting data for the calibration. After a few seconds, the display will show the reading. It should be a stable reading of 7.00 (or very close).
  • Rinse the probe in distilled water again and place the probe in the pH 10 solution
  • Once the reading has settled, press and hold the "pH 4/10" button for one second on the pH FeatherWing.
  • The display flashes "CAL" followed by "PH10" during which time the device is collecting data for the calibration. After a few seconds, the display will show the reading. it should be a stable reading of 10.00 (or very close).
  • At this point you can check the probe calibration by placing it back into pH 7 and/or 10 solutions and re-calibrating if necessary.
  • Once your probe is calibrated, you can start using the pH probe for measurements !
  • The calibration will be saved to non-volatile memory on the Feather development board and will be re-loaded when the device is powered on/off.