Automated Water Testing


Hydroponics, aquaponics, water features, aquaculture…  A lot of endeavors depend on water quality and knowing what is in your water.   You can automate testing of a few things, but for many things sensors either don’t exist or are prohibitively expensive.  Many tests can be performed using colorimetric tests where one or more reagents are added to the water and the resulting color is the indicator.  But these can be time consuming to perform.

I got tired of being bitten by mosquitoes while waiting for the Nitrate color test to complete and decided to automate the process.  I built the autotester which can be used to automate the API tests or any other colorimetric tests that use liquid reagents.

There are 12 slots for reagents.  The reagents are in 10mm syringes which can be popped in and out.  The tester can perform the following steps:

  • Rinse and clean the mixing tube
  • Fill the mixing tube with x ml of water
  • Agitate the reagent before dispensing (if needed by the test)
  • Dispense x drops of reagent into the mixing tube
  • Dispense whatever combination of reagents is needed by the test
  • Agitate the mixture (if needed)
  • Wait for the color to develop
  • Compare the resulting color to recorded color swatches (the CIElab colorspace is used since it was designed to mimic human color perception)
  • Stopper the reagents to preserve them between tests
  • Record and report the results
  • Run tests on demand or by schedule
  • Send notifications where the readings exceed preset thresholds
  • Send notifications when a reagent is getting low

Tests sequences are set up using a web interface.  To learn the color values associated with a test, the color swatches can be placed in front of the camera and it will record the color values and the associated test reading.  For maximum acuracy, the tests should be run with the cover on and lighting only supplied by the internal LEDs.  The system also samples the lighting environment and attempts to adjust to alternate lighting environments should the tests be run without the cover on.  Unlike humans, the autotester is very precise in reading the color.  It can interpolate between colors and extrapolate beyond the end colors to obtain more detailed measurements than the human eye can achieve.

The processor is a Raspberry Pi (model 2, or 3, or Zero) and a custom circuit board is used to control the steppers, electromagnets, lighting, valves, and pump.  The camera is a pi-camera with a fisheye lens.  The plastic parts are 3D printed.  In this case it is important to print most of the parts in white or black as you do not want to bias the color measurements.  The designs and code will be released open source once the web interface is cleaned up to be more user friendly.

The video below shows the autotester in operation.

More info on building the autoTester can be found here.