Hi
Featured Services
Tutorials on Embedded
System Design .
Tutorials on
Antenna Design.
Tutorials on
Image Processing Using
Open-CV.
read more

PROJECTS WITH CODE

HELP SHARE IDEAS.COM
Mail us at : info@helpshareideas.com

:Uploaded on Monday 24th OCT 2016

Code for the Implemenatation of Project :
Zigbee Based Home Automation - Monitoring & Controlling using ARM7 LPC2148

The main principle of this project is controlling and monitoring the devices in an industry using zigbee technology which is a wireless technology. Here we are using the zigbee transceivers which are used to send and receive the data. First of all, the ADC 0809 is connected to the three channels from the three sensors. Here the ADC is inbuilt in arm 7 microcontroller. The microcontroller sends the data to the zigbee transceiver at transmitter side and it is collected by the zigbee transceiver at the receiver side because it is a wireless network and then sent to arm cortex processor which is used as a serial to Ethernet converter and the values are displayed on the PC in the form of web page. Here the two devices are connected to the controller by the help of relays which are connected through the ULN 2003.The sensor values are displayed in the webpage and through this we can control and also monitor the devices.

Zigbee Based Home Automation

In this project the code has been written in such a way that Arm 7 microcontroller collects the data continuously, and sends to zigbee at the other end data is received by zigbee trans-receiver and sends to data at pc it continuosly updates the different sensors data and controls the devices connected to the arm 7 microcontroller.

The devices that are to be controlled are connected to the arm 7 microcontroller. The status of the device is sent via wireless network using zigbee that is being accessed by the user at the remote side. The commands given by the user at the remote client will be received by the microcontroller through zigbee at other end and get executed. This way control of the devices will take place. In our Project demo we are giving input as temperature to inbuilt ADC of LPC 2148 by using LM35 sensor. The Device we have selected is heater. Depending on the temperature above the ref or below the ref the device will be switched on or off.

Code for the Implementation of the Project

