Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Spring_Project_SE1819_G4

The document outlines the contributions of students in a project related to an IoT irrigation system, detailing their specific tasks and responsibilities. It includes schematics for both transmitter and receiver components, along with Arduino and ESP32 code for sensor integration and data transmission. Additionally, it mentions the use of various sensors and components, as well as links to project resources and a video demo.

Uploaded by

aen75687
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Spring_Project_SE1819_G4

The document outlines the contributions of students in a project related to an IoT irrigation system, detailing their specific tasks and responsibilities. It includes schematics for both transmitter and receiver components, along with Arduino and ESP32 code for sensor integration and data transmission. Additionally, it mentions the use of various sensors and components, as well as links to project resources and a video demo.

Uploaded by

aen75687
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Class SE1819 Group 04 Contribution

# Student ID Student Name Task (0-100%)


1 SE183415 Trịnh Gia Huy Planning and wiring 25%
2 SE192542 Lê Trần Gia Huy ESP32 (receive node) coding 25%
3 SE192751 Thái Thiện Nhân Arduino (transmit node) coding 25%
4 SE192672 Đồng Xuân Bảo Long User interface coding, SQL database 25%
Total 100%

IOT102t: PROGRESS TEST 1


1. Description

2. Block diagram

1
3. Schematic of design (Wiring table)

Schematic of transmitter (main controller: Arduino UNO)


Yl-38 (Soil moisture sensor)
Arduino UNO Yl-38
5V VCC
GND GND
A0 AO
D3 DO

DHT11 (Temperature and Humidity sensor)


Arduino UNO DHT11
5V VCC
GND GND
D2 DATA

LoRa SX1278 (Wireless communication)


Arduino UNO LoRa SX1278
3.3V VCC
GND GND
D12 MISO
D11 MOSI
D13 SCK
D10 NSS (CS)
D9 RST
D8 DIO0

2
Servo SG90 (Water valve)
Arduino UNO Servo Motor
5V VCC
GND GND
D6 SIGNAL

LCD Parallel (Outside data-indicator)


Arduino UNO LCD Parallel
GND VSS
5V VDD
D7 RS
GND RW
A1 E
D5 D4
D4 D5
A2 D6
A3 D7
5V (via 330Ohm resistor) A
GND (via 1kOhm resistor) V0
GND K

MQ-7 (CO gas sensor)


Arduino UNO MQ-7
3.3V 3.3V
GND GND
A4 AO

MQ-135 (Atmosphere quality sensor)


Arduino UNO MQ-135
3.3V 3.3V
GND GND
A5 AO

3
Schematic of receiver (main controller: ESP32)

LoRa SX1278 (Wireless communication)


ESP32 LoRa SX1278
3.3V 3.3V
GND GND
19 MISO
23 MOSI
18 SCK
5 NSS (CS)
14 RST
2 DIO0

OLED 12864 I2C Communication (Data visualization)


ESP32 OLED 12864 I2C
3.3V 3.3V
GND GND
21 SDA
22 SCL

4
4. Code

Arduino UNO code (transmitter)


#include <Servo.h>
#include <SPI.h>
#include <LoRa.h>
#include <LiquidCrystal.h>
#include <DHT.h>

// Pin definitions
#define YL38_ANALOG A0
#define YL38_DIGITAL 3
#define SERVO_PIN 6
#define LORA_SS 10
#define LORA_RST 9
#define LORA_DIO0 8
#define DHTPIN 2
#define DHTTYPE DHT11
#define MQ7_PIN A4
#define MQ135_PIN A5

// Updated LCD pin definitions


#define RS 7
#define E A1 // Enable moved to A1
#define D4 5
#define D5 4
#define D6 A2 // Move Data 6 to A2
#define D7 A3 // Move Data 7 to A3

// LCD pin configuration


LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
Servo waterValve;
DHT dht(DHTPIN, DHTTYPE);

// Threshold for rain detection


int rainThreshold = 500;
int displayState = 0;

void setup() {
Serial.begin(115200);

// Initialize LoRa
LoRa.setPins(LORA_SS, LORA_RST, LORA_DIO0);
if (!LoRa.begin(433E6)) { // Adjust frequency as needed

5
Serial.println("LoRa init failed!");
while (1);
}
Serial.println("LoRa init succeeded.");

// Initialize LCD
lcd.begin(16, 2);
lcd.print("Irrigation Sys");

// Initialize servo
waterValve.attach(SERVO_PIN);
waterValve.write(0); // Default closed position

// Initialize DHT sensor


dht.begin();

pinMode(YL38_DIGITAL, INPUT);
}

void loop() {
int rainAnalog = analogRead(YL38_ANALOG);
bool isRaining = rainAnalog > rainThreshold;
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
int mq7Value = analogRead(MQ7_PIN);
int mq135Value = analogRead(MQ135_PIN);

// Cycle LCD display


lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Rain: ");
lcd.print(rainAnalog);
delay(2000);

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print(" C");
delay(2000);

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Humi: ");

6
lcd.print(humidity);
lcd.print("%");
delay(2000);

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("MQ7: ");
lcd.print(mq7Value);
delay(2000);

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("MQ135: ");
lcd.print(mq135Value);
delay(2000);

if (isRaining) {
closeValve();
} else {
openValveWithInterval();
}

// Send data via LoRa


LoRa.beginPacket();
LoRa.print("Rain: ");
LoRa.print(rainAnalog);
LoRa.print(", Temp: ");
LoRa.print(temperature);
LoRa.print(", Hum: ");
LoRa.print(humidity);
LoRa.print(", MQ7: ");
LoRa.print(mq7Value);
LoRa.print(", MQ135: ");
LoRa.print(mq135Value);
LoRa.endPacket();
}

void closeValve() {
waterValve.write(0); // Close valve
}

void openValveWithInterval() {
waterValve.write(90); // Open valve
delay(5000); // Keep it open for 5 seconds

7
waterValve.write(0); // Close valve
delay(5000); // Wait 5 seconds before checking again
}

ESP32 code (receiver / wifi)


User interface code (Java)
It was uploaded to Google Drive, using Java IDE (NetBeans 8.2, …) to run

5. Tinkercad link (if any)

(Does not included)

6. Video clip (Google Drive)

Link video demo

Link folder project

You might also like