This circuit is designed to monitor soil moisture and rain presence to control a water management system. It uses multiple sensors to detect environmental conditions and servos to actuate doors or valves based on the sensor readings. The system is controlled by three Arduino UNO microcontrollers, which are programmed to read sensor inputs and drive the servos accordingly. The circuit also includes OLED displays for user interface and feedback.
#include <U8g2lib.h>
#include <Servo.h>
const int waterSensor1Pin = A0;
const int soilMoisture1Pin = A1;
const int waterSensor2pin = A2;
const int soilMoisture2pin = A3;
const int waterSensor3pin = 3;
const int soilMoisture3pin = 4;
const int ServoPin1 = 6;
const int ServoPin2 = 9;
const int ServoPin3 = 5;
int waterSensor3Value = 1;
int soilMoisture3Value = 1;
Servo Fservo;
Servo Sservo;
Servo Tservo;
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/U8X8_PIN_NONE);
int R1limite = 800;
int R2limite = 175;
int S1limite = 450;
int S2limite = 450;
void setup() {
Fservo.attach(ServoPin1);
Sservo.attach(ServoPin2);
Tservo.attach(ServoPin3);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
u8g2.begin();
u8g2.setFont(u8g2_font_ncenB08_tr);
u8g2.drawStr(17, 10, "Water Controll");
u8g2.sendBuffer();
u8g2.setFont(u8g2_font_ncenB08_tr);
u8g2.drawStr(0, 20, "Automation System");
u8g2.sendBuffer();
u8g2.setFont(u8g2_font_ncenB08_tr);
u8g2.drawStr(30, 40, "Made By");
u8g2.sendBuffer();
u8g2.setFont(u8g2_font_ncenB08_tr);
u8g2.drawStr(0, 60, "CHAMIDU HARSHANA");
u8g2.sendBuffer();
delay(4000);
u8g2.clearBuffer();
u8g2.drawStr(37, 20, "System");
u8g2.sendBuffer();
u8g2.setFont(u8g2_font_ncenB08_tr);
u8g2.drawStr(20, 40, "Auto Mode On");
u8g2.sendBuffer();
delay(3000);
}
void loop() {
int waterSensor1Value = analogRead(waterSensor1Pin);
int soilMoisture1Value = analogRead(soilMoisture1Pin);
int waterSensor2Value = analogRead(waterSensor2pin);
int soilMoisture2Value = analogRead(soilMoisture2pin);
waterSensor3Value = digitalRead(waterSensor3pin);
soilMoisture3Value = digitalRead(soilMoisture3pin);
u8g2.clearBuffer();
// Various conditions to control servos and display messages based on sensor readings
// ...
u8g2.sendBuffer();
delay(100);
}
void setup() {
// Secondary controllers may have additional setup code here.
}
void loop() {
// Secondary controllers may have additional loop code here.
}
Note: The secondary Arduino UNOs are not provided with specific code in the input. They are likely intended to be programmed with similar or complementary logic to the main controller.