You are on page 1of 7

Research Note

on

Design data acquisition system for green house control


using ARM 7 microcontrollers.
Submitted By

Mohini P. Rajput
mohini.rajput9953@gmail.com

Under the Guidance of

Prof. Sirsat
Assistant Professor

Pravara Rural Education Society's

Pravara Rural Engineering College, Loni


Tal- Rahata, Dist- Ahmednagar, 413736, Maharashtra
May, 2019.
Design data acquisition system for green house control
using ARM 7 microcontrollers.
Introduction
In greenhouses, many parameter measurements are required to monitor and
control for the good quality and productivity of plants. But to get the desired
results there are some very important factors which come into play like
Temperature, Humidity, Light and Water, which are necessary for a better plant
growth.

A. Interfacing DHT11/DHT22 Humidity and Temperature Sensor with


MCU
DHT11/DHT22 are pretty well known sensors for sensing relative humidity
and Temperature. These are digital sensors are based on a custom protocol which
use a single wire/bus for communication. The primary difference between DHT11
and DHT22 is that, DHT22 has higher resolution and is more accurate as compared
to DHT11. Other than that, the pinout and programming is same for both. In this
tutorial we will go through basics of protocol/communication process for DHTxx
sensors.
Specifications & DHT11 Vs DHT22:
Parameter DHT11 DHT22
Temperature measurement range 0 to 50 Deg.C -40 to 80 Deg.C
Temperature Accuracy +- 1 to 2 Deg.C +- 0.5 Deg.C
Relative Humidity Range 30% to 90% 0% to 100%
Relative Humidity Accuracy +- 4% to 5% +-2 to 5%
Operating Voltage 3.3V to 5V 3.3V to 5V
Resolution 8 bits 16 bits
Sampling period >=1 sec >=2 sec
DHT22 & DHT11 Pinout:

Fig 1 : DHT22 & DHT11 Pinout


The DATA wire used for communication between microcontroller and
DHT11/DHT22 is pulled HIGH using a 4.7K or 10K pull-up resistor. This is to
bring the bus in an IDLE state when there is no communication taking place. A
continuous HIGH on the line denote an IDLE state. The microcontroller acts as the
bus master and hence is responsible for initiating communication (i.e. Read).
DHTxx Humidity and Temperature sensor always remain as slave and responds
with data when MCU asks for it. The protocol used for communication is simple
and can be summarized as follows:

Fig2: DHTxx Protocol


Communication Process:

1. When the Line is IDLE the microcontroller pulls it to a LOW for 18ms.
2. After this MCU pulls it HIGH for around 20 to 40us.
3. DHTxx will detect it as a START from the MCU and responds by pulling
the line LOW for 80us.
4. Next, DHTxx will pull it HIGH for 80us which indicates that it is ready to
send data or “get ready”.
5. Next it will send 40 bits of Data. Each bit starts with a 50us LOW followed
by 26-28us for a “0” or 70us for a “1”.
6. After communication ends, the Line is pulled HIGH by the pull-up resistor
and enters IDLE state.
DHTxx Data Format
When Humidity and Temperature sensor sends data, it sends the MSB first.
The 40bits of data is divided into 5 bytes. For DHT11 sensor 2nd and 4th byte is
always Zero. The significance of these bytes is as follows:

1. 1st Byte: Relative Humidity Integral Data in % (Integer Part)


2. 2nd Byte: Relative Humidity Decimal Data in % (Fractional Part) – Zero for
DHT11
3. 3rd Byte: Temperature Integral in Degree Celsius (Integer Part)
4. 4th Byte: Temperature in Decimal Data in % (Fractional Part) – Zero for
DHT11
5. 5th Byte: Checksum (Last 8 bits of {1st Byte + 2nd Byte + 3rd Byte+ 4th
Byte})

Fig 3: DHTxx Data Format

B. Interfacing LDR with LPC2148


