Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help to program FYP-MICROCONTROLLER-GSM-IRRIGATION WATER SUPPLY MONITORING-CONTROL

Status
Not open for further replies.

thibaka

Newbie level 1
Joined
Jun 3, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
any one please help me to compile this program i didnt got the exact gsm.h for this



#include <16F877A.h>
#include <string.h>
#include <stdio.h>
#include <gsm.h>
#use delay (clock=20000000)
#use rs232 (baud = 9600, xmit=PIN_B0,rcv=PIN_B1,stream=GSM)
byte ch = 0;
int count = 0;
byte data[15]; //For SMS storage
byte on[] = {"on"};
byte off[] = {"off"};
byte about[] = {"about"};
byte help[] = {"help"};
byte num[12];
void init_gsm()
{
fprintf(GSM,"AT\r\n");
delay_ms(1500);
fprintf(GSM,"AT+CMGF=1\r\n");
delay_ms(1500);
}
void WRITE_TO_EEPROM(int tdata, int location) //write data to eprom at location
{
write_eeprom(location,tdata);
}
int READ_FROM_EEPROM(int location) //read eeprom data strored location
{
int tdata;
tdata = read_eeprom(location);
return(tdata);
}
void main()
{
int i = 0;
int j = 0;
int system_on_flag = 0;
int pump_on_flag = 0;
output_high(PIN_D2);
output_high(PIN_D3);
delay_ms(1000);
output_low(PIN_D2);
output_low(PIN_D3);
delay_ms(1000);
output_high(PIN_D2);
output_high(PIN_D3);
delay_ms(1000);
output_low(PIN_D2);
output_low(PIN_D3);
init_gsm();
while(1)
{
output_toggle(PIN_D2);
delay_ms(1000);
system_on_flag = READ_FROM_EEPROM(0);
if(system_on_flag == 1)
{
output_high(PIN_D3);
if((pump_on_flag == 0) && (input(PIN_B6))) //PIN_B6 is from soil sensor output
{
pump_on_flag = 1;
output_high(PIN_D7); //Relay ON
fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num);
delay_ms(1000);
fprintf(GSM,"*** ALERT ***Irrigation Water Pump got Switched ON\r\n");
delay_ms(1000);
fputc(0x1A,GSM);
delay_ms(2000);
}
if((pump_on_flag == 1) && (!input(PIN_B6))) //PIN_B6 is from soil sensor output
{
pump_on_flag = 0;
output_low(PIN_D7); //Relay OFF
fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num);
delay_ms(1000);
fprintf(GSM,"*** ALERT ***Irrigation Water Pump got Switched OFF\r\n");
delay_ms(1000);
fputc(0x1A,GSM);
delay_ms(2000);
}
}
count = 0;
fprintf(GSM,"AT+CMGR=1\r\n");
num = get_gsm_sms_number(); //get the phone number from sms
data = get_gsm_sms_text; //get sms message content
fprintf(GSM,"AT+CMGD=1\r\n"); //delete message
delay_ms(2000);
if(strstr(data,on)) //check if the message got on
{
WRITE_TO_EEPROM(1,0); //data, location (address)
output_high(PIN_D3);
fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num);
delay_ms(1000);
fprintf(GSM,"Irrigation Water Sensing System got switched ON\r\n");
delay_ms(1000);
fputc(0x1A,GSM);
fgetc(GSM);
delay_ms(2000);
}
else if(strstr(data,off))
{
WRITE_TO_EEPROM(0,0); //data, location (address)
output_low(PIN_D3);
output_low(PIN_D7);
fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num);
delay_ms(1000);
fprintf(GSM,"Irrigation Water Sensing System got switched OFF\r\n");
delay_ms(1000);
fputc(0x1A,GSM);
fgetc(GSM);
delay_ms(2000);
}
else if(strstr(data,about))
{
fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num);
delay_ms(1000);
output_high(PIN_D2);
fprintf(GSM,"B.Tech Final Year(2009-2010) Project.\r\n");
delay_ms(1000);
fputc(0x1A,GSM);
fgetc(GSM);
delay_ms(2000);
}
else if(strstr(data,help)) //check for help message
{
fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num);
output_high(PIN_D2);
delay_ms(1000);
fprintf(GSM,"Send \"on\" to on OR \"off\" to off the Automatic Irrigation Water System.\r\n");
fprintf(GSM,"Send \"about\" to know about me \r\n");
delay_ms(1000);
fputc(0x1A,GSM);
fgetc(GSM);
delay_ms(2000);
}
}
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top