Introduction: Automation of Greenhouse Using Temperature and Humidity Sensor

About: I am an Agricultural Engineering Scientist in Division of Agricultural Engineering, ICAR-IARI New Delhi, India

A green house is a framed or inflated structure covered with transparent or translucent material (glass, plastic sheeting, Plastic film) in which fruit/vegetable/ flower crops can be grow under the controlled climate condition or partially controlled environment. The greenhouse effect is a process that occurs when gases in Earth's atmosphere trap the Sun's heat. This process makes Earth much warmer than it would be without an atmosphere. A greenhouse stays warm inside, even during the winter due to greenhouse effect. In daytime, sunlight radiation traps into the greenhouse and warms the plants and air inside. At nighttime, it's colder outside, but the greenhouse stays pretty warm inside. Greenhouse environment is suitable for cultivating the crops around the year to meet the market demand. Temperature beyond the 35 oC within the greenhouse is not suitable for the plant. Temperature inside the greenhouse in summer and winter season higher and lower respectively from the optimum growth temperature of crops. So temperature should be controlled regularly for optimum growth of plants. Ventilation and fogging are required for decreasing the temperature similarly heater, high wattage bulb for increasing the temperature inside the greenhouse for maintaining optimum temperature for proper plant growth throughout the day and night time. The average range of humidity is 50-80 %. if the desire humidity is not available, then it can be achieved by using cooling system like exhaust fan, cooling pad and fogging system. Different Optimum temperature and humidity are required for optimum growth and higher production of high value cash crops. Therefore, Automation of Greenhouse for controlling/monitoring the temperature and humidity inside the greenhouse are required for higher production. Keeping the above point in mind following objective were selected.

Objectives:

1. To Study the AC Relay, temperature humidity sensor for controlling the climate inside the greenhouse

2. To operate the Exhaust fan and motor of fogger/mist for maintaining the optimum temperature and humidity inside the Greenhouse

Before crossing the maximum limit and After crossing the maximum limit are shown in these fig.

Step 1: Temperature Humidity Sensor

DHT11 and DHT22 are popularly available sensor in market for measuring the temperature and humidity. Thermocouple, TMP100, LM75, DS18820, SHT15, LM35DZ, TPA81, D6T are other temperature measuring sensor. Specification of DHT11 and DHT22 are given below

Step 2: Working Principle of DHT Sensor

For measuring humidity, it uses the humidity sensing component which has two electrodes with moisture holding substrate between them which is shown in Fig. 2. when humidity changes, the electrical conductivity of the substrate changes or resistance between these electrodes changes. This change in resistance is measured and processed by the IC which makes it ready to be read by a microcontroller.

A thermistor is actually a variable resistor that changes its resistance with change of the temperature. These sensors are made by sintering of semi conductive materials such as ceramics or polymers in order to provide larger changes in the resistance with just small changes in temperature. The term “NTC” means “Negative Temperature Coefficient”, which means that the resistance decreases with increase of the temperature.

Step 3: Relay

