Concept

This concept is to deal with the effects of climate change on our planet and how it affects agriculture. It is immediately applicable to the optimization of agricultural production in greenhouses and helps to slow the phenomenon of climate change by saving water and energy.
A complete functional unit for monitoring and controlling the internal environmental conditions of a greenhouse was implemented for this purpose using a microcontroller (Arduino).

Technique

BOM

Schematics

Code

#include <SimpleDHT.h>

// for DHT11,
// VCC: 5V or 3V
// GND: GND
// DATA: 2
int pinDHT11 = 4;
int LedPin1 = 10;
int sensorValue = 0;
int sensorPin = A0;
int LedPin2 = 11;
int TrigPin = 2; // Arduino pin connected to Ultrasonic Sensor’s TRIG pin
int EchoPin = 3; // Arduino pin connected to Ultrasonic Sensor’s ECHO pin
int LedPin3 = 9; // Arduino pin connected to LED’s pin
int DISTANCE_THRESHOLD = 50; // centimeters
SimpleDHT11 dht11(pinDHT11);

float duration_us, distance_cm;

void setup() {
Serial.begin(115200);
pinMode(LedPin1, OUTPUT);
pinMode(LedPin2, OUTPUT);
pinMode(TrigPin, OUTPUT); // set arduino pin to output mode
pinMode(EchoPin, INPUT); // set arduino pin to input mode
pinMode(LedPin3, OUTPUT); // set arduino pin to output mode
}

void loop() {
// start working…
Serial.println(“=================================”);
Serial.println(“Sample DHT11…”);

// read without samples.
byte temperature = 0;
byte humidity = 0;
int err = SimpleDHTErrSuccess;
if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess)
{
Serial.print(“Read DHT11 failed, err=”); Serial.print(SimpleDHTErrCode(err));
Serial.print(“,”); Serial.println(SimpleDHTErrDuration(err)); delay(1000);
return;
}

Serial.print(“Sample OK: “);
Serial.print((int)temperature); Serial.print(” *C, “);
Serial.print((int)humidity); Serial.println(” H”);

if((int)temperature<= 50)
{
digitalWrite(LedPin1, HIGH);
}
else{
digitalWrite(LedPin1, LOW);
}

// DHT11 sampling rate is 1HZ.
delay(1500);
sensorValue = analogRead(sensorPin);
int mapSoil = map(sensorValue, 200, 1023, 0, 100);

int ConstrainSoil = constrain(mapSoil, 0, 100);
if((int)sensorValue<= 50)
{
digitalWrite(LedPin2, HIGH);
}
else
{
digitalWrite(LedPin2, LOW);
}

Serial.print(“soil Humidity is:”);
Serial.println(mapSoil);
delay(500);

// generate 10-microsecond pulse to TRIG pin
digitalWrite(TrigPin, HIGH);
delayMicroseconds(10);
digitalWrite(TrigPin, LOW);

// measure duration of pulse from ECHO pin
duration_us = pulseIn(EchoPin, HIGH);
// calculate the distance
distance_cm = 0.017 * duration_us;

if(distance_cm < DISTANCE_THRESHOLD)
digitalWrite(LedPin3, HIGH); // turn on LED
else
digitalWrite(LedPin3, LOW); // turn off LED

// print the value to Serial Monitor
Serial.print(“distance: “);
Serial.print(distance_cm);
Serial.println(” cm”);
delay(500);
}

Automating a Greenhouse is a project of IAAC, Institute for Advanced Architecture of Catalonia developed at Master in Advanced Architecture (MAA01) 2021/22 by Student: Vishakha Pathak and faculty: Cristian Rizzuti, faculty assistant: Arman Najari.

Video

<p>

</p>