This circuit is designed to monitor and control various environmental parameters such as pH, turbidity, water level, and temperature. It uses an Arduino Nano microcontroller to read sensor data and control actuators like a water pump and a pneumatic solenoid valve. The data is displayed on an OLED screen, and alerts are provided via a buzzer.
Arduino Nano
pH Sensor (ph4502c)
Turbidity Module
DS18B20 Temperature Sensor
Water Level Sensor
Water Pump
OLED 1.3" Display
12V Pneumatic Solenoid Valve
Battery 12V
1 Channel 5V Relay Module
Buzzer
GND connected to:
5V connected to:
D2 connected to:
D3 connected to:
D4 connected to:
D5 connected to:
A5 connected to:
A4 connected to:
A2 connected to:
A1 connected to:
A0 connected to:
GND connected to:
VCC connected to:
OUT connected to:
GND connected to:
VCC connected to:
OUT connected to:
GND connected to:
VCC connected to:
SIG connected to:
VCC connected to:
GND connected to:
GND connected to:
VCC connected to:
SCL connected to:
SDA connected to:
VCC connected to:
GND connected to:
+ connected to:
- connected to:
VCC+ connected to:
VCC- (GND) connected to:
IN connected to:
N.O. connected to:
COM connected to:
PIN connected to:
GND connected to:
#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