The project involves designing and developing for collecting and monitoring climatic condition.in this project we are going to monitor the climate conditions. Here we monitor only 4 weather parameters atmospheric temperature, light intensity, humidity and pressure.

These parameters are measured using different sensors like LDR for measuring light intensity. All sensors are connected the microcontroller.

An LCD is used to display the output from MC.

The block diagram consist of 4sensor modules, LCD and lpc2148 microcontroller.

Gas detector block diagram

LPC 2148 is a 32 bit microcontroller based  on ARM architecture developed by Philips .

The sensors are connected to the ADC pins of the controller they are locate at  P0.27-P0.30.

The temperature sensor (LM35) is connected to the ADC channel 0. The out put voltage of LM35 is linearly proportional to the temperature.

• Calibrated Directly in Celsius (Centigrade)

• Linear + 10-mV/°C Scale Factor

• 0.5°C Ensured Accuracy (at 25°C)

• Rated for Full −55°C to 150°C

• Suitable for Remote Applications

• Low-Cost Due to Wafer-Level Trimming

• Operates from 4 V to 30 V

• Less than 60-μA Current Drain

• Low Self-Heating, 0.08°C in Still Air

• Non-Linearity Only ±¼°C Typical

• Low-Impedance Output, 0.1 Ω for 1-mA Load

LDR (light dependent resistor)

Is used for measuring light intensity and it is connected to the ADC channel1. The working principle behind LDR is photo conductivity. This is an optical phenomenon in which the material conductivity is increased when light is absorbed by the material.

ldr

The humidity sensor (DHT11) is connected to the ADC channel 2. The output of the sensor changes according to the humidity present in air. Resistive type humidity sensors pick up changes in the resistance value of the sensor element in response to the change in the humidity.

humidity sensor

FEATURES:

  • Excellent linearity
  • Low power consumption
  • Wide measurement range
  • Quick response

SPECIFICATIONS:

  • Operating range: humidity(20-95%RH), temperature(0-600C)
  • Power supply: 1.5V AC(Max sine)
  • Operating frequency: 500Hz-2kHz
  • Rated power: 0.2mW(Max sine)
  • Accuracy: ±5%RH

Pressure sensor (MPS20N0040D-D) is connected to ADC channel 3 of the controller.

  • Measure the pressure range of 580 PSIG, 40KPaG
  • Max pressure capacity of three times the measuring range
  • Work power supply 5 VDC,
  • Input impedance of 4 - 6 KΩ
  • The output impedance of 4 - 6 KΩ
  • Operating temperature -40 - 85 ° C -40 ° F - +185 ° F
  • Storage Temperature -40 - 125 ° C -40 ° the F - +257 ° F
  • Accessible media, clean, dry, non-corrosive gases
  • Bias voltage ± 25 mV
  • Full-scale output voltage 50 - 100 mV
  • Bridge Resistance to 4 - 6 KΩ

pressure sensor

LCD(liquid crystal display ) is connected with MC to view the output.

lcd

LCD (liquid crystal display) screen is an electronic display module.LCD 16x2 means it can display16 characters per line and there are two such lines.

DB0-DB7:-Data pins

The data and command are given through these pins.

EN:-enable   

The lcd controller take the data from data pins only get a high to low transition in enable pin.

R/W:

Mode of operation is select using this pin. Giving low to this pin for write something on lcd .read from lcd by making this pin in high state.

RS:

Register select pin.LCD has two registers namely data register and command register.

Writing commands codes for initializing the LCD. For display something on LCD first we have to initialize the LCD by giving some commands. Make RS pin low for giving commands. The LCD controller will take the values in data pins as commands when RS pin is in low state.

If RS is in high state the controller will take the values in data pins for displayin

INSTRUCTION

HEX

8bit ,1Line ,5x7Dots

0x30

8bit ,2Line ,5x7Dots

0x38

4bit ,1Line ,5x7Dots

0x20

bit ,2Line ,5x7Dots

0x28

Entry Mode

0x06

Display off cursor off

(clearing display without clearing content in DDRAM)

0x08

