Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino and ESP8266-Based Water Quality Monitoring System with LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino and ESP8266-Based Water Quality Monitoring System with LCD Display

Circuit Documentation

Summary

This circuit is designed for water quality monitoring, utilizing an Arduino UNO and an ESP8266 for data acquisition and wireless communication. The system measures Total Dissolved Solids (TDS) and pH levels using respective sensors and displays the data on an LCD. The data is also transmitted to a web server via the ESP8266.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. LCD 16x2 (Wokwi Compatible)

    • Description: 16x2 character LCD display.
    • Pins: VSS, VDD, V0, RS, RW, E, D0, D1, D2, D3, D4, D5, D6, D7, A, K
  3. Resistor (1k Ohms)

    • Description: Resistor with a resistance of 1000 Ohms.
    • Pins: pin1, pin2
  4. esp8266

    • Description: Wi-Fi module for wireless communication.
    • Pins: 3V, G, D8, D7, D6, D5, D4, D3, D2, D1, D0, A0, S3, S2, S1, SC, S0, SK, EN, VIN, RST, VU
  5. TDS Sensor

    • Description: Sensor for measuring Total Dissolved Solids in water.
    • Pins: AI, GND, 5V
  6. PH Meter

    • Description: Sensor for measuring pH levels in water.
    • Pins: Signal, VCC, GND

Wiring Details

Arduino UNO

LCD 16x2 (Wokwi Compatible)

esp8266

Resistor (1k Ohms)

TDS Sensor

PH Meter

Code Documentation

Arduino UNO Code

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  Serial.begin(9600); // Communicate with ESP8266
  lcd.begin(16, 2);
  lcd.print("Initializing...");
}

void loop() {
  // Read and map TDS data
  int TDS = analogRead(A0);
  int TDS1 = map(TDS, 0, 1023, 0, 2000);

  // Read and map pH data
  int PH = analogRead(A1);
  int PH1 = map(PH, 0, 1023, 0, 14);

  // Display on LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("TDS: ");
  lcd.print(TDS1);
  lcd.setCursor(0, 1);
  lcd.print("pH: ");
  lcd.print(PH1);

  // Send data to ESP8266
  String data = "TDS:" + String(TDS1) + ";PH:" + String(PH1);
  Serial.println(data);

  delay(1000);
}

ESP8266 Code

#include <ESP8266WiFi.h>

const char* ssid = "Your_SSID";       // Replace with your Wi-Fi SSID
const char* password = "Your_PASSWORD"; // Replace with your Wi-Fi Password

WiFiServer server(80);
String inputData = ""; // Data received from Arduino

void setup() {
  Serial.begin(9600); // Communicate with Arduino UNO
  WiFi.begin(ssid, password);
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("Wi-Fi Connected");
  Serial.print("IP Address: ");
  Serial.println(WiFi.localIP());

  server.begin();
}

void loop() {
  // Receive data from Arduino UNO
  while (Serial.available()) {
    char c = Serial.read();
    inputData += c;
    if (c == '\n') break;
  }

  // Serve data via Wi-Fi
  WiFiClient client = server.available();
  if (client) {
    String header = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";
    String webpage = "<!DOCTYPE HTML><html><body>";
    webpage += "<h1>Water Monitoring</h1>";
    webpage += "<p>" + inputData + "</p>";
    webpage += "</body></html>";
    client.print(header + webpage);
    delay(10);
    client.stop();
  }

  // Clear input data after processing
  inputData = "";
}

This documentation provides a comprehensive overview of the circuit, including the components used, their wiring details, and the code running on the microcontrollers.