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

ESP32-Based Water Quality Monitoring System with SIM900A Communication

View and Edit Project In Cirkit DesignerImage of ESP32-Based Water Quality Monitoring System with SIM900A Communication

Circuit Documentation

Summary

This circuit is designed to monitor water quality using various sensors connected to an ESP32 Devkit V1. The sensors include a DS18B20 temperature sensor, a turbidity sensor, a water level sensor, a PH meter, an MQ135 air quality sensor, and a SIM900A module for communication. The ESP32 reads data from these sensors and can communicate the results via the SIM900A module.

Component List

  1. ESP32 Devkit V1

    • Description: A microcontroller with Wi-Fi and Bluetooth capabilities.
    • Pins: 3V3, GND, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, VIN
  2. DS18B20 Temperature Sensor

    • Description: A digital temperature sensor.
    • Pins: GND, VCC, OUT
  3. Turbidity Sensor

    • Description: A sensor to measure the turbidity (cloudiness) of water.
    • Pins: OUT, VCC, GND
  4. Water Level Sensor

    • Description: A sensor to measure the water level.
    • Pins: SIG, VCC, GND
  5. SIM900A

    • Description: A GSM/GPRS module for communication.
    • Pins: GND, DB9-3 (RXD), DB9-2 (TXD), 5V, 3VR, 5VR, 3VT, 5VT, VCC, Ring, RESTART, RESET, STATUS
  6. MQ135

    • Description: An air quality sensor.
    • Pins: VCC, GND, A0, D0
  7. PH Meter

    • Description: A sensor to measure the pH level of water.
    • Pins: Signal, VCC, GND

Wiring Details

ESP32 Devkit V1

DS18B20 Temperature Sensor

Turbidity Sensor

Water Level Sensor

SIM900A

MQ135

PH Meter

Code Documentation

/*
 * This Arduino Sketch is designed to check water quality using various sensors
 * connected to an ESP32 Devkit V1. The sensors include a DS18B20 temperature
 * sensor, a turbidity sensor, a water level sensor, a PH meter, an MQ135 air
 * quality sensor, and a SIM900A module for communication.
 */

#include <OneWire.h>
#include <DallasTemperature.h>

// Pin definitions
#define DS18B20_PIN 13
#define TURBIDITY_OUT_PIN 32
#define WATER_LEVEL_SIG_PIN 27
#define PH_SIGNAL_PIN 39
#define MQ135_A0_PIN 15
#define MQ135_D0_PIN 2

// OneWire and DallasTemperature instances
OneWire oneWire(DS18B20_PIN);
DallasTemperature sensors(&oneWire);

void setup() {
  // Initialize serial communication
  Serial.begin(115200);

  // Initialize sensors
  sensors.begin();
  pinMode(TURBIDITY_OUT_PIN, INPUT);
  pinMode(WATER_LEVEL_SIG_PIN, INPUT);
  pinMode(PH_SIGNAL_PIN, INPUT);
  pinMode(MQ135_A0_PIN, INPUT);
  pinMode(MQ135_D0_PIN, INPUT);
}

void loop() {
  // Read temperature from DS18B20
  sensors.requestTemperatures();
  float temperature = sensors.getTempCByIndex(0);
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");

  // Read turbidity sensor
  int turbidity = analogRead(TURBIDITY_OUT_PIN);
  Serial.print("Turbidity: ");
  Serial.println(turbidity);

  // Read water level sensor
  int waterLevel = analogRead(WATER_LEVEL_SIG_PIN);
  Serial.print("Water Level: ");
  Serial.println(waterLevel);

  // Read PH meter
  int phValue = analogRead(PH_SIGNAL_PIN);
  Serial.print("PH Value: ");
  Serial.println(phValue);

  // Read MQ135 sensor
  int mq135A0 = analogRead(MQ135_A0_PIN);
  int mq135D0 = digitalRead(MQ135_D0_PIN);
  Serial.print("MQ135 A0: ");
  Serial.println(mq135A0);
  Serial.print("MQ135 D0: ");
  Serial.println(mq135D0);

  // Delay before next reading
  delay(2000);
}

This code initializes the sensors and reads data from them in a loop, printing the results to the serial monitor. The delay of 2000 milliseconds ensures that the readings are taken at regular intervals.