How to Connect a Turbidity Sensor to a Raspberry Pi 3

This site contains affiliate links to products. We may receive a commission for purchases made through these links.

There is no doubt that water is an essential resource. In addition to that, the quality of water is of more significance. Most individuals even don’t realize why it is important to drink enough water every day.

Unfortunately, water is being wasted in several uncontrolled ways. Coming up with a system that helps in preventing water wastage is vital.

This is where the Turbidity Sensor comes in. The turbidity sensor helps in measuring the quality of water as well as determining water levels. This is an important system, and as a DIY enthusiast, mastering ways in which you can implement it in your projects will help you go a long way.

In this article, we shall be discussing how to connect a Turbidity Sensor to a Raspberry Pi 3. The entire process is relatively easy, and when followed to the letter, you will be able to tackle it with fewer issues irrespective of your skill level. With that said, let’s get started.

AdobeStock 32584478 1

Overview

The Turbidity sensor connected to a Raspberry Pi 3 helps in measuring water quality with the use of a pH sensor. This particular sensor is capable of providing you with various essential parameters, including water level, pH level, water temperature, and LDR, which is used in turbidity measurement. When you interface the sensor with your Raspberry Pi 3, you will be able to obtain every essential value.

Every value will be decoded and then split up with the help of python programming. You can easily predict the quality of water with the use of pH values. However, with additional water parameters, you will be able to know the quality of water with this system’s help.

Connecting Turbidity Sensor to a Raspberry Pi 3

When connecting a turbidity sensor to a Raspberry Pi 3, you will require the following:

  • Raspberry Pi
  • Power supply
  • SD card
  • pH sensor
  • MCP300 (ADIC)
  • A VGA to HDMI converter (however, this is optional)
  • Raspbian Jessie Lite Operating System
  • SD card Formatter
  • Win32DiskImager or Etcher
  • Python programming

The first thing you will have to do is install the distribution on the Raspberry Pi 3; you should consider doing so by installing the Raspbian Jessie Lite Operating System. Once this is done, you will just go ahead and follow the tips discussed here.

Take your SD card and plug it in your Raspberry Pi 3 and then power it up. Usually, the default login, as well as password, are; pi and raspberry, respectively. You will go ahead and change the default password by keying in this command passwd

Go ahead and enter the current password before entering your new one. You will then have to install new software, and to do that; you will have to update your system first using this command sudoapt-getupdate and sudoapt-getupgrade. The process will only take a little time, and once you are done, you will then proceed to the installation process. Once you have your OS running, you should consider installing the Python programming.

You will be forced to manually configure some things, such as kernel support for 12C and the DS18B. Key in this command sudonano/etc/modules and then add these commands at file’s end i2c-bcm2708 and i2c-dev. In addition to that, you will have the line (put a ‘#’ in front) if it exists and key in this command sudonano/etc/modprobe.d/raspi-blacklist.conf. Then add these two commands blacklist spi-bcm2708 and blacklist i2c-bcm2708.

Once you are done with that, you will go ahead and modify /boot/config.txt by entering this command sudonano/boot/config.txt. Go ahead and enter these commands at the end dtparam=i2c_arm=on and dtparam=i2c1=on to enable BMP180 sensor. On the other hand, you will enter this command dtoverlay=w1-gpio to enable your DS18B sensor. When you have everything set up, you will go ahead and reboot by entering this command sudoreboot. 

Once you reboot your Raspberry Pi 3, you will have to finish sensor configuration by entering these commands sudo modprobew1-gpio and sudo modprobew1-therm. By doing so, your Raspberry Pi 3 will be ready to have all the sensors operating. Therefore, the last thing you will have to do to set up your server. To achieve it, you will key in this command gitclonehttps://github.com/nbonfils/fixed-probe.git.

With that done, you will set up your system service, allowing the server to start once you power your Raspberry Pi 3. The next startup, your server will be working and collecting data from the sensors. You can always use these commands in case you want to stop; sudosystemctlstopsensor-server.service and sudosystemctlstartsensor-server.service. Your Raspberry Pi will be configured and connected successfully. However, you will still have to connect your probe.

What you need to know about connecting turbidity sensor to Raspberry Pi 3

Sensor

When you connect a turbidity sensor to Raspberry Pi 3, it will help in measuring the clarity of your water. The sensor is equipped with three pins (GND, VIN, and DATA). Usually, the turbidity sensors are often found in house appliances such as dishwashers.

Since the turbidity sensor features an analog sensor, the Raspberry Pi 3 is not equipped with an analog-digital converter. This means that you will have to use an external one such as the MCP300B.

Data collection 

Your Raspberry Pi 3 is designed to handle your sensors as well as receive data from them. Furthermore, the data features three possible in which you can go:

  • Network availability. You can send data through GPRS with an HTTP protocol through the GET method to the server; this can process, parse as well as display your data using a web interface. Usually, the images will be sent through the PUT method.
  • Use a USB in the absence of a network. Your data can be stored in the USB root directory in a CSV format in thesensor_data.csv file.
  • No USB and no internet. The data will be stored locally on your SD card.

Final Word

Connecting the Turbidity sensor to Raspberry Pi 3 is relatively easy and can be achieved by anyone irrespective of their skill level. By following the tips discussed in this article, you will be able to connect your Turbidity sensor to Raspberry Pi 3 without any issue. As we conclude, we hope that you find this article helpful.

About The Author