Display on cursor on

0x0E

Display on cursor off

0X0C

Display on cursor blinking

0X0F

Shift entire display left

0X18

Shift entire display right

0X1C

Move cursor left by one character

0X10

Move cursor right by one character

0x14

Clear display and DDRAM content

0x01

The microcontroller is programmed using keil software; in programming first we interface the LCD module with LPC2148. (For more details refer tutorial). The sensors are connected to analogue pins of the MC. Using PINSEL register we can select the ADC channel .The temperature sensor LM35 is connected to AN0 pin and enable ADC module 0 by configuring the controller registers AD0CR.  After the conversion process the output (10bit) will be at AD0GDR register. The conversion start by setting the 24th bit of AD0CR (go) and the 31st bit of AD0GDR indicate the status of the process if it is set means the conversion is completed.

We will check it by polling method to get the result. The result will be a 10bit value ranging from 0 to 1023 .we will get a value which is corresponding to the temperature. So we have to convert this value into temperature in degree Celsius. 

In order to convert the value into degree Celsius, multiply the obtained value   with 0.3225. Similar is the case for rest three ADC channels.

                                                             weather monitoring system

Circuit diagram

circuit diagram weather monitoring station

/*********************************************************/

/*P0.27-P0.30 are input pins ,P0.16-P0.22 are output pins*/

/*uart is connected at P0.0*/

#include <LPC214X.H>

#define rs 16                                                                                                         //rs=16

#define rw 17

#define en 18

#define data 19                               

int s1;

    void lcd_int();                    //lcd function declarations

    void lcd_cmd(int);

    void lcd_data(int);

    void lcd_display(int);

    void lcd_string(char*);

    void delay(unsigned long );

    void enable();                                                   

    void urt(char);                                   //urat function

    void temp();                      

    void light();

    void moist();

    void hm();

    void lcd_int()                     //lcd init function defininition

    {

    delay(100000);                //delay call

    IO0CLR|=(0XFF<<15);                  //clear all out put pins                                                                                                                                                                 lcd_data(0x30<<15);  

    delay(100000);

                lcd_data(0x30<<15);

                delay(100000);                                         //commands for making lcd 4bit mode

                lcd_data(0x30<<15);

                delay(100000);

                lcd_data(0x20<<15);

                        lcd_cmd(0x28);

                        lcd_cmd(0x0c);

                        lcd_cmd(0x06);

                        lcd_cmd(0x01);

                }

                                                 void lcd_cmd(int cmd)                                 

                                                  {

                                                   int cmdd;             //variable declaration

                                                  IO0CLR=(1<<rs);             //write low to lcd rs pin

                                                  IO0CLR=(1<<rw);           // write low to lcd rw pin

                                                  IO0CLR=(1<<en);           // write low to lcd en pin

                                                  cmdd=cmd&0xf0;          //separate upper nibble from cmd

                                                  lcd_data(cmdd<<15);   //write upper nibble to lcd data pins(d4-d7).

                                                  cmdd=cmd&0x0f;          // separate lower nibble from cmd

                                                  lcd_data(cmdd<<19);   //write lower nibble to lcd data pins(d4-d7).

                                                  }

                                                 void lcd_data(int dat)

                                                 {

                                                IO0CLR|=(0xF<<19);                       //clear data pins

                                                IO0SET|=dat;                                     //write data into lcd data pins

                                                //delay(100000);                              //delay

                                                enable();                                             //enable function call

                                                //delay(100000);

                                                  }

void lcd_display(int c)

{

int a;

IO0CLR|=(1<<rw);                           //rw=0

IO0CLR |=(1<<en);                          //en=0

IO0SET |=(1<<rs);                           //write high in rs pin

a=c&0xf0;                                       //separate upper nibble

lcd_data(a<<15);                              //write data

a=c&0x0f;                                       //separate lower nibble

lcd_data(a<<19);                             write lower nibble to lcd data pins

//delay(100000);

}

void lcd_string(char *string)

{

while(*string!='\0')                         //execute the loop until get a ‘\0’

{

lcd_display(*string);

urt(*string);                                       //urt function call            

string++;

}

urt('\r');                                                                //for next line  

}

