![](/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@1:b2ea1e9d90df, 2012-10-31 (annotated)
- Committer:
- Renato
- Date:
- Wed Oct 31 12:26:00 2012 +0000
- Revision:
- 1:b2ea1e9d90df
- Parent:
- 0:03ec282c2908
- Child:
- 2:fe0f893513d4
Test v1
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 | 1:b2ea1e9d90df | 11 | uOLED uoled(p9, p10, p8); |
feabhas | 0:03ec282c2908 | 12 | |
feabhas | 0:03ec282c2908 | 13 | Ticker timer; // used for our microsec timing |
feabhas | 0:03ec282c2908 | 14 | Serial pc(USBTX, USBRX); // serial comms over usb back to console |
Renato | 1:b2ea1e9d90df | 15 | float temp=0; |
Renato | 1:b2ea1e9d90df | 16 | |
Renato | 1:b2ea1e9d90df | 17 | |
feabhas | 0:03ec282c2908 | 18 | |
feabhas | 0:03ec282c2908 | 19 | int main() { |
Renato | 1:b2ea1e9d90df | 20 | |
Renato | 1:b2ea1e9d90df | 21 | /*oled.init(); |
Renato | 1:b2ea1e9d90df | 22 | oled.eraseScreen(); |
Renato | 1:b2ea1e9d90df | 23 | oled.setTextBackgroundType(OLED_SET_TEXT_OPAQUE); |
Renato | 1:b2ea1e9d90df | 24 | oled.setFontSize(0); |
Renato | 1:b2ea1e9d90df | 25 | */ //uOLED initialization... |
Renato | 1:b2ea1e9d90df | 26 | uoled.init(); |
Renato | 1:b2ea1e9d90df | 27 | |
Renato | 1:b2ea1e9d90df | 28 | |
Renato | 1:b2ea1e9d90df | 29 | //oled.printf("===========\n"); |
Renato | 1:b2ea1e9d90df | 30 | //oled.printf("DS18B20 Config\n"); |
feabhas | 0:03ec282c2908 | 31 | sensor.mode(PullUp); |
feabhas | 0:03ec282c2908 | 32 | |
feabhas | 0:03ec282c2908 | 33 | ROM_Code_t ROM_Code = ReadROM(); |
Renato | 1:b2ea1e9d90df | 34 | /*oled.printf("Family code: 0x%X\n", ROM_Code.BYTES.familyCode); |
Renato | 1:b2ea1e9d90df | 35 | oled.printf("Serial Number: \n"); |
feabhas | 0:03ec282c2908 | 36 | for (uint32_t i = 6; i != 0; --i) { |
Renato | 1:b2ea1e9d90df | 37 | oled.printf("%02X%s", ROM_Code.BYTES.serialNo[i-1], (i != 1)?":":"\n"); |
feabhas | 0:03ec282c2908 | 38 | } |
Renato | 1:b2ea1e9d90df | 39 | oled.printf("CRC: 0x%X\n", ROM_Code.BYTES.CRC); |
Renato | 1:b2ea1e9d90df | 40 | */ |
Renato | 1:b2ea1e9d90df | 41 | oled.locate(0,1); |
Renato | 1:b2ea1e9d90df | 42 | uoled.printf("Convertendo...\n"); |
Renato | 1:b2ea1e9d90df | 43 | //uoled.drawText(1, 3, 3, 200, 100, 40, "Convertendo...\n"); |
feabhas | 0:03ec282c2908 | 44 | while (1) { |
Renato | 1:b2ea1e9d90df | 45 | showTemperature(&temp); |
Renato | 1:b2ea1e9d90df | 46 | oled.locate(2,3); |
Renato | 1:b2ea1e9d90df | 47 | oled.setFontSize(2); |
Renato | 1:b2ea1e9d90df | 48 | oled.printf("%.2f C",temp); |
feabhas | 0:03ec282c2908 | 49 | wait(10); |
feabhas | 0:03ec282c2908 | 50 | } |
feabhas | 0:03ec282c2908 | 51 | } |
feabhas | 0:03ec282c2908 | 52 |