Cheap pH Meter for Raspberry Pi with ADS1115 and PH4502C

Note: Currently working on a video of this how-to. Should be up in a few days.

If you search for “raspberry pi ph meter” you’ll quickly learn that there are very few affordable options when it comes to digitally monitoring the pH of your nutrient solution. For a while Atlas Scientific dominated the search results, but I believe their kit was around $200 at the time. The kit has since come down to $164, but for someone like me that’s still a bit out of my price range.

The problem with the Raspberry Pi is that it has no analog inputs and pH meters are analog for the most part. I like the Raspberry Pi as it’s a one stop shop, sure I could have used a computer that has analogs out of the box, but then how would I upload the information to a remote MySQL server? I’d have to expand that board.

Anyway here is a list of parts I used for this project with the three affiliates I use. Obviously AliExpress is the winner, but if you’re in a time crunch and have the extra money the other two are the exact same things.

** Note: I am using a Raspberry Pi Zero W, this schematic will work with any 40 pin header Raspberry Pi.

Parts used in this Guide (Shipping not included as this varies)
Raspberry Pi Zero W $18.09 $19.98 $21.49
ADS1115 $1.61 $1.79 $6.99
PH4502C + pH Probe $10.47 $14.53 $37.99
pH Reference Solution $0.95 (powder) $17.95 $18.52
Total: $30.17 $54.25 $82.38

Step 1: Wiring

Basic configuration
  • RPi pin 1 (3.3V) to ADS1115 pin VDD
  • RPi pin 2 (5V) to PH4502C pin V+
  • RPi pin 3 (SDA) to ADS1115 pin SDA
  • RPi pin 5 (SCL) to ADS1115 pin SCL
  • RPi pin 8 (GND) to PH4502C pin G (Analog GND closest to V+)
  • RPi pin 9 (GND) to ADS115 pin GND
  • ADS1115 pin A0 to PH4502C pin Po

Optional Setup

There are some optional pins on the PH4502C: To, Do, and G (digital, the G pin furthest from V+). You do not need these pins unless you want a digital signal for the pH limit or the analog temperature sensor as the PH4502C has built in temperature compensation. I do use the temperature sensor built into the pH probe since it’s already there.

  • RPi pin 11 (GPIO 17) to PH4502C pin Do (Optional Digital pH Limit)
  • RPi pin 14 (GND) to PH4502C pin G (Digital GND)
  • ADS1115 pin A1 to PH4502C pin To
Optional Configuration

Step 2: Adjusting the PH4502C Voltage Offset

So the idea behind this step is that that the PH4502C Po voltage oscillates between positive and negative values. We only want positive values for the ADC to convert. To remedy this we force a pH “reading” of 7.0 by shorting the BNC connector. To short the BNC take a metal paper clip and insert it down the center female input on the connector and connect one end of alligator clips to the paper clip and the other end to the outer metal casing of the BNC connector.

Once you have shorted the BNC you can run the following script, which I put way to much thought into. Once you start this script and dial it in to ~2.5 volts, you can leave it running for Step 3.

(Link to Github file)

Step 3: Mapping the the voltage to pH readings

In this step we will map two known pH measurements to their respective reported voltages. To do this step you either need some pH calibration solution, or you can use another substance of known pH; however, I prefer pH calibration solution.

I use General Hydroponics Standard Reference Solution pH 4.01 and pH 7.0. You will want some distilled, purified, or some sort of deionized water. Use this water to rinse the probe between pH measurements.

Once you have your solutions ready, the script from Step 2 should still be reporting a ~2.5 voltage connect the pH probe to the BNC to take measurements. Place the probe in both the pH 4.01 solution and the pH 7.0 solution (rinsing in between) and record their output voltages. It can take up to 2 minutes for the sensor to stabilize, so give it time in each solution.

Now that you have voltages for 4.01 and 7.00 reference solutions, use y = mx + b to solve the linear equation and map the range.

In my situation, pH 4.01 reported 3.11 volts (3.11,4.01) and pH 7.0 reported 2.58 volts (2.58, 7.0). If y = pH and x = voltage we can solve for m by y2-y1x2-x1.

7.0-4.012.58-3.11 = 2.99/-0.53 = –5.641509 = m

Once we have m we simply substitute it back in to one set, we’ll use pH 4.01. 4.01 = -5.641509(3.11) + b. Then solve for b = 21.55509299. The final formula is pH = -5.641509(voltage) + 21.55509299.

External Sources



Add a Comment

Your email address will not be published. Required fields are marked *