A relay is an electromagnetic switch operated by a relatively small electric current that can turn on or off a much larger electric current. The heart of a relay is an electromagnet (a coil of wire that becomes a temporary magnet when electricity flows through it. When no voltage is applied to the core, it cannot generate any magnetic field and it doesn’t act as a magnet. Therefore, it cannot attract the movable armature. When sufficient voltage is applied to the core it starts to create a magnetic field around it and acts as a magnet. Since the movable armature is placed within its range, it gets attracted to that magnetic field created by the core, thus the position of the armature is being altered.

Step 4: Working Principal of Automation of Greenhouse

When the temperature of greenhouse higher the optimum temperature which is predefined in the programming code (say 30 0C). Microcontroller direct to this signal (HIGH) to the relay to switch on the exhaust fan(in place of exhaust fan, bulb was used for experiment). Similarly, in case of lower humidity, microcontroller direct to this signal (HIGH) to the relay to switch on the motor to start the fogging/mist system (in place of motor, bulb was used for experiment). Schematic electronics diagram of greenhouse automation system is shown in Fig. 6.

Step 5: Circuit Diagram of Automated Greenhouse

Step 6: Programming Code

Arduino IDE was used for writing and uploading the programming code in the selected microcontroller as Arduino Mega 2560. 12 V battery was used for powering the microcontroller, AC Relay and DHT22. Buck converter 12 V to 5 Volt was used for step down the voltage and used for sensor and microcontroller.

Explanation of programming Code

The first step is to include the DHT22 Sensor library in Arduino IDE. This library may be downloaded from https://github.com/adafruit/DHT-sensor-library

#include

Next, DHT data output pin to Arduino connection pin (digital pin 2) and output pin of Arduino to relay connections pins were defined. It was also set the DHT sensor type. In my case, DHT22 sensor was used. Next, DHT class with DHT connection and type was defined. For this dht(DHTPIN, DHTTYPE) function was used.

#define DHTPIN 2

int bulb = 3;

int motor = 8;

#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

Maximum humidity and temperature limit was defined for operating the climate control devices in the greenhouse such as exhaust fan and motor for humidifier.

int maxHum = 65;

int maxTemp = 30.00;

Under the void setup() function, one time program is executed. Serial communication at a baud rate of 9600 was defined and make sure the serial monitor is also set to 9600 at the time of looking the sensor data in Arduino IDE compiler. Sensor was initialized with dht.begin(). Output pin command (pinMode(motor, OUTPUT); and pinMode(bulb, OUTPUT);) of Arduino microcontroller for motor and bulb as output of microcontroller was defined. 100 millisecond delay was given in this setup() programming segment for stabilizing the microcontroller.

void setup() {

Serial.begin(9600);

dht.begin();

pinMode(motor, OUTPUT);

pinMode(bulb, OUTPUT);

delay(100);

}

The loop() section of the code was started with a delay of 2000 milliseconds. This delay command (delay(2000);)will give the sensor some time to do the readings. Local variable as “h” and “t” of the float type for storing the humidity and temperature data was defined under loop() function. readHumidity() and readTemperature() are inbuilt command for reading the humidity in % and temperature in degree Celsius in the DHT library.

float h = dht.readHumidity();

float t = dht.readTemperature();

Next, there is a small section of code that checks if the sensor is connected correctly and is returning a reading. If not, an error message will be printed on the Serial Monitor.

if (isnan(h) || isnan(t)) {

Serial.println("Failed");

return;

}

after reading and storing the humidity and temperature data in the “h” and “t” variable, under if condition, Motor for operating the fogger for increasing the humidity was started, if humidity of greenhouse is less than the predefined maximum humidity (65%) otherwise motor will remain off.

if(h

digitalWrite(motor, HIGH);

}

else{

digitalWrite(motor, LOW);

}

Similarly, if the temperature of greenhouse is lower than the predefined temperature (int maxTemp = 25.00;) than bulb will be ON otherwise bulb will remain off.

if(t> maxTemp) {

digitalWrite(bulb, LOW);

}

else {

digitalWrite(bulb, HIGH);

}

Serial.print(h); and Serial.println(t); command was used for print the humidity and temperature data on serial monitor of Arduino IDE complier. Serial.print("\t"); was used for separating the data with one-tab spacing.

Step 7: Component Required

1. Arduino Mega 2560

2. AC Relay

3. DTH22

4. High wattage bulb

5. AC Motor

6. AC source

7. Wires

8. Plastic box for storing the Electronics circuit and battery

Step 8:

Step 9: Complete Programming Code

#include "DHT.h"

#define DHTPIN 2

int bulb = 3;

int motor = 8;

#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

int maxHum = 65;

int maxTemp = 30.00;

void setup() {

// put your setup code here, to run once:

Serial.begin(9600);

dht.begin();

pinMode(motor, OUTPUT);

pinMode(bulb, OUTPUT);

delay(100);

}

void loop() {

delay(2000);

float h = dht.readHumidity();

float t = dht.readTemperature();

if(isnan(h) || isnan(t)) {

Serial.println("Failed");

return;

}

if(h

digitalWrite(motor, HIGH);

}

else{

digitalWrite(motor, LOW);

}

if(t< maxTemp) {

digitalWrite(bulb, HIGH);

}

else {

digitalWrite(bulb, LOW);

}

Serial.print(h);

Serial.print("\t");

Serial.println(t);

}

Step 10: Serial Data Before or After the Crossing the Defined Limit of Humidity and Temperature