Fixed Sensor

From BioDesign for the Real-World
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. There 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 the current prototype is restrained to

  • the temperature of the water
  • the turbidity of the water
  • the ambient temperature
  • the barometric pressure
  • taking a photo of the water.

For simplicity reasons given a single semester project, there are only 5 different types of data collected and also to get a functional prototype.
One could easily imagine that it can be extended to collect more data related to pollution of the water like the conductivity or pH.

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 different 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 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.

This project does not necessarly aim to "replace" the professional devices but more like opening it anyone, giving the possibility to get data on the water by yourself and not waiting for some professional team with professional equipements do certain measurements for the period of time they have chosen, etc...

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.

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.

The idea of having some kind of fixed probe on the field that would do the measurements and sending data through internet came up.

Of course having a wider objectif than just creating a probe specifically for arsenic in waters measurements and analysis is more interresting, the idea evolved in way such that it would be interesting to have more than just on sensor on such a probe. But creating a wonderful probe that does any measurements you want isn't possible in such a short amount of time (one academic semester). So at first, as in any kind of project, it's required to start small and with the less ressource possible, that is just a logical and safe way to begin a project, and that is was was done in this project.

By starting small it's meant build a working prototype of a fixed probe that can measure some simple parameters relted to the water and its environment. Then set up the probe in real conditions and test it. That's where the advancement of this project sits now, of course the final goal is to go further and develop such a probe. But that's it for now, this project that starts as a bachelor project, building a prototype and documenting it.

The probe

The developpement of such a probe can be seen in a seperation of three big parts.

Logistics of the ressources/materials

One of the project's goal is to make the building of such a device accessible and affordable, so the more materials that can be scraped, the better. And if there is a need to buy something, the cheaper the better. So indeed, for the prototype. It is why this project follows the DIY approach on this.

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. What is to be achieved through this part of the developpement of the probe is to have working server scripts that can autonomously manage the different sensors and modules hooked to the controller (here a Raspberry Pi), and then send/store the data.

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.

The server needs to be resilient and autonomous, meaning that things can happen. If some sensors actully break it should not crash the server, data of the working sensors should still be collected, also if there is no network, data needs to be stored for there is no loss of data. That is called "robust code" and it is very hard to achieve, but everything must be done to tend to it.

A part of the writing of the server code is the testing of each components with Raspberry Pi and integrating the code to read its data in the server's code. 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.

Also there is this part of handling where the data is stored, and where and when to send it according to the network availability.

Hardware developement

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 give randomly garbage bytes, sometimes it worked, sometimes not.

Final words

As it should not be a conclusion, because it is just the start of a project that is still meant to evolve and grow, it's just some final words one a milestone of this project.

The project is not meant to restrain itself to the building of a simple prototype, and I will certainly continue working on it after this report. Firstly because the prototype is not completly working yet and I still have one week before the presentation, but honestly I think it is impossible to get it "completely working" in such a short amount of time, there always will be ameliorations to make, bugs to resolve... And secondly I loved working on this project as it is kind of "my" project, It really began from nothing and there is still a lot of thing to improve and to do to make the project evolve even further.

My only regret regarding the work I have done is that I couldn't do more and use more of time to work on this because of all the others courses I had to follow and all the other projects this semester

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.