Arduino pH and ORP data logger
Purpose: how-to guide to building a pH and ORP data logger (on SD card) to use in your aquarium, swimming pool or hot tub.
All components cost €183.61. This is not particularly cheap, especially given that electrodes tend to last only 1 year.
- Arduino Uno R3 — €28.99
- Gravity: IO Expansion Shield for Arduino V7.1 — €14.95
- Gravity: Analog pH Sensor / Meter Kit For Arduino (BNC) — €35.95
- Gravity: Analog ORP Sensor Meter For Arduino (BNC) — €75 + shipping
- MicroSD card module for Arduino — €18.73
- MicroSD — €9.99
- 5m USB extension cable (optional) — €9.85
A Tupperware box works well as a water-resistant casing in case the prototype stays outdoors for longer.
Hardware set-up — connection diagrams
This is what my final prototype looked like, neatly wrapped in a Tupperware box for water-resistance.
- Gravity: IO Expansion Shield for Arduino V7.1 + SD card connection
- Gravity: Analog pH Sensor / Meter Kit For Arduino (BNC)
- Gravity: Analog ORP Sensor Meter For Arduino (BNC)
Software set-up — code
The C++ code below is not optimised in any form, but works well. Any feedback is appreciated!
You can change the rate at which sensor data is logged by changing the ‘printInterval’ variable. Furthermore, adjust ‘pH_Offset’ and ‘ORP_OFFSET’ to calibrate.
While some electrodes are calibrated before shipping, it is crucial to calibrate any electrode before testing. I used pH and an ORP buffer solutions from my local pool store, but I found some online too: pH for €10.22 and ORP for €8.99.
Calibrate the electrodes with the buffer solutions for a couple hours to make sure you correctly adjust the pH and ORP offsets in the code.
The easiest way to calibrate and test the prototype is by opening the ‘Serial Monitor’ in the Arduino app on your desktop. Now, the prototype will start writing to an empty file every time it’s plugged in. The existing file will be overwritten. So make sure you pull the logged data before starting a new test run.
Here is a sample output in the ‘Serial Monitor’:
10 sec — ORP value: 122 mV — pH value: 6.44
20 sec — ORP value: 122 mV — pH value: 6.45
30 sec — ORP value: 122 mV — pH value: 6.45
40 sec — ORP value: 121 mV — pH value: 6.45
50 sec — ORP value: 122 mV — pH value: 6.45
60 sec — ORP value: 122 mV — pH value: 6.45
Compare this to the equivalent data in the .txt file on the SD card, which separates values with a blank space:
10 122 6.44
20 122 6.45
30 122 6.45
40 121 6.45
50 122 6.45
60 122 6.45
It might be necessary to smooth the resulting data in order to identify more long-term trends. Short-term deviations can be quite substantial.
I hope this short how-to guide is useful — just comment below if you have any questions.