void enable()

{

//delay(30000);

IO0SET|=(1<<en);                           //en=1

delay(30000);                                     //delay

 IO0CLR|=(1<<en);                          //en=0

 //delay(30000);

 }

void delay(unsigned long value)                                //delay

{

     while(value>0)

    {

        value--;

    }

}

void main()

       {                                                     
                     PINSEL0                =5;

                     U0LCR   =             0X83;                                 //UART configuration

                     U0DLL   =             97;

                     U0LCR   =             0X03

                     IO0DIR|=(0XFF<<16);

                     lcd_int();                                             //function call

                     delay(10000);                   

                     lcd_cmd(0X80);

                     lcd_string("~WEATHER MONTRG~");

                     lcd_cmd(0xc0);

                     lcd_string("~~STATION~~");

                     delay(500000);                  

while(1)

                     {

                     temp();

                     light();

                     delay(300000);

                     moist();

                     hm();

                     delay(300000);

                    }

                      }

void urt(char msg)                           //urt function definition

                   {

                    U0THR=msg;

                    while(!(U0LSR&(1<<6)));              //wait for completion of transmission                                                                                                                                                                                                                                                                }

                   void temp()        //temp function definition

                     {

                        int r0,r1,r2;

                        char q[50];       

                        PINSEL1=(1<<22);          //make P0.27 as analogue

                        AD0CR=0X00200001;    //AD0.0 select (channel select)

                        r0=0x0000ffff;

                        while(r0--);                      //delay

                        AD0CR |=(1<<24);        //start conversion enable

                        while(!(AD0GDR&(1<<31)));       //wait until conversion complete

                        r1=AD0GDR;

                        r1=((r1>>6)&0x000003ff);

                        r1=r1*0.3225;

                        sprintf(q,"TEMP=%d ",r1);                                                      

                        lcd_cmd(0x01);              //clear lcd

                        lcd_string(q);                  //write tem on lcd

                        lcd_display('C');     

                             }

                        void light()        

                        {

                        int r0,r1;

                        char q[50];

                        PINSEL1=(1<<24);          // make P0.28 as analogue

                        AD0CR=0X00200002;    // AD0.1 select (channel select)

                        r0=0x0000ffff;

                        while(r0--);

                        AD0CR |=(1<<24);

                        while(!(AD0GDR&(1<<31)));

                        r1=AD0GDR;

                        r1=((r1>>6)&0x000003ff);

                        r1=r1*0.241;

                        sprintf(q,"lIGHT=%d ",r1);

                        lcd_cmd(0xc0);

                        lcd_string(q);

                        lcd_display('c');

                        lcd_display('d');

                        }

                        void moist()

                        {
                       int r0,r1;

                       char q[50];

                       PINSEL1=(1<<26);          // make P0.29 as analogue

                       AD0CR=0X00200004;    // AD0.2 select (channel select)

                       r0=0x0000ffff;                                //delay

                       while(r0--);

                       AD0CR |=(1<<24);

                       while(!(AD0GDR&(1<<31)));

                       r1=AD0GDR;

                       r1=((r1>>6)&0x000003ff);                                                       

                       sprintf(q,"MOISTURE=%d ",r1);

                       lcd_cmd(0x01);                                                                        

                       lcd_string(q);                                                                      

                       }

                      void hm()

                       {
                      int r0,r1;

                      char q[50];

                      PINSEL1=(1<<28);          //make P0.23 as analogue

                      AD0CR=0X00200008;    // AD0.2 select (channel select)

                      r0=0x0000ffff;

                      while(r0--);

                      AD0CR |=(1<<24);

                     while(!(AD0GDR&(1<<31)));

                     r1=AD0GDR;

                     r1=((r1>>6)&0x000003ff);

                     r1= r1*.1;

                     sprintf(q,"HUMIDITY=%d ",r1);

                     lcd_cmd(0xc0);

                     lcd_string(q);                                                                        

                     }

/************************************************************************/
User Review (0)
Related Items