

The circuit in question is designed to monitor and control a water system, featuring sensors for pH, turbidity, temperature, and water level. It includes an Arduino Nano as the central microcontroller, interfaced with various sensors and output devices such as a relay module, a buzzer, an OLED display, a water pump, and a pneumatic solenoid valve. The system reads sensor data, displays values on the OLED, and activates the pump and valve based on predefined threshold values.
GND connected to the common ground netD2 connected to DS18B20 Temperature Sensor OUTD3 connected to Relay Module (Solenoid Valve) IND4 connected to Relay Module (Pump) IND5 connected to Buzzer PIN5V connected to the common 5V netA5 connected to OLED SCLA4 connected to OLED SDAA2 connected to Water Level Sensor SIGA1 connected to Turbidity Module OUTA0 connected to pH Sensor PoVCC connected to the common 5V netG1 and G2 connected to the common ground netPo connected to Arduino Nano A0VCC connected to the common 5V netGND connected to the common ground netOUT connected to Arduino Nano A1VCC connected to the common 5V netGND connected to the common ground netOUT connected to Arduino Nano D2VCC connected to the common 5V netGND connected to the common ground netSIG connected to Arduino Nano A2VCC connected to 12V Battery (+)GND connected to Relay Module (Pump) N.O.VCC connected to the common 5V netGND connected to the common ground netSCL connected to Arduino Nano A5SDA connected to Arduino Nano A4VCC connected to Relay Module (Solenoid Valve) N.O.GND connected to 12V Battery (-)+ connected to Water Pump VCC and Relay Module (Solenoid Valve) COM- connected to Pneumatic Solenoid Valve GND and Relay Module (Pump) COMVCC+ connected to the common 5V netVCC- (GND) connected to the common ground netIN connected to Arduino Nano D3N.O. connected to Pneumatic Solenoid Valve VCCCOM connected to 12V Battery (+)VCC+ connected to the common 5V netVCC- (GND) connected to the common ground netIN connected to Arduino Nano D4N.O. connected to Water Pump GNDCOM connected to 12V Battery (-)PIN connected to Arduino Nano D5GND connected to the common ground net#include <Wire.h> // For OLED Display
#include <Adafruit_GFX.h> // For OLED Display
#include <Adafruit_SSD1306.h> // For OLED Display
#include <OneWire.h> // For DS18B20 Temperature Sensor
#include <DallasTemperature.h> // For DS18B20 Temperature Sensor
#define SCREEN_WIDTH 128 // OLED display width
#define SCREEN_HEIGHT 64 // OLED display height
#define OLED_RESET -1 // Reset pin (not used)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// Pin Definitions
#define PH_SENSOR_PIN A0 // pH Sensor connected to A0
#define TURBIDITY_SENSOR_PIN A1 // Turbidity Sensor connected to A1
#define WATER_LEVEL_SENSOR_PIN A2 // Water Level Sensor connected to A2
#define TEMP_SENSOR_PIN 2 // DS18B20 Temperature Sensor on digital pin 2
#define RELAY_SOLENOID_PIN 3 // Relay for Solenoid Valve on digital pin 3
#define RELAY_PUMP_PIN 4 // Relay for Pump on digital pin 4
#define BUZZER_PIN 5 // Buzzer connected to digital pin 5
// DS18B20 Sensor Setup
OneWire oneWire(TEMP_SENSOR_PIN);
DallasTemperature sensors(&oneWire);
// Threshold values (You can adjust these based on your requirements)
float pHThresholdLow = 6.5; // Lower pH threshold
float pHThresholdHigh = 8.0; // Upper pH threshold
int turbidityThreshold = 300; // Turbidity threshold (analog value)
int waterLevelThreshold = 500; // Water level threshold (analog value)
// Variables
float pHValue;
int turbidityValue;
int waterLevelValue;
float temperatureValue;
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
// Initialize the OLED display
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Initialize OLED with I2C address 0x3C
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Loop forever if the display initialization fails
}
// Clear the display
display.clearDisplay();
display.display();
// Initialize the DS18B20 temperature sensor
sensors.begin();
// Set pin modes for the relay, buzzer, etc.
pinMode(RELAY_SOLENOID_PIN, OUTPUT);
pinMode(RELAY_PUMP_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
// Turn off relays and buzzer at startup
digitalWrite(RELAY_SOLENOID_PIN, LOW);
digitalWrite(RELAY_PUMP_PIN, LOW);
digitalWrite(BUZZER_PIN, LOW);
}
void loop() {
// Read sensor values
pHValue = analogRead(PH_SENSOR_PIN);
turbidityValue = analogRead(TURBIDITY_SENSOR_PIN);
waterLevelValue = analogRead(WATER_LEVEL_SENSOR_PIN);
// Get temperature readings
sensors.requestTemperatures();
temperatureValue = sensors.getTempCByIndex(0);
// Display readings on the OLED
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print("pH: ");
display.println(pHValue);
display.print("Turbidity: ");
display.println(turbidityValue);
display.print("Water Level: ");
display.println(waterLevelValue);
display.print("Temperature: ");
display.println(temperatureValue);
display.display();
// Control relays and buzzer based on thresholds
if (pHValue < pHThresholdLow || pHValue > pHThresholdHigh || turbidityValue > turbidityThreshold) {
digitalWrite(RELAY_SOLENOID_PIN, HIGH); // Open solenoid valve
digitalWrite(BUZZER_PIN, HIGH); // Turn on buz