![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
temperature sensor with uOLED 96 g1 & GSM Support
Dependencies: OLED160G1 mbed uOLED
Fork of DS18B20 by
main.cpp@2:fe0f893513d4, 2012-11-02 (annotated)
- Committer:
- Renato
- Date:
- Fri Nov 02 09:27:14 2012 +0000
- Revision:
- 2:fe0f893513d4
- Parent:
- 1:b2ea1e9d90df
Temp Sensor with uOLED96-g1 & GSM support
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 | 1:b2ea1e9d90df | 8 | DigitalInOut sensor(p23); // sensor connected to pin 23 |
Renato | 1:b2ea1e9d90df | 9 | |
Renato | 1:b2ea1e9d90df | 10 | OLED160G1 oled(p9, p10, p8); |
Renato | 2:fe0f893513d4 | 11 | //uOLED uoled(p9, p10, p8); |
Renato | 2:fe0f893513d4 | 12 | |
Renato | 2:fe0f893513d4 | 13 | Serial GSM(p13, p14); |
feabhas | 0:03ec282c2908 | 14 | |
feabhas | 0:03ec282c2908 | 15 | Ticker timer; // used for our microsec timing |
Renato | 2:fe0f893513d4 | 16 | //Serial pc(USBTX, USBRX); // serial comms over usb back to console |
Renato | 1:b2ea1e9d90df | 17 | float temp=0; |
Renato | 2:fe0f893513d4 | 18 | void FlushGSM(void) { char char1 = 0; while (GSM.readable()) { char1 = GSM.getc(); } return; } |
Renato | 2:fe0f893513d4 | 19 | bool Flag = false; |
Renato | 2:fe0f893513d4 | 20 | unsigned char i = 0; |
Renato | 2:fe0f893513d4 | 21 | unsigned char j = 0; |
Renato | 2:fe0f893513d4 | 22 | char r[]=""; |
Renato | 2:fe0f893513d4 | 23 | char NumTel[] = "937831063"; |
Renato | 2:fe0f893513d4 | 24 | unsigned char CtrlZ = 0x1A; |
feabhas | 0:03ec282c2908 | 25 | |
feabhas | 0:03ec282c2908 | 26 | int main() { |
Renato | 1:b2ea1e9d90df | 27 | |
Renato | 2:fe0f893513d4 | 28 | |
Renato | 2:fe0f893513d4 | 29 | GSM.baud(9600); |
Renato | 2:fe0f893513d4 | 30 | GSM.format(8,Serial::None,1); |
Renato | 2:fe0f893513d4 | 31 | |
Renato | 2:fe0f893513d4 | 32 | oled.init(); |
Renato | 1:b2ea1e9d90df | 33 | oled.eraseScreen(); |
Renato | 1:b2ea1e9d90df | 34 | oled.setTextBackgroundType(OLED_SET_TEXT_OPAQUE); |
Renato | 1:b2ea1e9d90df | 35 | oled.setFontSize(0); |
Renato | 2:fe0f893513d4 | 36 | //uOLED initialization... |
Renato | 2:fe0f893513d4 | 37 | //uoled.init(); |
Renato | 1:b2ea1e9d90df | 38 | |
Renato | 1:b2ea1e9d90df | 39 | |
Renato | 1:b2ea1e9d90df | 40 | //oled.printf("===========\n"); |
Renato | 1:b2ea1e9d90df | 41 | //oled.printf("DS18B20 Config\n"); |
feabhas | 0:03ec282c2908 | 42 | sensor.mode(PullUp); |
feabhas | 0:03ec282c2908 | 43 | |
feabhas | 0:03ec282c2908 | 44 | ROM_Code_t ROM_Code = ReadROM(); |
Renato | 1:b2ea1e9d90df | 45 | /*oled.printf("Family code: 0x%X\n", ROM_Code.BYTES.familyCode); |
Renato | 1:b2ea1e9d90df | 46 | oled.printf("Serial Number: \n"); |
feabhas | 0:03ec282c2908 | 47 | for (uint32_t i = 6; i != 0; --i) { |
Renato | 1:b2ea1e9d90df | 48 | oled.printf("%02X%s", ROM_Code.BYTES.serialNo[i-1], (i != 1)?":":"\n"); |
feabhas | 0:03ec282c2908 | 49 | } |
Renato | 1:b2ea1e9d90df | 50 | oled.printf("CRC: 0x%X\n", ROM_Code.BYTES.CRC); |
Renato | 1:b2ea1e9d90df | 51 | */ |
Renato | 1:b2ea1e9d90df | 52 | oled.locate(0,1); |
Renato | 2:fe0f893513d4 | 53 | oled.printf("Convertendo...\n"); |
Renato | 1:b2ea1e9d90df | 54 | //uoled.drawText(1, 3, 3, 200, 100, 40, "Convertendo...\n"); |
feabhas | 0:03ec282c2908 | 55 | while (1) { |
Renato | 1:b2ea1e9d90df | 56 | showTemperature(&temp); |
Renato | 1:b2ea1e9d90df | 57 | oled.locate(2,3); |
Renato | 1:b2ea1e9d90df | 58 | oled.setFontSize(2); |
Renato | 1:b2ea1e9d90df | 59 | oled.printf("%.2f C",temp); |
feabhas | 0:03ec282c2908 | 60 | wait(10); |
Renato | 2:fe0f893513d4 | 61 | |
Renato | 2:fe0f893513d4 | 62 | GSM.printf("AT+CMGF=1"); |
Renato | 2:fe0f893513d4 | 63 | FlushGSM(); |
Renato | 2:fe0f893513d4 | 64 | |
Renato | 2:fe0f893513d4 | 65 | GSM.printf("AT+CMGS=%s",NumTel); |
Renato | 2:fe0f893513d4 | 66 | |
Renato | 2:fe0f893513d4 | 67 | while(GSM.readable()) |
Renato | 2:fe0f893513d4 | 68 | { |
Renato | 2:fe0f893513d4 | 69 | if(GSM.getc()=='>') |
Renato | 2:fe0f893513d4 | 70 | { |
Renato | 2:fe0f893513d4 | 71 | Flag = true; |
Renato | 2:fe0f893513d4 | 72 | } |
Renato | 2:fe0f893513d4 | 73 | } |
Renato | 2:fe0f893513d4 | 74 | if(Flag==true) |
Renato | 2:fe0f893513d4 | 75 | { |
Renato | 2:fe0f893513d4 | 76 | |
Renato | 2:fe0f893513d4 | 77 | GSM.printf("%.2f C",temp); |
Renato | 2:fe0f893513d4 | 78 | |
Renato | 2:fe0f893513d4 | 79 | GSM.printf("%c",CtrlZ); |
Renato | 2:fe0f893513d4 | 80 | |
Renato | 2:fe0f893513d4 | 81 | while(!GSM.readable()){;} |
Renato | 2:fe0f893513d4 | 82 | i=0; |
Renato | 2:fe0f893513d4 | 83 | while(GSM.readable()) |
Renato | 2:fe0f893513d4 | 84 | { |
Renato | 2:fe0f893513d4 | 85 | r[i]=GSM.getc(); |
Renato | 2:fe0f893513d4 | 86 | i++; |
Renato | 2:fe0f893513d4 | 87 | } |
Renato | 2:fe0f893513d4 | 88 | |
Renato | 2:fe0f893513d4 | 89 | } |
Renato | 2:fe0f893513d4 | 90 | else |
Renato | 2:fe0f893513d4 | 91 | { |
Renato | 2:fe0f893513d4 | 92 | oled.setFontSize(0); |
Renato | 2:fe0f893513d4 | 93 | oled.printf("\n\n\nTerminal error !!!"); |
Renato | 2:fe0f893513d4 | 94 | return 0; |
Renato | 2:fe0f893513d4 | 95 | } |
Renato | 2:fe0f893513d4 | 96 | |
feabhas | 0:03ec282c2908 | 97 | } |
feabhas | 0:03ec282c2908 | 98 | } |
feabhas | 0:03ec282c2908 | 99 |