This circuit is designed to monitor water quality and temperature using an Arduino UNO, a GSM SIM900 module, multiple water level sensors, and LEDs. The system reads temperature data from a TEMP sensor and TDS data from a TDS sensor module, displays the data on a 16x2 I2C LCD, and sends the data via the GSM SIM900 module. The status is indicated using LEDs.
Arduino UNO
GSM SIM900
Water Level Sensor
LED: Two Pin (red)
LED: Two Pin (yellow)
LED: Two Pin (green)
Resistor (200 Ohms)
/*
* Water Quality and Temperature Monitoring System
* This Arduino sketch reads temperature data from a TEMP sensor, TDS data from a
* TDS Sensor Module, and displays the data on a 16x2 I2C LCD. It also sends the
* data via a GSM SIM900 module and indicates status with an LED.
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// LCD setup
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Pin definitions
const int tempPin = 3; // TEMP sensor connected to D3
const int tdsPin = A0; // TDS sensor connected to A0
const int ledPin = 13; // LED connected to D13
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize LCD
lcd.begin();
lcd.backlight();
// Initialize TEMP sensor pin
pinMode(tempPin, INPUT);
// Initialize LED pin
pinMode(ledPin, OUTPUT);
// Initialize GSM module
Serial1.begin(9600); // GSM module connected to D0 (RX) and D2 (TX)
// Display startup message
lcd.setCursor(0, 0);
lcd.print("Water Quality");
lcd.setCursor(0, 1);
lcd.print("Monitoring");
delay(2000);
lcd.clear();
}
void loop() {
// Read temperature data
int tempValue = analogRead(tempPin);
float temperature = (tempValue / 1024.0) * 5.0 * 100.0;
// Read TDS data
int tdsValue = analogRead(tdsPin);
float tds = (tdsValue / 1024.0) * 5.0 * 1000.0;
// Display data on LCD
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("TDS: ");
lcd.print(tds);
lcd.print(" ppm");
// Send data via GSM module
Serial1.print("AT+CMGF=1\r"); // Set SMS mode to text
delay(1000);
Serial1.print("AT+CMGS=\"+1234567890\"\r"); // Replace with your phone number
delay(1000);
Serial1.print("Temp: ");
Serial1.print(temperature);
Serial1.print(" C, TDS: ");
Serial1.print(tds);
Serial1.print(" ppm");
delay(1000);
Serial1.write(26); // ASCII code for CTRL+Z to send SMS
delay(5000);
// Indicate status with LED
digitalWrite(ledPin, HIGH); // Turn on LED
delay(500);
digitalWrite(ledPin, LOW); // Turn off LED
// Wait before next reading
delay(10000);
}
This code initializes the necessary components, reads data from the sensors, displays the data on an LCD, sends the data via the GSM module, and indicates the status using an LED. The loop function continuously reads the sensor data, updates the display, sends the data, and toggles the LED status.