Water Turbidity

Project Objective: By testing water turbidity, temperature, and TDS of Lake Latin, we will be able to monitor and study Lake Latin, allowing Charlotte Latin School to make the best decisions for the Lake.

Testing Water

Good Water

Bad Water

Latin Okay Water

Latin Bad Water

Data Sheet

Algae Water Sheet

Water Turbidity Sensor

Set Up

To set up the water turbidity sensor, we plugged the sensor into the PCB board in either of the four ports (it does not matter which one is used). We then plugged an USB-C cord into the board and PC and uploaded the following code into the Arduino board.

How the Sensor Works

The Grove turbidity sensor works by using an optical sensor (composed of an optical transistor to control light and optical diodes that allow light to be transmitted in only one direction) to measure the amount of light that comes from the light source to the light sensor. In other words, it observes the amount of light scattered by material in the water to determine the turbidity of the liquid. Turbidity can be considered the relative clearness of a liquid.

Analysis

From this data, we can see that water turbidity is consistent in water bodies assuming that the water appears clear. Lake Latin water is consistent in both the okay and bad sides of the lake. The clean water compared to the dirtied clean water is more starkly different because the dirtied water is more obviously foggy.

The Code

How it Works

Void setup () {

Serial.begin(9600);

}

The ‘setup()’  function is used when the Arduino is powered on or reset, initializing serial communication (the process of sending data continuously one bit at a time) at a baud rate of 9600 (meaning that the serial port transfers a maximum of 9600 bits per second). This code allows the Arduino to communicate with an external device through a USB connection.


Void loop() {

Indicates that the code is to run repeatedly after the ‘setup()’ function. 


int sensorValue = analogRead(A0);

Reads the analog (continuous) voltage from pin A0.


float voltage = sensorValue * (3.3 / 1024.0);

Converts the analog reading to voltage. The ‘3.3’ is because the Arduino operates on a 0-3.3V range and thus scales the analog reading. 


Serial.println(“Sensor Output (V):”);

Gives a label to the serial monitor to indicate the following value is the sensor output (in volts).


Serial.println(voltage);

Tells the calculated voltage value to the serial monitor. 


Serial.println();

Prints an empty line in the code for better readability in the serial monitor.


delay(1000);

Pauses the program for 1000 milliseconds before repeating the loop.


}

Indicates the end of the code that gets repeated in the loop.

Temperature Sensor

Set Up

To use the temperature sensor, we plugged it into any of the four white ports on the PCB board and plugged an USB-C cable into the PCB board and PC. Next we downloaded https://github.com/PaulStoffregen/OneWire/archive/master.zip and https://github.com/milesburton/Arduino-Temperature-Control-Library/archive/master.zip libraries on the computer. In Arduino we then hit sketch, include library, add zip, and then add the two libraries linked above. Then we uploaded the following code to the board through Arduino.

How the Sensor Works

The One Wire Temperature Sensor DS18B20 works by measuring temperature using electrical signals. In the sensor, two metals generate electrical voltage/resistance when a change in temperature occurs between the diode terminals (the anode and cathode terminals). When the voltage increases, temperature increases (and vise versa). 

Analysis

This data shows us that Lake Latin water temperature is fairly consistent on the Okay and Bad sides of the Lake. The water temperature in the Good water is higher than that in the Bad water presumably becsause the mud added to the clean water to make the Bad water took some of the Bad water's heat. 

The Code

How it Works

// Include the libraries we need

#include <OneWire.h>

#include <DallasTemperature.h>

Includes the necessary libraries for working with the one-wire bus (communication method) and Dall Temperature sensors.


#define ONE_WIRE_BUS 26

Defines a constant ‘ONE_WIRE_BUS’ with the value 26. 26 is the pin to which the Dallas Temperature sensor is connected. The ‘ONE_WIRE_BUS’  allows multiple sensors to connect to the same wire.


OneWire oneWire(ONE_WIRE_BUS)

Creates an instance of the “OneWire’ class (a collection of functions and variables used to perform specific tasks) is created.  


// Pass our oneWire reference to Dallas Temperature.

Dallas Temperature sensors(&oneWire);

This sets up the communication with the Dallas Temperature Sensor.


void setup(void)

{

Serial.begin(9600);

The ‘setup()’  function is used when the Arduino is powered on or reset, initializing serial communication (the process of sending data continuously one bit at a time) at a baud rate of 9600 (meaning that the serial port transfers a maximum of 9600 bits per second).


Serial.println(“Dallas Temperature IC Control Library Demo”);

The program prints the message to the serial monitor that indicates the start of the Dallas Temperature IC control library demo. 


sensors.begin();

}

The ‘begin()’ method (a piece of code that only runs when called upon) is called on the ‘sensors’ object (allows access to the functions and variables inside a class) and initializes communication with the connected sensor. 



void loop(void)

{

Indicates that the code is to run repeatedly after the ‘setup()’ function. 


Serial.print(“Requesting temperatures…”);

Prints a message indicating that it’s about to request temperatures.


sensors.requestTemperatures(); // Send the command to get temperatures

Calls ‘sensors.requestTemperatures()’ to send a command to the Dallas Temperature sensor to obtain temperature readings


Serial.println(“DONE”);

Indicates that the temperature readings are done.


float tempC = sensors.getTempCByIndex(0);

The obtained temperature in Celsius is then retrieved and stored in the variable ‘tempC’.


if(tempC !_DEVICE_DISCONNECTED_C)

Checks if the temperature reading is valid. If the temperature equals ‘DEVICE_DISCONNECTED_C’, the temperature is invalid. If the temperature does not equal ‘DEVICE_DISCONNECTED_C’, then a valid temperature reading has been obtained. 


{

Serial.print(“Temperature for the device 1 (index 0) is: “);

Serial.println(tempC);

}

Prints the temperature to the serial monitor if the temperature reading is valid.


Else

{

Serial.println(“Error: Could not read temperature data”);

}

If there is an issue or the device is disconnected, it prints an error message.


}

