Fixed Sensor

From BioDesign for the Real-World
Revision as of 20:22, 10 June 2016 by Nbonfils (Talk | contribs) (What is this project useful for ?)

Jump to: navigation, search
River sorge.jpg

"Open design of a fixed probe for water quality monitoring in rivers and lakes" is the bachelor project of an EPFL student, Nils Bonfils, which is done within the Biodesign project and supervised by Robin Scheibler and Sachiko Hirosue.

The aim of this project is to set up a prototype measurement station in the Sorge (a small river near the EPFL) to collect some data about the water and the environmental conditions. And also make the work reproducible so that someone, somewhere else could also build one to collect data about a specific river or lake. That's why there also is a GitHub for the project, where there are guidlines on how to build your own. These guidlines were made based on my own experience of building such a device.

The data collected is for my prototype restrained to the temperature of the water, the turbidity of the water, the ambient temperature, the barometric pressure and taking a photo of the water. One could easily imagine that it can be extended to collect more data related to pollution of the water like the conductivity or pH. But it's for simplicity reasons that there are only 5 different types of data collected (which seems enough for a prototype) and also to get a functional prototype in a single semester while not working full time on it. And one must not forget that this project is started from scratch !

What is this project useful for ?

The goal of this project is to build and setup a fixed probe that will store/send measured data related to the water quality collected via differents sensors. The experience of building this prototype will be used as a basis to document the process of building such a probe, giving some sort of guidelines for others to build their own device. This documentation is for now written as a README on the github repository of the project (link in the references).

The importance of this project lay on the fact that water is a precious life-depending ressource which is unfortunately often polluted by industries and/or leaky waste management system (aka toilets). That being said allowing anyone to be able to monitor water-related data could raise awarness on how polluted some waters are and also provide some tool to detect which water aren't to be drunken from. Maybe not as precisely as some method that already exists, consisting of manually taking samples of water then bring it to a lab for further analysis, but more like being able to detect "Oh! This rivers is anormally dirty" without needing to be there, as there is an autonomous system that is already in place.

