prathap j
/
PROJECTFILE
EMS_Final_5/11/13 (HVM here)
Fork of 4_LCD_With_Lib by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 00004 AnalogIn sm1(p18); 00005 DigitalOut relay(p30); 00006 00007 Serial GPRS(p9,p10); 00008 Serial pc(USBTX, USBRX); // tx, rx 00009 00010 TextLCD lcd(p26, p25, p24, p23, p22, p21); // rs, e, d4, d5, d6, d7 00011 00012 LocalFileSystem local("local"); 00013 00014 char z=0x1A,e=0x22,c=0x0d; // ASCII equivalent of 0X22 is "(Double invited coma) 00015 char num[]="9535811293"; // Mobile phone number to which emergancy information has to be delivered 00016 00017 int main() 00018 { 00019 float a,m; 00020 int b=100,time=0; 00021 00022 while(1) 00023 { 00024 GPRS.baud(9600); 00025 GPRS.printf("AT+CMGF=1\r\n"); 00026 q=m; //Storing the sensor value in a variable 00027 00028 //Sensor read and Callibrate 00029 a=sm1.read(); 00030 m=(0.057*(a*1024))+25.072; 00031 lcd.cls(); 00032 lcd.printf("Raw SM1=%0.3f",a); 00033 wait(5); 00034 00035 //Local storage (On board flash memory of 2MB) 00036 FILE *fp=fopen("/local/KAEMS.csv","a"); 00037 fprintf(fp,"%d,%0.3f\n",time,m); 00038 fclose(fp); 00039 lcd.cls(); 00040 lcd.printf("File updated"); 00041 wait(5); 00042 00043 //Display 00044 lcd.cls(); 00045 lcd.locate(0,0); 00046 lcd.printf("SM1=%0.3f",m); 00047 wait(5); 00048 00049 //Realy control 00050 if(m>50) 00051 relay=0; 00052 else 00053 relay=1; 00054 wait(2); 00055 lcd.cls(); 00056 lcd.locate(0,0); 00057 lcd.printf("Relay Function..."); 00058 00059 //GPRS commands 00060 lcd.cls(); 00061 lcd.locate(0,0); 00062 lcd.printf("Updating BMSEMS..."); 00063 wait(3); 00064 GPRS.printf("AT+SAPBR=0,1\r\n"); 00065 wait(3); 00066 GPRS.printf("AT+SAPBR=3,1,%cCONTYPE%c,%cGPRS%c\r\n",e,e,e,e); 00067 wait(3); 00068 GPRS.printf("AT+SAPBR=3,1,%cAPN%c,%cwww%c\r\n",e,e,e,e); 00069 wait(3); 00070 GPRS.printf("AT+SAPBR=1,1\r\n"); 00071 wait(5); 00072 GPRS.printf("AT+HTTPINIT\r\n"); 00073 wait(2); 00074 GPRS.printf("AT+HTTPPARA=%cCID%c,1\r\n",e,e); 00075 wait(2); 00076 GPRS.printf("AT+HTTPPARA=%cURL%c,%chttp://bmsems.org/update.php?u=3&t=23&h=34&s1=%f&s2=24&s3=25&s4=26&ph=5&b=%d%c\r\n",e,e,e,m,b--,e); 00077 wait(2); 00078 GPRS.printf("AT+HTTPDATA=1000,5000\r\n"); 00079 wait(10); 00080 GPRS.printf("AT+HTTPACTION=1\r\n"); 00081 wait(5); 00082 GPRS.printf("AT+HTTPTERM\r\n"); 00083 wait(5); 00084 00085 time=time+1; 00086 lcd.cls(); 00087 lcd.locate(0,0); 00088 lcd.printf("BMSEMS Updated"); 00089 wait(10); 00090 } 00091 }
Generated on Fri Aug 12 2022 18:10:09 by 1.7.2