A Microcontroller Based Turbidity Meter using AtmelMega32

Introduction
Low-Cost Turbidity Meter for Underdeveloped Countries
Our project is a collaboration with an independent research project being conducted by senior civil and environmental engineering student James Berg. The goal of this project is to create a low cost turbidity meter for use in under developed countries. Real laboratory turbidity meters can cost over $1000.Our goal is to create a meter that costs between $50 and $75. Because we are using less expensive sensors, the accuracy of our meter might not be as high as a piece of laboratory equipment. However, our goal is make a meter with a resolution of .1 NTU in the range 0-50 NTU and a resolution of 2 NTU in the range 50-1000 NTU. In addition the meter needs to have a calibration mode which can accurately calibrate the meter for use in the field.

A Microcontroller Based Turbidity Meter using AtmelMega32
A Microcontroller Based Turbidity Meter using AtmelMega32

Background
What is Turbidity?
According to the Environmental Protection Agency (EPA), turbidity is:
The cloudy appearance of water caused by the presence of suspended and colloidal matter. In the waterworks field, a turbidity measurement is used to indicate the clarity of water. Technically, turbidity is an optical property of the water based on the amount of light reflected by suspended particles. Turbidity cannot be directly equated to suspended solids because white particles reflect more light than dark-colored particles and many small particles will reflect more light than an equivalent large particle.[1]

Basically, this means that turbidity is closely related to the amount of light scattered at 90 degrees when a light source is shined through a sample. Our measurement process takes advantage of the relationship between optical scattering and turbidity to take measurements of the turbidity of liquid samples.
How Do We Measure Turbidity?
When particles are suspended in water and a light is shined through the sample, not all of the light will pass straight through the sample. Instead, the light will reflect off of the suspended particles and some of the light will exit at a right angle to the direction of entry into the sample. Our meter uses a laser pointer as a light source, and two photodiodes as detectors for the intensity of the transmitted and refracted light.
By measuring the voltages off of both of the photo diodes, we can derive a function which calculates turbidity from the ratio of the voltage across the 90 degree sensor to the voltage across the 180 degree sensor.
In order to prove that our idea was sound, we used equipment in one of the civil and environmental engineering labs to test out the design. We mixed kaolin clay and water to create samples of varying turbidity. We measured the samples on a calibrated turbidity meter, and then took measurements from our device.
It is apparent that there is some function which will define the turbidity of a sample as a function of the voltage ratio from the sensors. As it turns out, a quadratic least squares regression line is a very close fit to the data.
Calibration Standards
The EPA sets the calibration standard for a turbidity meter quite high. The following are the EPA for turbidity meters:
The sensitivity of the instrument should permit detection of a turbidity difference of 0.02 NTU or less in waters having turbidities less than 1 unit. The instrument should measure from 0 to 40 units turbidity. Several ranges may be necessary to obtain both adequate coverage and sufficient sensitivity for low turbidities.[1]
These standards are probably beyond the capabilities of the sensors that we chose and the ability of the microcontroller to process. However, the point of this project is not to create a perfect meter, but rather a viable low cost alternative. Despite the fact that our resolution does not necessarily live up to EPA standards, the meter can still be quite useful in a laboratory setting.
Getting Samples to Measure
The principle of turbidity measurements was described in the above section. In practice, taking these measurements turned out to be far more difficult than was imagined. The first large problem that we encountered was the quality of the samples which we were attempting to use to calibrate the meter with. Because we had to work on our project in the 476 lab space, we needed to get samples of known turbidities which were contained in glass cuvettes which we could bring into the lab. We measured the turbidity of our samples in a calibrated turbidity meter in a civil and environmental engineering laboratory. The standard sample which is used to calibrate turbidity meters is formazin in water.However, formazin is a carcinogen and expensive, so we looked for alternative materials use.
Kaolin clay mixed with water was the first sample type which we tried. The downfall of Kaolin clay is that is does not form a homogeneous solution with water, and it settles out over time. This means that while the sample is in the meter, small chunks of the clay will float between the photodiode and the laser.This results in unstable measurements of turbidity even on a calibrated piece of laboratory equipment!!
Our next attempt at finding stable samples also went sour. Regular 2% milk does form a homogeneous solution in water. We mixed milk with water to create samples of various turbidities, all of which were stable. However, milk is an organic substance which means that is spoils over time. Despite our best refrigeration efforts, after one night, the sample went bad and the turbidity changed.
Our final effort was clearly the best. We diluted a hydrophilic cutting oil into water to make stable, homogeneous, non-organic samples which do not settle out over time. The samples are shown above in figure 3. The turbidity remained stable over a period of several days (and counting).
Hardware Design

Housing the Sensors
Mixed in with the process of discovering the importance of stable samples was learning the importance of a stable receptacle for those samples. The original design for the turbidity meter was created by James Berg out of foam core cardboard. This setup is shown below in figure 4. Eventually, after much frustration, we discovered that when we put samples into the cardboard, the housing of the meter flexed, and the alignment of the laser to the photodiodes changed by as much as 10% in either direction.
In order to try to minimize the movement of the sensors, light source and sample, James created a hard nylon container for the meter. This container is shown below in figure 5. There are holes drilled into the sides for the photodiodes and the laser pointer. The precise machining keeps the sensors from moving with respect to the light source. However, the diameter of the hole for the cuvettes was slightly too large. The results was that the placement of the cuvette in the holder could drastically adjust the readings on the sensors. Because the laser is a highly correlated and directed light source, the angle at which the beam hits the glass changes the amount of light which is reflected and transmitted. In order to combat this, we found a new, disposable cuvette (the ones shown in figure 3) which was slightly larger in diameter. James machined the nylon holder to within 1/1000 inch precision. The cuvettes cannot move with respect to the laser, and the readings are very steady.
A Microcontroller Based Turbidity Meter using AtmelMega32 diagram
After moving to the black nylon container, we also decided to focus on the entire range of turbidity (0-1000 NTU) rather than just the range 0-50 NTU. We had been focusing on increasing the resolution in the low range, but we decided that a more reasonable goal for this project was to try to get good (not great) readings across the entire scale. Although we have not had the opportunity to test the resolution of the new housing for sample in the range 0-50 NTU, we have high hopes that the new housing will also improve resolution in this range.
From Photodiodes to the MCU
After receiving James measurements (shown in figure 2), we realized that one of the main challenges of this project would be taking input from the photodiodes to the ADC. The ADC on the on the AtmelMega32 MCU has 10 bits of resolution, or 1024 distinct levels, between GND and Vcc. In the range from 0-50 NTU the voltage across the 90 degree sensor varies from .0633V to .1477V. Without amplification, that corresponds to (.1477V-.0633V) * 1024levels / 5V= 17 levels.This means that we need to amplify the voltages from the sensors so that they resolve to as many different levels as possible. If we use a non-inverting amplifier, such as the once shown in figure 6, we can get a gain of up to 30 without clipping the input.

Parts list:

 

Part Name

Quantity

     Price ($)
 

 

 
White Board

1

6

Custom PC Board

1

5

Mega32

1

8

LCD (16×2)

1

8

LM 358 Dual Op Amp

1

1.04

9V Battery

1

4

Chunk Black Nylon

1

found

Laser Pointer

1

found

OPF470 Photodiodes

2

found

Push Buttons

5

found

Total Price

 

$32.04

 
For more detail: ECE 476 Final Project:  A Microcontroller Based Turbidity Meter


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top