Light Dependent Resistor (i.e. LDR for short) is basically used to detect the
intensity of light and hence, for example, we can detect if a room is dark or lit.
They are also known as photoresistors or photoconductive cells. The resistance of
LDR is inversely proportional to the intensity of light. Hence under dark conditions
the resistance typically rises to around 500K to 5M. Under ambient light the
resistance is generally around 2K to 10K. Under very bright light its resistance
falls down to around few ohms, for example around 2 to 20 ohms.
We cannot directly connect an LDR to the ADC’s input, we need to convert
the resistance into an equivalent voltage. Once we do this it becomes very easy to
interface them. By adding another fixed resistor in series we can form a potential
divider network and can connect the common of the resister and LDR to ADC’s
input pin. Lets call LDR as R1 and the fixed resistor as R2. The voltage Vout at the
common terminal is given as:
Fig 4: Voltage divider ckt.
The ADC will convert the input voltage to a proportional value between 0
and 1023. We can directly use this value(ADC Result) to detect the light intensity.
A value of 0 means Dark condition and a value of 1023 means very bright light is
present. With this example you can see the output values change as you change the
intensity of light. Working with this example you can decide on a cut-off value or a
cut-off range to trigger a function.

Fig 5: interfacing LDR to LPC214x


We will turn-on an LED when we detect low light or dark conditions.
Instead of an LED you can also connect a Relay which can then switch on a Bulb
or something like heater during night in cold regions. Make sure you keep the LDR
away from the LED or Bulb since we are only interested in detecting sunlight and
not artificial light in this case. Schematic for this example is given as follows:

Fig 6: Control LED/Relay using LDR

C. DHT22 Interfacing with ARM LPC2148


The algorithm or steps we need to implement for interfacing. Since only one
DATA line(PIN) is used, we will use the same GPIO PIN first as OUTPUT to send
START condition and then as INPUT to Receive data.
Steps for Programming DHT11/DHT22:
1. Configure PIN to be used to communication as OUTPUT.
2. Set the PIN O/P to LOW and wait for 18 milli-seconds.
3. Configure the PIN as INPUT. The pull-up resistor will Pull the bus to
HIGH.
4. Wait until DHT responds and pulls the line to LOW after around 40 micro-
seconds or else exit as timeout error.
5. Next, check for 80us LOW followed by 80us HIGH from DHT. This
condition denotes that DHT is ready to send data next.
6. Now, check for 50us LOW followed by 26us to 28us HIGH denoting data
bit ‘0’ or 50us LOW followed 70us HIGH denoting data bit ‘1’. Store the
interpreted bit in an array. Repeat this for each of 40 bits.
7. Extract the data bytes from array to record or display it. Optionally the
checksum can be used to verify data integrity.
8. Wait for at least 1 second before starting again to fetch new data.

Program for Interfacing DHT11/DHT22 with ARM LPC2148:


Now lets build a program for interfacing example. In this example we will
us PIN P0.2 for communication with DHT11 sensor. For DHT22 you just need to
make a slight modification in code to display the decimal part. I leave that to the
reader. If you are using the bare 4 pin sensor than make sure that DATA pin is
pulled up using 4.7K or 10K resistor. If you are using PCB mounted sensor which
has 3 pins then external pullup resistor is not required since it is already present on
the PCB. Timer0 block is used for generating delays and measuring timing of
responses given by DHTxx.
We will also use UART0 to send data back to PC and display it using
software terminal. Printf() has been re-targeted such that its output gets redirected
to UART0.
The schematic for connections between DHTxx and LPC214x is as given
below:
Fig 7: Connections between DHTxx and LPC214x

Conclusion
Designing the ARM based system for measurement and control of the four
environmental parameters, essential for plant growth i.e. temperature, humidity,
soil moisture and light intensity has been followed. The measurement results
obtained from the circuit have shown that the system performance is quite
accurate. This automation in greenhouse improves quality and quantity
ofproduction in agricultural field. Keypad used in system is simple and reduces
complexity by reducing IO requirement of the controller. Driver Circuit provides
better isolation to avoid the noise pickups. Greenhouse status can be observed on
PC, located away from the greenhouse due to use of ZIGBEE technology.

You might also like