Anda di halaman 1dari 36


y The scope of this project is to design a system through

which, we can control multi appliances from our mobile by sending message. The LCD display is interfaced to the Microcontroller and this in turn is connected to UART and GSM modem. Upon receiving the data the microcontroller processes the message and sends it to the LCD display to show it, and switches ON or OFF the corresponding equipment.

y An embedded system is a special-purpose computer

system usually built into a Environment connected to systems through sensors, actuators and other I/O interfaces. y Embedded system must meet timing & other constraints imposed on it by Environment.

y This project is intended to serve a farmer gadget

which helps him to control his motor in his farm using his mobile phone by sending an sms. y This project presents the emerging applications of the GSM technology. Using the public GSM networks, a field automation system has been proposed, designed, implemented and tested.


y Microcontroller 89S52 y MAX 232 y LCD display y Relays y LED y GSM modem y MOTOR

Fully Static Operation: 0 Hz to 33 MHz Three-level Program Memory Lock 256K Internal RAM 32 Programmable I/O Lines, 16-bit Timer/Counters Eight Interrupt Sources Full Duplex UART Serial Channel Low-power Idle and Power-down Modes Watchdog Timer Dual Data Pointer

Micro controller AT 89S52

MAXor Exceed TIA/EIA-232-F and ITU y Meet 232

y y y y y y y

Recommendation V.28 Operate With Single 5-V Power Supply Operate Up to 120 Kbit/s Two Drivers and Two Receivers( typical threshold 1.3V and typical hysteresis 0.5V) 30-V Input Levels Low Supply Current . . . 8 mA Typical Designed to be Interchangeable With Maxim MAX232 ESD Protection Exceeds JESD 22, 2000-V HumanBody Model (A114-A)

MAX 232

LCD display
y light weight and slimness, wide operating

temperatures y less power consumption and hence can be used for long durations y can be read in the darkness as it does not generate light y changing the display size is relatively simpler and hence customer friendly


y A relay is an electrical switch that opens and closes

under the control of another electrical circuit. In the original form, the switch is operated by an electromagnet to open or close one or many sets of contacts. A relay is able to control an output circuit of higher power than the input circuit, it can be considered to be, in a broad sense, a form of an electrical amplifier.


y LED's are special diodes that emit light when

connected in a circuit. They are frequently used as "pilot" lights in electronic appliances to indicate whether the circuit is closed or not. A clear (or often colored) epoxy case enclosed the heart of an LED, the semi-conductor chip.


GSM modem
y A GSM modem is a specialized type of modem which

accepts a SIM card, and operates over a subscription to a mobile operator, just like a mobile phone. From the mobile operator perspective, a GSM modem looks just like a mobile phone.

y This project is intended to serve a farmer gadget which helps him to control

his motor in his farm using his mobile phone by sending an sms.

y Here a gsm modem is connected to the microcontroller which is in turn

connected to motors via relays. When the farmer sends message to the gsm modem, this message can be read from the microcontroller and it will decide whether to ON the motor or to make it OFF according to the message received. microcontroller. So, when an appropriate command is received, motor send the particular logic either 1 or 0 to the output pin where relay is connected.

y All the commands required to access gsm are programmed in the

y This relay supplies current to the motor according to the logic received from the mcu. y The status of the motor is displayed on the lcd screen which is placed at the visible place for the farmer. All the commands required to access lcd are also programmed in the microcontroller. Thus microcontroller acts as the intermediate stage between all the independent modules like gsm modem, lcd screen, motors. y Gsm modem is connected using uart port which is connected to max232 ic which is used as level translator between gsm modem and mcu. y

Thus, the whole process happening in the project is, taking message from the gsm modem, and according to the message, controlling the motor and displaying the same status on the lcd screen. This is the brief explanation of the whole task handled.

y y y y y y y y y y y y y y y y y y y y

#include<reg51.h> void serial_init(void); void uart_putChar(unsigned char d); void uart_putString(unsigned char *Uart_Data); sfr LCD=0xA0; void cmd_lcd(unsigned char ); void display_lcd(unsigned char ); void delay(unsigned int ); void lcd_init(void); void display_string(void); void shal_LcdPrint (char *string); typedef enum { GSM_START, GSM_INIT, GSM_WAIT, GSM_READ, GSM_DEL, GSM_SEND }GSM_state;

y y y y y y y y y y y y y y y y y y y y y y

sbit light = P0^1; sbit motor = P0^3; volatile char flag=0; char r_buf[20]=0; int r_pos = 0,read = 0 ,msg_no; GSM_state modem_state;

