Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MPL3115A2
Fork of Hexi_barom_alt_temp_app by
Revision 1:4cd4a1bd710b, committed 2016-08-15
- Comitter:
- GregC
- Date:
- Mon Aug 15 23:45:15 2016 +0000
- Parent:
- 0:97dd02e37c94
- Commit message:
- Barometric pressure and temperature sensing program example for Hexiwear
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Aug 13 16:02:39 2016 +0000
+++ b/main.cpp Mon Aug 15 23:45:15 2016 +0000
@@ -8,12 +8,16 @@
#define MPL3115A2_I2C_ADDRESS (0x60<<1)
-DigitalOut led1(LED1);
+DigitalOut led1(LED_GREEN);
+
+// Initialize Serial port
+Serial pc(USBTX, USBRX);
// Pin connections for Hexiwear
MPL3115A2 MPL3115A2( PTC11, PTC10, MPL3115A2_I2C_ADDRESS);
/* pos [0] = altimeter or pressure value */
/* pos [1] = temperature value */
+
float sensor_data[2];
// main() runs in its own thread in the OS
@@ -22,13 +26,15 @@
// Set over sampling value (see MPL3115A2.h for details)
- MPL3115A2.Oversample_Ratio( OVERSAMPLE_RATIO_64);
+ MPL3115A2.Oversample_Ratio(OVERSAMPLE_RATIO_64);
// Configure the sensor as Barometer.
MPL3115A2.Barometric_Mode();
- while (true) {
+ printf("\rBegin Data Acquisition from MPL3115A2 sensor....\r\n\r\n");
+ wait(0.5);
- MPL3115A2.getAllData( &sensor_data[0]);
+ while(1) {
+ MPL3115A2.getAllData(&sensor_data[0]);
printf("\tPressure: %f\tTemperature: %f\r\n", sensor_data[0], sensor_data[1]);
led1 = !led1;
Thread::wait(500);
