![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Temperature, Voltage & RTC via SMS
Dependencies: DS1307 OLED160G1 mbed uOLED
Fork of Astromed by
main.cpp@3:603f315daf7b, 2012-11-06 (annotated)
- Committer:
- Renato
- Date:
- Tue Nov 06 10:19:38 2012 +0000
- Revision:
- 3:603f315daf7b
- Parent:
- 2:fe0f893513d4
- Child:
- 4:d352ae75fe0b
temp & voltage sensor via sms
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
feabhas | 0:03ec282c2908 | 1 | #include "mbed.h" |
Renato | 1:b2ea1e9d90df | 2 | #include "stdint.h" |
feabhas | 0:03ec282c2908 | 3 | #include "DS18B20.h" |
Renato | 1:b2ea1e9d90df | 4 | #include "OLED160G1.h" |
Renato | 1:b2ea1e9d90df | 5 | #include "uOLED.h" |
feabhas | 0:03ec282c2908 | 6 | |
Renato | 1:b2ea1e9d90df | 7 | |
Renato | 3:603f315daf7b | 8 | DigitalInOut sensor(p23); //DS18b20 connected on pin 23 |
Renato | 1:b2ea1e9d90df | 9 | |
Renato | 3:603f315daf7b | 10 | OLED160G1 oled(p28, p27, p8); |
Renato | 3:603f315daf7b | 11 | AnalogIn input(p20); //Voltage meter |
Renato | 2:fe0f893513d4 | 12 | |
Renato | 2:fe0f893513d4 | 13 | Serial GSM(p13, p14); |
Renato | 3:603f315daf7b | 14 | Serial pc(USBTX,USBRX); |
feabhas | 0:03ec282c2908 | 15 | |
feabhas | 0:03ec282c2908 | 16 | Ticker timer; // used for our microsec timing |
Renato | 3:603f315daf7b | 17 | |
Renato | 1:b2ea1e9d90df | 18 | float temp=0; |
Renato | 3:603f315daf7b | 19 | |
Renato | 3:603f315daf7b | 20 | |
Renato | 2:fe0f893513d4 | 21 | unsigned char i = 0; |
Renato | 2:fe0f893513d4 | 22 | unsigned char j = 0; |
Renato | 2:fe0f893513d4 | 23 | char NumTel[] = "937831063"; |
Renato | 2:fe0f893513d4 | 24 | unsigned char CtrlZ = 0x1A; |
Renato | 3:603f315daf7b | 25 | float volt=0; |
feabhas | 0:03ec282c2908 | 26 | |
feabhas | 0:03ec282c2908 | 27 | int main() { |
Renato | 1:b2ea1e9d90df | 28 | |
Renato | 2:fe0f893513d4 | 29 | |
Renato | 2:fe0f893513d4 | 30 | GSM.baud(9600); |
Renato | 2:fe0f893513d4 | 31 | GSM.format(8,Serial::None,1); |
Renato | 2:fe0f893513d4 | 32 | |
Renato | 2:fe0f893513d4 | 33 | oled.init(); |
Renato | 1:b2ea1e9d90df | 34 | oled.eraseScreen(); |
Renato | 1:b2ea1e9d90df | 35 | oled.setTextBackgroundType(OLED_SET_TEXT_OPAQUE); |
Renato | 1:b2ea1e9d90df | 36 | oled.setFontSize(0); |
Renato | 1:b2ea1e9d90df | 37 | |
feabhas | 0:03ec282c2908 | 38 | sensor.mode(PullUp); |
feabhas | 0:03ec282c2908 | 39 | |
feabhas | 0:03ec282c2908 | 40 | ROM_Code_t ROM_Code = ReadROM(); |
Renato | 3:603f315daf7b | 41 | |
Renato | 1:b2ea1e9d90df | 42 | oled.locate(0,1); |
Renato | 3:603f315daf7b | 43 | oled.printf("Temp Actual..\n"); |
Renato | 3:603f315daf7b | 44 | |
feabhas | 0:03ec282c2908 | 45 | while (1) { |
Renato | 3:603f315daf7b | 46 | volt = input.read()*3.3; |
Renato | 1:b2ea1e9d90df | 47 | showTemperature(&temp); |
Renato | 1:b2ea1e9d90df | 48 | oled.locate(2,3); |
Renato | 1:b2ea1e9d90df | 49 | oled.setFontSize(2); |
Renato | 1:b2ea1e9d90df | 50 | oled.printf("%.2f C",temp); |
Renato | 3:603f315daf7b | 51 | wait(600); |
Renato | 3:603f315daf7b | 52 | |
Renato | 2:fe0f893513d4 | 53 | |
Renato | 3:603f315daf7b | 54 | GSM.printf("AT+CMGF=1\r\n"); |
Renato | 3:603f315daf7b | 55 | wait(1); |
Renato | 2:fe0f893513d4 | 56 | |
Renato | 3:603f315daf7b | 57 | GSM.printf("AT+CMGS=937831063\r\n"); |
Renato | 3:603f315daf7b | 58 | wait(1); |
Renato | 3:603f315daf7b | 59 | |
Renato | 3:603f315daf7b | 60 | GSM.printf("%.2f C\r\n",temp); |
Renato | 3:603f315daf7b | 61 | GSM.printf("%.2f V\r\n", volt); |
Renato | 3:603f315daf7b | 62 | GSM.printf("%c",CtrlZ); |
Renato | 3:603f315daf7b | 63 | |
Renato | 3:603f315daf7b | 64 | |
Renato | 2:fe0f893513d4 | 65 | |
feabhas | 0:03ec282c2908 | 66 | } |
feabhas | 0:03ec282c2908 | 67 | } |
feabhas | 0:03ec282c2908 | 68 |