temperature sensor with uOLED 96 g1 & GSM Support

Dependencies:   OLED160G1 mbed uOLED

Fork of DS18B20 by Renato Loureiro

Files at this revision

API Documentation at this revision

Comitter:
Renato
Date:
Fri Nov 02 09:27:14 2012 +0000
Parent:
1:b2ea1e9d90df
Commit message:
Temp Sensor with uOLED96-g1 & GSM support

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Oct 31 12:26:00 2012 +0000
+++ b/main.cpp	Fri Nov 02 09:27:14 2012 +0000
@@ -8,22 +8,33 @@
 DigitalInOut sensor(p23);     // sensor connected to pin 23
 
 OLED160G1 oled(p9, p10, p8);
-uOLED uoled(p9, p10, p8);
+//uOLED uoled(p9, p10, p8);
+
+Serial GSM(p13, p14);
 
 Ticker timer;                // used for our microsec timing
-Serial pc(USBTX, USBRX);     // serial comms over usb back to console
+//Serial pc(USBTX, USBRX);     // serial comms over usb back to console
 float temp=0;
-
-
+void FlushGSM(void) { char char1 = 0; while (GSM.readable()) { char1 = GSM.getc(); } return; }
+bool Flag = false;
+unsigned char i = 0;
+unsigned char j = 0;
+char r[]="";
+char NumTel[] = "937831063";
+unsigned char CtrlZ = 0x1A;
 
 int main() {
 
-    /*oled.init();
+
+GSM.baud(9600);
+GSM.format(8,Serial::None,1);
+
+    oled.init();
     oled.eraseScreen();
     oled.setTextBackgroundType(OLED_SET_TEXT_OPAQUE);
     oled.setFontSize(0);
-      */                    //uOLED initialization...
-    uoled.init();
+                         //uOLED initialization...
+    //uoled.init();
     
     
     //oled.printf("===========\n");
@@ -39,7 +50,7 @@
     oled.printf("CRC: 0x%X\n", ROM_Code.BYTES.CRC);
     */
     oled.locate(0,1);
-    uoled.printf("Convertendo...\n");
+    oled.printf("Convertendo...\n");
     //uoled.drawText(1, 3, 3, 200, 100, 40, "Convertendo...\n");
     while (1) {
     showTemperature(&temp);
@@ -47,6 +58,42 @@
        oled.setFontSize(2);
         oled.printf("%.2f C",temp);
         wait(10);
+
+GSM.printf("AT+CMGF=1");
+FlushGSM();
+
+GSM.printf("AT+CMGS=%s",NumTel);
+
+while(GSM.readable())
+    {
+        if(GSM.getc()=='>')
+        {
+            Flag = true;
+        }
+    }
+    if(Flag==true)
+    {
+        
+        GSM.printf("%.2f C",temp);
+        
+        GSM.printf("%c",CtrlZ);
+        
+        while(!GSM.readable()){;}
+        i=0;
+        while(GSM.readable())
+        {
+            r[i]=GSM.getc();
+            i++;
+        }
+        
+    }
+    else
+    {
+        oled.setFontSize(0);
+        oled.printf("\n\n\nTerminal error !!!");
+        return 0;
+    }
+
     }
 }