temperature & voltage sensor via SMS with uOLED 96 g1

Dependencies:   OLED160G1 mbed uOLED

Fork of DS18B20GSM by Renato Loureiro

Files at this revision

API Documentation at this revision

Comitter:
Renato
Date:
Tue Nov 06 10:19:38 2012 +0000
Parent:
2:fe0f893513d4
Commit message:
temp & voltage sensor via sms

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r fe0f893513d4 -r 603f315daf7b main.cpp
--- a/main.cpp	Fri Nov 02 09:27:14 2012 +0000
+++ b/main.cpp	Tue Nov 06 10:19:38 2012 +0000
@@ -5,23 +5,24 @@
 #include "uOLED.h"
 
 
-DigitalInOut sensor(p23);     // sensor connected to pin 23
+DigitalInOut sensor(p23);     //DS18b20 connected on pin 23
 
-OLED160G1 oled(p9, p10, p8);
-//uOLED uoled(p9, p10, p8);
+OLED160G1 oled(p28, p27, p8);
+AnalogIn input(p20);          //Voltage meter
 
 Serial GSM(p13, p14);
+Serial pc(USBTX,USBRX);
 
 Ticker timer;                // used for our microsec timing
-//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;
+float volt=0;
 
 int main() {
 
@@ -33,66 +34,34 @@
     oled.eraseScreen();
     oled.setTextBackgroundType(OLED_SET_TEXT_OPAQUE);
     oled.setFontSize(0);
-                         //uOLED initialization...
-    //uoled.init();
     
-    
-    //oled.printf("===========\n");
-    //oled.printf("DS18B20 Config\n");
     sensor.mode(PullUp);
     
     ROM_Code_t ROM_Code = ReadROM();
-    /*oled.printf("Family code: 0x%X\n", ROM_Code.BYTES.familyCode);
-    oled.printf("Serial Number: \n");
-    for (uint32_t i = 6; i != 0; --i) {
-        oled.printf("%02X%s", ROM_Code.BYTES.serialNo[i-1], (i != 1)?":":"\n");
-    }
-    oled.printf("CRC: 0x%X\n", ROM_Code.BYTES.CRC);
-    */
+    
     oled.locate(0,1);
-    oled.printf("Convertendo...\n");
-    //uoled.drawText(1, 3, 3, 200, 100, 40, "Convertendo...\n");
+    oled.printf("Temp Actual..\n");
+    
     while (1) {
+    volt = input.read()*3.3;
     showTemperature(&temp);
        oled.locate(2,3);
        oled.setFontSize(2);
         oled.printf("%.2f C",temp);
-        wait(10);
+        wait(600);
+
 
-GSM.printf("AT+CMGF=1");
-FlushGSM();
-
-GSM.printf("AT+CMGS=%s",NumTel);
+GSM.printf("AT+CMGF=1\r\n");
+wait(1);
 
-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;
-    }
+GSM.printf("AT+CMGS=937831063\r\n");
+wait(1);
+
+GSM.printf("%.2f C\r\n",temp);
+GSM.printf("%.2f V\r\n", volt);
+GSM.printf("%c",CtrlZ);
+
+
 
     }
 }