Indicates the end of the code to be completed after ‘setup()’.

Total Dissolved Solids (TDS) Sensor

Set Up

To set up the TDS sensor, we plugged it into the white ports on the PCB board, plugged an USB-C cord into the board and PC, and uploaded the code in Arduino. 

How the Sensor Works

The TDS sensor measures the concentration of total dissolved solids in a liquid. It works by measuring the electrical conductivity of a liquid. The sensor has two electrodes that have an electrical current flowing between them. The amount of resistance is measured and the greater the resistance, the greater the concentration of dissolved solids as dissolved solids in water can conduct electricity. 

Analysis

This data shows that the total dissolved solids (TDS) in the Good and Bad clean water is close in range, the Lake Latin Okay water is about 50 parts per million more, and the Bad Lake Latin water is astronomically worse in quality as opposed to the other water samples. This extreme difference is likely due to sediments in the Bad Lake Latin water accumulating. 

The Code

How it Works

Void setup () {

Serial.begin(9600);

}

The ‘setup()’  function is used when the Arduino is powered on or reset, initializing serial communication (the process of sending data continuously one bit at a time) at a baud rate of 9600 (meaning that the serial port transfers a maximum of 9600 bits per second). This code allows the Arduino to communicate with an external device through a USB connection.


Void loop() {

Indicates that the code is to run repeatedly after the ‘setup()’ function. 


int sensorValue = analogRead(A0);

Reads the analog (continuous) voltage from pin A0. The voltage value will be between 0 and 1023 and corresponds to a voltage range of 0 to 5 volts. 


float voltage = sensorValue * (3.3 / 1024.0);

Converts the analog reading to voltage. The ‘3.3’ is because the Arduino operates on a 0-3.3V range and thus scales the analog reading. 


Serial.println(“Sensor Output (V):”);

Gives a label to the serial monitor to indicate the following value is the sensor output (in volts).


Serial.println(voltage);

Tells the calculated voltage value to the serial monitor. 


Serial.println();

Prints an empty line in the code for better readability in the serial monitor.


delay(1000);

Pauses the program for 1000 milliseconds before repeating the loop.


}

Indicates the end of the code that gets repeated in the loop.

Temperature Sensor:


// Include the libraries we need

#include <OneWire.h>

#include <DallasTemperature.h>

Includes the necessary libraries for working with the one-wire bus (communication method) and Dall Temperature sensors.


#define ONE_WIRE_BUS 26

Defines a constant ‘ONE_WIRE_BUS’ with the value 26. 26 is the pin to which the Dallas Temperature sensor is connected. The ‘ONE_WIRE_BUS’  allows multiple sensors to connect to the same wire.


OneWire oneWire(ONE_WIRE_BUS)

Creates an instance of the “OneWire’ class (a collection of functions and variables used to perform specific tasks) is created.  


// Pass our oneWire reference to Dallas Temperature.

Dallas Temperature sensors(&oneWire);

This sets up the communication with the Dallas Temperature Sensor.


void setup(void)

{

Serial.begin(9600);

The ‘setup()’  function is used when the Arduino is powered on or reset, initializing serial communication (the process of sending data continuously one bit at a time) at a baud rate of 9600 (meaning that the serial port transfers a maximum of 9600 bits per second).


Serial.println(“Dallas Temperature IC Control Library Demo”);

The program prints the message to the serial monitor that indicates the start of the Dallas Temperature IC control library demo. 


sensors.begin();

}

The ‘begin()’ method (a piece of code that only runs when called upon) is called on the ‘sensors’ object (allows access to the functions and variables inside a class) and initializes communication with the connected sensor. 



void loop(void)

{

Indicates that the code is to run repeatedly after the ‘setup()’ function. 


Serial.print(“Requesting temperatures…”);

Prints a message indicating that it’s about to request temperatures.


sensors.requestTemperatures(); // Send the command to get temperatures

Calls ‘sensors.requestTemperatures()’ to send a command to the Dallas Temperature sensor to obtain temperature readings


Serial.println(“DONE”);

Indicates that the temperature readings are done.


float tempC = sensors.getTempCByIndex(0);

The obtained temperature in Celsius is then retrieved and stored in the variable ‘tempC’.


if(tempC !_DEVICE_DISCONNECTED_C)

Checks if the temperature reading is valid. If the temperature equals ‘DEVICE_DISCONNECTED_C’, the temperature is invalid. If the temperature does not equal ‘DEVICE_DISCONNECTED_C’, then a valid temperature reading has been obtained. 


{

Serial.print(“Temperature for the device 1 (index 0) is: “);

Serial.println(tempC);

}

Prints the temperature to the serial monitor if the temperature reading is valid.


Else

{

Serial.println(“Error: Could not read temperature data”);

}

If there is an issue or the device is disconnected, it prints an error message.


}

Indicates the end of the code to be completed after ‘setup()’.

Personal Reflection 

Through this project, I learned about water turbidity, temperature, and total dissolved solids. This research gave me perspective about how certain factors can affect the quality of our water as well as how water quality can be improved. I understand to a greater extent now how difficult it can be to maintain good, healthy drinking water and natural bodies of water and the importance of diligent time taken to protecting and improving our waters.