Code :

    // ZIGBEE BASED HOME AUTOMATION
    #include "LPC214X.H" // Header file LPC214x to be included

    void adc0_init(void);
    void transit_routine1(void);
    void transit_routine2(void);
    void receive_routine(void);
    void transit_routine3(void);
    void transit_routine4(void);
    void transit_routine5(void);
    void delay(unsigned long int count1);
    void WELCOME_SCREEN(void);

    char WS[]= {"***WELCOME TO HELPSHAREIDEAS.COM: DEMO ON ZIGBEE BASED HOME AUTOMATION USING ARM7-LPC2148***"} ; //85 CHARACTERS

    char gh1[]= {"Temp Above RefVal - PRESS 1 T0 TURN OFF "};
    char gh2[]= {"Temp Below RefVal - PRESS 0 TO KEEP IT TURNED ON "};
    char gh3[]= {" *LOAD IS KEPT ON* "};
    char gh4[]= {" *LOAD IS OFF* "};
    char gh5[]={" "} ;
    int buffer ;
    int ADCout ;
    int m ;
    unsigned char RxData;

    int main()
    {
    unsigned int j, ADCout ;
    adc0_init();
    PINSEL0|=0x00000000;
    IODIR0=0x00003FF0;
    IOCLR0=ADCout<<4;
    IODIR1 = 0x00FF0000; // Defining outputs -P1.16..23 defined as Outputs
    IOSET1 = 0x00FF0000 ;
    while(1)
    {
    AD0CR|=0X01000000;
    for(j=0;j<0x10000;j++);
    while(!(AD0DR4 &(0x80000000)));
    AD0CR&=0XF0FFFFFF;
    ADCout=((AD0DR4)&(0x0000FFC0))>>6 ;
    IOSET0=ADCout<<4;
    AD0CR|=0X00000000;
    for(j=0;j<0x1000000;j++);
    IOCLR0=ADCout<<4;
    for(j=0;j<0x100000;j++);
    // Enable RxD0 and TxD0
    PINSEL0 = 0x00000005;
    // Initialize UART0 & Set Baudrate to 9600
    U0LCR = 0x83;
    U0DLL = 97;
    U0DLM=00;
    U0LCR = 0x03;
    U0FCR= 0x07;
    //U0IER= 0x1;
    // Initialize VIC
    //VICIntSelect=0x0;
    //VICIntEnable= 0x40;
    //VICVectCntl0= 0x26;
    //VICVectAddr0=(unsigned long)uart_isr;

    // comparing the ADCout with Ref Value
    WELCOME_SCREEN();
    if( ADCout >= 0x009B) // 0x009B is equivalent converted value for .5 volts input
    {
    transit_routine1() ;
    // wait for receiving the data
    delay(500000); // waiting for input by giving delay
    receive_routine();
    if( RxData==0x31)
    {
    unsigned int j;
    IOCLR1= 0x00FF0000 ; // clearing P1.16..23 defined as Outputs
    for(j=0;j<0x100000;j++);
    transit_routine4();
    }
    else
    {
    transit_routine5();
    }
    }
    else
    {
    transit_routine2();
    // wait for receiving the data
    delay(500000); // waiting for input by giving delay
    receive_routine();
    if( RxData==0x30)
    { unsigned int j;
    IOSET1 = 0x00FF0000 ; // Turning on P1.16..23 defined as Outputs
    for(j=0;j<0x100000;j++);
    transit_routine3();
    }
    else
    {
    transit_routine5();
    }
    }
    }
    }

    //adc0 prgrm
    void adc0_init(void)
    {
    PINSEL1=0x00040000;
    AD0CR=0X00200310; // selecting AD0.4
    AD0CR|=0X00000000;
    }

    void transit_routine1(void)
    {
    int m ;
    for(m=0; m<41 ; m++)
    { unsigned int j;
    U0THR=gh1[m];
    for(j=0;j<0x10000;j++);
    }
    /*delay(5000); // waiting for input by giving delay
    for(m=0; m<16 ; m++)
    {
    U0THR=gh6[m];
    }
    */
    }

    void transit_routine2(void)
    { unsigned int j;
    int m ;
    for(m=0; m<49 ; m++)
    {
    U0THR=gh2[m] ;
    for(j=0;j<0x10000;j++);
    }
    /* delay(5000); // waiting for input by giving delay
    for(m=0; m<16 ; m++)
    {
    U0THR=gh7[m];
    }
    */
    }

    void transit_routine3(void)
    { unsigned int j;
    int m ;
    for(m=0; m<19 ; m++)
    {
    U0THR=gh3[m];
    for(j=0;j<0x10000;j++);
    }
    }

    void transit_routine4(void)
    { unsigned int j;
    int m ;
    for(m=0; m<15 ; m++)
    {
    U0THR=gh4[m] ;
    for(j=0;j<0x10000;j++);
    }
    }
    void transit_routine5(void)
    { unsigned int j;
    int m ;
    for(m=0; m<18 ; m++)
    {
    U0THR=gh5[m] ;
    for(j=0;j<0x10000;j++);
    }
    }

    void receive_routine(void)
    {
    //unsigned char RxData;
    while ((U0LSR & 0x01)!=0x01);
    {
    RxData=U0RBR;
    }
    }
    void delay(unsigned long int count1)
    {
    while(count1 > 0) {count1--;}
    // Loop Decrease Counter
    }

    void WELCOME_SCREEN(void)
    {
    unsigned int j;
    int m ;
    for(m=0; m<85 ; m++)
    {
    U0THR=WS[m] ;
    for(j=0;j<0x10000;j++);
    }
    }

Kindly mail us if you get any difficulties while testing this code.
Note : We will soon update Tutorials page. You Can Learn how to create a Project using Arm 7 - LPC 2148 using these demos. Hence Kindly visit the page for more updates

Editor: HelpShareIdeas.com

For giving feedback on this article please mail us at : info@helpshareideas.com

<: Click the link PROJECTS with Code to access the Latest Projects with codes Page:>