A disadvantage of such a system is that it lacks adaptability to certain situation, it just does what it's supposed to do. Also for now with limited ressources it can't do complex measurements (like following a specific measurement protocol). But having a constant feedback on simpler measurments (temperature, turbidity, etc...) could give some clue on where and when to go and do manually more complex measurments (supposing that we could have multiple probe on different section of a water flow). That's just the logical advantage of having an automated system over the need to do everything by hand, also there already exists professional solutions, but as the one used by the State of Geneva cost over 10'000$, not everyone could afford such a device, even the State of Geneva has only three of them, that are managed by Stephane Odriozola who works for the State of Geneva (see [ Nils's blog post of his meeting with him). So one really big advantage of such probe as proposed in this project, is that they provide a really affordable way of monitoring waters.

If the probes are cheaper, there can be more of them, if there can more of them, data collected are more meaningful as you have more data to compare with and finnally with more meaningful data one can take more adequat measure to protect the environment.

The final goal will be to provide an open source alternative to professional water related data collecting device, making anyone who wants it able to build its own probe with lesser mean.

For now, basically nothing really interresting, but as mentioned in the intro, it's a prototype and the application of such a device is potentially interresting, like extending the work and change it or add more sensors to collect data related to other parameters that are useful for you. Also this could be nice in some countries where governements aren't willing to spend money in water monitoring, and you don't need to spend 10'000$ to get a professional probe like the ones used in the State of Geneva (Nils had the chance to meet Stephane Odriozola who works there, see his post on the Biodesign blog), maybe a scientific team could build few of those probes and check them in some rivers if the water is polluted and/or dirty.

This project is the frame of something that could become really improved if people contribute to it. This project is also part of of the Biodesign project, which for now the "main" project is to detect Arsenic in water with a bacteria, and the collecting system has to be manually done, it could be interesting to automate it by maybe integrating this kind of measurements in a more advanced version of such a probe.

Developpement from scratch

This project starts from scratch, meaning that at first it was just an idea. The idea of this emerged between Sachiko, Robin and Nils. At first, Robin and Sachiko presented the Biodesign project to Nils and they came to the idea that, as the collecting of sample for the bacteria measurements is not highly developed as well as the recording of the data, it would be interesting to automate some parts of it.

So the idea of having some kind of probe on the field that would do the measurements and sending data through internet came up, but as for the bacteria there are specific protocols and other things, it was more reasonable to start with measurements that are easier to make, like the temperature of the water (etc...). So that's where the idea of such a probe came from.

Once the idea was correctly set up, materials to craft the probe were needed.

Scraping/Buying the materials

One of the project's side goal is to make the building of such a device accessible and affordable, so the more materials can be scraped, the better. And if there is a need to buy something, the cheaper the better. So indeed, for the prototype, the finitions aren't quite "commercial", it is really DIY looking.

What could be scraped for example is the turbidity sensor, which is a basic turbidity sensor comming from a dishwasher (for the prototype it was bought for 2$ on the internet as we hadn't a dishwasher at our disposal). In fact, almost everything could be scraped depending on how good you are at finding and making work stuff, and even if you can't, every materials used for such a probe can be bought on the internet for very cheap.

Software developement

Starting from scratch also means that there is no software for such a probe. Of course, there are already some works out there that were made to make certain of these components work, but not for all of them, and there was a need to figure out those things too. And at the end, putting it all together and have a working server that runs on the device, collects the data and send them.

The choice was made to develop in python 3 as it is a very popular and user-friendly language, although powerful. Python is an interpreted language, that means that it can run on any machine, providing the python interpreter is installed on this machine. And as the Raspberry Pi features a linux system (Raspbian) it is very easy to install and use python on it.

A big part of this project was the testing of each components with Raspberry Pi and integrating the code to read the data for it in a server-script in python. The testing consisted in different steps, first finding a documentation on the component if there was any, then based on that, hook up the component to the raspberry, trying to find a python library if there are any for this specific component and then try to get some data out of the component. Once the component worked, there was a need to integrate it in the server-script that will run inside the probe.

Building the probe

It is a chance that there exists Hackuarium near the EPFL, a place where different people coming from different formations can work and meet. There are also a lot of tools to work with. It is where the prototype was built.

But before building, as there was no plans to build such a probe, the creation of the prototype was made step by step, with lots of tests. A thing that couldn't be done without the apropriate tools were the holes in the mettalic box, those holes were made in order for the cable of the sensors to leave the box and go in the water, and tools were needed so the holes have the right size for the cable clamps. To use these tools following a security formation was needed first.

Fastening the electronics inside the boxes was another challenge, for the small box as there only is a small sensor in it (temperature and barometric pressure), a very simple PCB with the adequat size to fit in and fastened it. And for the big box, cutting a plexiglas plate with the adequate size too seems to do the trick (of course the components need to be fixed to the plate too).

The electronic components are soldered together with the help of wires and a breadborad-like PCB.

Problem faced during the project

Of course in project like this not everything goes as planned and indeed there were a few difficulties.

Notably with the turbidity sensor, such sensor can be found in any standard dishwasher but other than that and tutorials on how to replace the turbidity sensor in a dishwasher there is not much documentation on the internet, so logically as a turbidity sensor give an analog output there is a need for an analog-digital converter, that with a 10k resistor between the analog output of the sensor and the ground showed some acceptable results. And as the ouput result is just a value between 0 and 1024 (10 bits ADC) it needs to be calibrated, the choice was made such that the raw value will be sent to the server leaving the interpretation to the front-end. Although for calibratique physically the sensors some tests were made with water and milk to get actual value that made sense.

The there is the GSM module, it is not a module made for a Raspberry Pi (gsm click) so the figuring out how it worked wasn't as easy as for the other components (such as the temperature sensor). It had the TX and RX pins, typical pins used for serial communication, so using a usb to serial module to connect it to a computer is really interesting. GSM module usually communicate with AT commands and indeed it is the case for this one, then it is required to enter the correct sequence of AT commands in order to connect to the network and sends some informations through internet. Things worked with usb module but when hooked via the GPIO pins of the Raspberry Pi the output wnet randomly garbage, sometime it worked, sometimes not.

The project

"Open design of a fixed probe for water quality monitoring in rivers and lakes" is the bachelor project of an EPFL student Nils Bonfils which is done within the Biodesign project and supervised by Robin Scheibler. The goal is to set a fixed measurement station on Sorge river at EPFL. It will collect different water-related and environment-related data and then send them through the internet to a server to be stored there, and then maybe be displayed with a web interface. The core of the station is a raspberry pi that will be used to interface with the different components like the temperature probe. The advantages of using raspberry pi in such a project is firstly its low power consumption (roughly 2 to 3 W ). There are other advantages, like easy backup storage and internet connexion through USB (like usb dongle for 3g/4g) and there also is an ease of use with the ssh connexion, which provides a direct interface to access the raspberry pi, update the code, etc...

References and links

Currently used in the project

GitHub of the project


adc hook up for reading from sensor - python code to read from adc - Tutorial to connect ADC to raspberry pi

Used Sensor (BMP180) Datasheet of the sensor BMP180 circuit hook up BMP python lib

waterproof sensor(DS18B20) - useful python library (needed to change /boot/config.txt though) - ada fruit DS18B circuit hook up (the resistor is 4.7 or 10k Ohms)

GSM Click - octanis wiki - useful command sequence - some doc on at commands - configure serial on RPi

Witty Pi

LiPo Rider Pro

May be useful for further research/developpement

power consumption of pi 1 - power consumption of pi 2

Grafana tutorial with influxDB on CentOS


DIY water quality testing platform

Public Lab open water project

(VIDEO)Some guy doing a pretty similar work

Laboratory of ecohydrology at EPFL has a project for herbicide monitoring in the Chamberonne catchment where meteorological and flow data are available.

Flood monitor in the Flood Network.