-
Notifications
You must be signed in to change notification settings - Fork 0
/
12_UNIR_AutoWaterBot_Ultimate_Version_v0.2.ino
139 lines (114 loc) · 4.45 KB
/
12_UNIR_AutoWaterBot_Ultimate_Version_v0.2.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* Project:
12 UNIR AutoWaterBot_Ultimate_Version_v0.2
Link:
Objective:
This code, developed by Jose Antonio, aims to evolve into a real irrigation project. This marks the first prototype.
It was developed during the N.A.V.E TECH UNIR Samsung Eletrônica da Amazônia LTDA
In Porto Velho - RO - Brazil, Course from November 2023 to April 2024.
The project was supervised by Professor Dr. Ciro José Egoavil Montero
(https://www.linkedin.com/in/ciro-j-egoavil-210b7a44/?originalSubdomain=br),
an Associate Professor III in Electrical Engineering at the Federal University of Rondônia (UNIR).
homePage : (https://navetech.unir.br/) EDITAL Nº 01/2023/NAVE-Tech-RO/UNIR
(https://ciroegoavil.unir.br/homepage) Engenharia Elétrica da Fundação Universidade Federal de Rondônia (UNIR):
Authors: MARQUES, Ana p., RIBEIRO, Antônio J.; OLIVEIRA, Gilberto O.; FREIRE, Angelina.
Hardware: Development Boards:
Arduino UNO: Microcontroller board based on the ATmega328P (datasheet)
Software: Tinkercad
Tinkercad is a free, easy-to-use app for 3D design, electronics, and coding.
Connections:
The COMPONENTS is connected to the microcontroller as follows:
Arduino UNO Rev.3 board:
Microcontroller PART
=============== ===
A0 SOIL MOISTURE SENSOR
A1 LU-5-R
A2 LU-5-R
D2 BUZZER
A3 Photoresistor
The LCD's Is connected to the microcontroller as follows:
Arduino UNO Rev.3 board:
Microcontroller LCD
=============== ===
A4 SDA
A5 SCL
Presentation: https://www.canva.com/design/DAF1mXAJyeE/Iv0X65QcByHk04a267UFZA/edit?utm_content=DAF1mXAJyeE&utm_campaign=designshare&utm_medium=link2&utm_source=sharebutton
Date: 20 Dez 2023
*/
// Incluindo bibliotecas necessárias
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
// Definindo pinos
const int sensorPin = A0;
const int alertPin = 2;
const int relayPowerPin = A3;
const int relayIrrigationPin = A2;
const int lightSensorPin = A1;
// Constantes
const int moistureThreshold = 500;
const int lightThreshold = 500;
const int alertDuration = 1000;
const int i2cAddr = 0x20;
LiquidCrystal_I2C lcd(i2cAddr, 16, 2);
void setup() {
// Definindo pinos para o LCD I2C
Wire.begin();
lcd.begin(16, 2);
lcd.print("Navetec Group 03");
lcd.setCursor(0, 1);
lcd.print("****************");
delay(2000);
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" GILBERTO JR");
delay(2000);
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("ANTONIO RIBEIRO");
delay(2000);
lcd.clear();
lcd.noCursor();
Serial.begin(9600);
pinMode(alertPin, OUTPUT);
pinMode(relayPowerPin, OUTPUT);
pinMode(relayIrrigationPin, OUTPUT);
}
void loop() {
int soilMoisture = analogRead(sensorPin);
int lightSensorValue = analogRead(lightSensorPin);
lcd.setCursor(0, 0);
lcd.print("Umidade do Solo: ");
lcd.setCursor(0, 1);
lcd.print(soilMoisture);
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Claridade do Ambi: ");
lcd.setCursor(0, 1);
lcd.print(lightSensorValue);
delay(2000);
lcd.clear();
if (soilMoisture < moistureThreshold && lightSensorValue < lightThreshold)
{
// Solo seco e há luz solar
digitalWrite(relayIrrigationPin, HIGH);
digitalWrite(relayPowerPin, HIGH);
lcd.setCursor(0, 0);
lcd.print("Irrigando...");
delay(6000);
lcd.clear();
delay(alertDuration);
digitalWrite(relayIrrigationPin, LOW);
}
else if(soilMoisture < moistureThreshold && lightSensorValue > lightThreshold)
{
digitalWrite(relayIrrigationPin, HIGH);
digitalWrite(relayPowerPin, LOW);
lcd.setCursor(0, 0);
lcd.print("Irrigando...");
delay(6000);
lcd.clear();
delay(alertDuration);
digitalWrite(relayIrrigationPin, LOW);
}
delay(3000);
}