void uart_putChar(unsigned char d) { if(d<10) SBUF = d + 0x30; else if(d=='\r') //NewLine SBUF = 0x0d; else if(d=='\n') //Return SBUF = 0x0a; else if(d=='\"') //Return SBUF = 0x22; else SBUF = d;

y y y y y y y y y y y y y

while(TI == 0){} //Write transmitting has been finished TI = 0; } void uart_putString(unsigned char *Uart_Data) { while(*Uart_Data)//!='\0') { uart_putChar(*Uart_Data++); } }

y y y y y y y y y y y y y y y y y y y

// function takes two strings as input and return the position of second string in first if appears int contain(char s1[10],char s2[10]) { int i=0,j=0; while(s1[i]!='\0') { if(s1[i]==s2[j]) { while(s1[i]==s2[j]) { i++; j++; if(s2[j]=='\0')return 1;//(i-j+1); } } else i++,j=0; } return 0; }

y void main() y { y int x=0; y y lcd_init(); y serial_init(); y modem_state = GSM_INIT; y light = 0; y y motor = 0; y cmd_lcd(0x01); y cmd_lcd(0x80); y shal_LcdPrint ("WirelesMobilCtrl"); y cmd_lcd(0xC0); y shal_LcdPrint ("SystemForFarmers"); y delay(500);

y y y y y y y y y y y y y y y y y y y

IT0 = 1; // Configqure interrupt 0 for falling edge on /INT0 (P3.2) EX0 = 1; // Enable EX0 Interrupt EA = 1; // Enable Global Interrupt Flag

while(1) { if(modem_state == GSM_INIT) { cmd_lcd(0x01); shal_LcdPrint ("GSM INIT"); r_pos = 0; uart_putString("AT+CMGF=1\r"); delay(1500); if(contain(r_buf,"OK")) { modem_state = GSM_WAIT; } }

y y y y y y y y y y y y y y y y y y y y

if(modem_state == GSM_WAIT) { cmd_lcd(0x01); r_pos=0; shal_LcdPrint ("Waiting 4 SMS."); delay(200); if(contain(r_buf,"+CMTI")) { modem_state = GSM_READ; } } if(modem_state == GSM_READ) { r_pos=0; read = 0; cmd_lcd(0x01); shal_LcdPrint ("Reading SMS"); uart_putString("AT+CMGR=1\r"); delay(1500);

y if(contain(r_buf,"*LON#")) y { y cmd_lcd(0x01); y light = 1; y shal_LcdPrint ("LIGHT ON"); y modem_state = GSM_DEL; y } y else if(contain(r_buf,"*LOFF#")) y { y cmd_lcd(0x01); y light = 0; y shal_LcdPrint ("LIGHT OFF"); y modem_state = GSM_DEL; y }

y y y y y y y y y y y y y y y y y y y

else if(contain(r_buf,"*MOFF#")) { cmd_lcd(0x01); motor = 0; shal_LcdPrint ("MOTOR OFF"); modem_state = GSM_DEL; } modem_state = GSM_DEL; } if(modem_state == GSM_DEL) { r_pos=0; read = 0; cmd_lcd(0x01); uart_putString("AT+CMGD=1\r"); delay(500); while(r_pos == 0);


y y y y y y y y y y y y y y y y y y y y y

if(contain(r_buf,"OK")) { modem_state = GSM_WAIT; } } } } /* Serial Line interrupt */ void serial0() interrupt 4 { if (RI == 1) {

if(modem_state == GSM_READ && SBUF == '*' && read !=1 ) { read = 1; }

y if(modem_state != GSM_READ && read !=1 ) y { y r_buf[r_pos++] = SBUF; y } y y if( read == 1) y y { y r_buf[r_pos++] = SBUF; y r_buf[r_pos] = '\0'; y } y y RI = 0; y } y y } y y

y y y y y y y y y y y y y y

void ex0_isr (void) interrupt 0 { modem_state = GSM_INIT; }

void delay(unsigned int n) { unsigned short i; unsigned short j; for(j=0;j<n;j++) for(i=0;i<=1000;i++); }

y void lcd_init(void) y { y delay(10); y cmd_lcd(0x28); y cmd_lcd(0x28); y cmd_lcd(0x28); y cmd_lcd(0x0e); y y cmd_lcd(0x01); y cmd_lcd(0x06); y cmd_lcd(0x80); y }

y y y y y y y y y y y y y y y y y y y y

void cmd_lcd(unsigned char x) { unsigned char y; y=x>>4; LCD=y<<4|0x04; LCD=0; LCD=x<<4|0x04; LCD=0; delay(2); }

void display_lcd(unsigned char x) { unsigned char y; y=x>>4; LCD=y<<4|0x05; LCD=0; LCD=x<<4|0x05;

y y y y y y y y y y y y y y y y y y

LCD=0; delay(2); } void shal_LcdPrint (char *string) { while (*string) { display_lcd(*string++); } } void serial_init(void) { TMOD = 0X20; TH1 = 0XFD; SCON = 0X50; IE= 0X92; TR1=1; }

The project MOBILE CONTROL SYSTEM FOR FARMERS has been successfully designed and tested. y Integrating features of all the hardware components used, have developed it. Presence of every module has been reasoned out and placed carefully thus contributing to the best working of the unit. y Secondly, using highly advanced IC s and with the help of growing technology the project has been successfully implemented.

Future scope