Public Lab Research note


(Towards) AI-Assisted Water Testing

by jrmc502 | October 07, 2020 19:15 07 Oct 19:15 | #24713 | #24713

The Problem

Crisis like Flint and Newark highlight the lack of effective large-scale water quality assurance and the huge human cost this has. Current testing options are limited, lab testing is expensive, time consuming and relies on expertise and test strips are ambiguous and both these options are single use. Since water quality changes throughout the day and the seasons, multiple tests are necessary for a real assessment of heavy-metal contamination. Thus, there is to date no test that can help answering the question: is there lead in my water?

The (idea for a) Solution

Deployable, inexpensive, quick and accurate are the characteristics that makes electrochemistry the branch of science that can perhaps provide an answer. Digital, inexpensive potentiostats like the WheeSat (used as base for our project, shootout to Prof. Summers for being so awesome) and (almost) have proven to be effective at an extremely low price-point. Additionally, (almost) ready-to-go screen printed electrodes (https://www.palmsens.com/product/italsens-is-hm/) virtually eliminate the need for electrode preparation and conditioning. However, there is one last challenge remaining; Anodic Strip Voltammetry isn't really a term that comes up in every day parlance so in order for it to be effective, it has to be more "user friendly": that is, doable even if you don't have a degree in electrochemistry. That is where our work and cutting-edge advances in embedded-AI come in.

image description

By turning the problem of parameter optimization for generation of voltammograms (the experimental part" of ASV) into an ML problem, we can leverage pre-existing hardware and software solutions in a way that the need for electrochemical knowledge is eliminated.

Turning electrochemistry problem into an ML problem

We base our work partying from the standard-addition method followed by a two-step strip voltammetry protocol. The two steps are:

Step

  1. Pre-concentration (a very simple set-up than can be easily automated), biasing the working electrode to +5V as and pre-concentrating for several minutes. This potential is more than enough for all possible species detectable with SV.

Step

  1. Strip Voltammetry.

The idea here is that the voltammogram generated will start from pre-set parameters, and then the resulting (potentially "bad") voltammogram will be categorized based on features (things like shape, angle, patterns in values, etc) determined by the pre-trained ML model. After being categorized, new, better experimental parameters will be decided, and the experiment will be run again until a "good" voltammogram is achieved.

image description

Machine Learning for this Application

While writing a custom ML model for this application could certainly be an option, the "smart" way is to implement and adapt open-source pre-existing ML models which for which we then simply provide the training data set. By pre-training we can also minimize the hardware requirements to the bare minimum which improves deployability and cost. We consider various Google and TensorFlow available APIs, for which the latter has some promising computationally inexpensive embedded solutions.

A big reason why we believe this can work even with little training is because of the sampling space. While water is an extremely complicated matrix with parameters that vary widely, the behavior changes "predictably" and we know enough about the main parameters to consider: conductivity, pH and temperature. Consider the following Pourbaix Diagram:

image description

A vague statement made above is that the sequential experiment will stop once a "good" voltammogram is achieved. This is a classic basic problem in computer vision in which a match index can be easily computed. In general, you can ask imaging software (like imageJ) to tell you the percentage match between two shapes. Since a "good" voltammogram presents a bell curve at each species of interest (at given potentials), we can implement this solution in an straightforward manner.

Improved Deployment: Inexpensive and wireless

One of the main reasons why we decide to take this embedded-AI approach was because under this scheme we don't need the deployed system to carry heavy computations and can therefore work with a very basic, inexpensive "brain". We pre-train the model and then we load it onto the device, and it is then ready to go!

Now that we were working with the RaspberryPi system we can take the next step and leave behind our computers and just take our phones. As the python code is loaded in the RaspberryPi, we created an Android app which connects to the Raspberry Pi and the has a button to execute the main.py and then the results are spat our in the screen of your phone. Neat! Here are the files and this is the post with the instructions.


4 Comments

What a fascinating application of machine learning (using existing models, to boot!), ultimately making this tool more accessible. Thanks for explaining it all!

Thank you for your comments, hope we get to collect enough data to train a model enough to make it useful in real samples.


Reply to this comment...


Hi jrmc502,

I found your project proposal very interesting.

I have no practical experience with Electrochemistry but I am studying the subject with plans to assemble a potentiostat and use it in projects for chemical analysis of water.

http://www.c2o.pro.br/hackaguas/apes02.html

Translated by Google:

https://tinyurl.com/yydon3lj

I would like to learn more to "try to contribute" to your project.

Can I use this list for exchanging messages? Or do you prefer use the project page?

https://publiclab.org/notes/jrmc502/10-07-2020/towards-ai-assisted-water-testing

https://publiclab.org/notes/jrmc502/10-07-2020/towards-ai-assisted-water-testing-instructions

Best Regards, Markos

Is this a question? Click here to post it to the Questions page.

Markos, thanks for your interest! If you're wanting to explore potentiostats I'd recommend looking at the WheeSat (by Prof. Jack Summers and Smoky Mt. Scientific) which is what we're using. If you have interest in embedded AI applications then we could talk and see if there's a way for this to fit with your studies.


Likely to find something more about assisted water testing mechanism at https://culturebooklet.com but that is about Indian water system.


Reply to this comment...


Login to comment.