Demo program for the MPL3115A2 library.

Dependencies:   MPL3115A2 mbed

Example program for MPL3115 sensor. Added code for data acquisition using Interrupt.

Files at this revision

API Documentation at this revision

Comitter:
clemente
Date:
Tue Sep 24 20:22:57 2013 +0000
Parent:
6:07f92b4716b6
Commit message:
Added an example to read delta values.

Changed in this revision

MPL3115A2.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
diff -r 07f92b4716b6 -r 97f5edf7d270 MPL3115A2.lib
--- a/MPL3115A2.lib	Sun Sep 22 11:18:08 2013 +0000
+++ b/MPL3115A2.lib	Tue Sep 24 20:22:57 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/clemente/code/MPL3115A2/#75a5960adf5c
+http://mbed.org/users/clemente/code/MPL3115A2/#82ac06669316
diff -r 07f92b4716b6 -r 97f5edf7d270 main.cpp
--- a/main.cpp	Sun Sep 22 11:18:08 2013 +0000
+++ b/main.cpp	Tue Sep 24 20:22:57 2013 +0000
@@ -24,7 +24,7 @@
     pc.baud( 230400);
     pc.printf("MPL3115A2 Sensor. [%X]\r\n", wigo_sensor1.getDeviceID());
         
-#if 1
+#if 0
     // ***** Data acquisition using Interrupt
     
     // Configure the sensor as Barometer.
@@ -97,6 +97,28 @@
     }
 #endif
 
+#if 1
+    // ***** Data acquisition using polling method and delta values
+
+    // Array for the dela values
+    float delta[2];
+    
+    // Set over sampling value (see MPL3115A2.h for details)
+    wigo_sensor1.Oversample_Ratio( OVERSAMPLE_RATIO_128);
+    // Configure the sensor as Barometer.
+    wigo_sensor1.Barometric_Mode();
+
+    while(1) {
+        //
+        if ( wigo_sensor1.getAllData( &sensor_data[0], &delta[0])) {
+            pc.printf("\tPressure: %f\tTemperature: %f\r\n", sensor_data[0], sensor_data[1]);
+            pc.printf("\tDelatPress: %f\tDeltaTemp: %f\r\n", delta[0], delta[1]);
+        }
+        //
+        wait( 1.0);
+    }
+#endif
+
 #if 0
     // ***** Data acquisition in RAW mode using polling method