temperature and pressure sensor

Dependencies:   BMP180 N5110 beep mbed

Files at this revision

API Documentation at this revision

Comitter:
laithnashashibi1
Date:
Mon May 11 23:50:39 2015 +0000
Commit message:
final code

Changed in this revision

BMP180.lib Show annotated file Show diff for this revision Revisions of this file
N5110.lib Show annotated file Show diff for this revision Revisions of this file
beep.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BMP180.lib	Mon May 11 23:50:39 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/eencae/code/BMP180/#0e92710a46f9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/N5110.lib	Mon May 11 23:50:39 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/eencae/code/N5110/#ba8addc061ea
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/beep.lib	Mon May 11 23:50:39 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/dreschpe/code/beep/#d8e14429a95f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 11 23:50:39 2015 +0000
@@ -0,0 +1,109 @@
+/**
+@file main.cpp
+
+@brief Program implementation
+
+*/
+
+#include "main.h"
+
+
+int main()
+{
+
+    /// initiliase barometer
+
+    bmp180.init();
+    lcd.init(); /// intialise display
+    
+    buzzer.beep(1000,0.5);
+    lcd.printString("Welcome to",0,1);  /// display splash screen
+    lcd.printString("My Temperature",0,2);
+    lcd.printString("and Pressure",0,3);
+    lcd.printString("Sensor",0,5);
+    wait(3);
+
+    lcd.clear();
+    lcd.refresh();
+    
+    
+    
+    
+        while(1) {
+
+            if(button == 1) {
+                
+                lcd.clear();
+                lcd.refresh();
+                char buffer[14];
+                Measurement measurement;  /// measurement structure declared in BMP180 class
+                measurement = bmp180.readValues();
+                wait(0.1);
+                
+                int length = sprintf(buffer, "T = %.2f F", measurement.temperature*9/5+32); ///temp unit changed to F using the formula
+                if (length <= 14)
+                    lcd.printString(buffer,0,1);
+                wait(0.1);
+
+                length = sprintf(buffer, "P =%.2f b ", measurement.pressure/1000); /// pressure unit changed using /1000 to b
+                if (length <=14)
+                    lcd.printString(buffer,0,2);
+                wait(0.1);
+                
+            } 
+            else{
+                char buffer[14];
+                Measurement measurement;  /// measurement structure declared in BMP180 class
+                measurement = bmp180.readValues();
+                wait(0.1);
+
+                int length = sprintf(buffer, "T = %.2f C", measurement.temperature); /// temp unit in Celsius
+                if (length <= 14)
+                    lcd.printString(buffer,0,1);
+                wait(0.1);
+
+                length = sprintf(buffer, "P =%.2f mb ", measurement.pressure); /// pressure unit in mb
+                if (length <=14)
+                    lcd.printString(buffer,0,2);
+                wait(0.1);
+                ///lcd.refresh();
+            }
+            Measurement measurement;  /// measurement structure declared in BMP180 class
+            measurement = bmp180.readValues();
+            wait(0.1);
+            temp=measurement.temperature;
+            
+        
+            
+            if (measurement.temperature > 30) {
+                myled= 0.0; /// LED off
+                myled2=1.0; /// LED on
+                buzzer.beep(1000,0.5); /// Buzzer on when temp is > 30
+
+            }
+
+
+            else if (measurement.temperature < 25) { 
+                myled=1.0; /// led on 
+                myled2=0.0; /// led off
+            }
+
+            else {
+                myled=0.0; /// both leds are off when temp is between 25-30
+                myled2=0.0;
+            }
+
+
+            lcd.setBrightness(1.0); /// put LED backlight on full
+            V= mypotentiometer; /// potentiometer controls brightness of the screen
+            lcd.setBrightness(V);
+
+            wait(0.01);
+
+        }
+
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.h	Mon May 11 23:50:39 2015 +0000
@@ -0,0 +1,59 @@
+/**
+@file main.h
+@brief Header file containing functions prototypes, defines and global variables.
+@brief Revision 1.0.
+@author Laith N. Alnashashibi
+@date   May 2015
+*/
+
+
+
+#include "mbed.h"
+#include "BMP180.h"
+#include "N5110.h"
+#include "beep.h"
+ 
+
+N5110 lcd(p7,p8,p9,p10,p11,p13,p26);
+BMP180 bmp180(p28,p27);   // SDA, SCL
+Serial serial(USBTX,USBRX);
+Measurement measurement;
+/**  
+@namespace beep
+@output for status beep
+*/
+Beep buzzer(p21); ///@see
+/**  
+@namespace myled
+@output for status LED
+*/
+PwmOut myled(p25);
+/**  
+@namespace myled2
+@output for status LED2
+*/
+PwmOut myled2(p24);
+/**  
+@namespace mypotentiometer
+@output for status potentiometer
+*/
+AnalogIn mypotentiometer(p20);
+/**  
+@namespace button
+@output for status button
+*/
+DigitalIn button(p19);
+
+
+int temp; /*!< temp set in ISR */
+float V;
+float array[85];
+float ave;
+float sum=0;
+int counter=0; /*!< counter set in ISR */
+
+
+
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon May 11 23:50:39 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8ab26030e058
\ No newline at end of file