for textbook v4.4

Dependencies:   mbed MPL3115A2

Model number : MPL3115A2 module

Connection

Vin → 3.3V (supply voltage)

GND → GND

3vo → 3.3V

INT1 → Non connection

INT2 → Non connection

SCL → p27 (mbed SCL)

SDA → p28 (mbed SDA)

Files at this revision

API Documentation at this revision

Comitter:
HeptaSatTraining2019
Date:
Wed Nov 06 18:51:53 2019 +0000
Commit message:

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
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/MPL3115A2.lib	Wed Nov 06 18:51:53 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/sophtware/code/MPL3115A2/#7c7c1ea6fc33
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Nov 06 18:51:53 2019 +0000
@@ -0,0 +1,52 @@
+#include "mbed.h"
+#include "MPL3115A2.h"
+ 
+I2C i2c(p28, p27);       // sda, scl
+ 
+// Comment out all of the references to 'pc' on this page if you don't have the 
+// serial debug driver for your mbed board installed on your computer. If you do,
+// I personally like to use Putty as the terminal window to capture debug messages.
+Serial pc(USBTX, USBRX); // tx, rx
+ 
+// Again, remove the '&pc' parameter is you're not debugging.
+MPL3115A2 sensor(&i2c, &pc);
+ 
+DigitalOut myled(LED1);     // Sanity check to make sure the program is working.
+DigitalOut powerPin(p21);   // <-- I powered the sensor from a pin. You don't have to.
+ 
+int main() {
+    
+    powerPin = 1;
+    wait_ms(300);
+ 
+    pc.printf("** MPL3115A2 SENSOR **\r\n");
+    sensor.init();
+ 
+    Altitude a;
+    Temperature t;
+    Pressure p;
+    
+    // Offsets for Dacula, GA
+    sensor.setOffsetAltitude(83);
+    sensor.setOffsetTemperature(20);
+    sensor.setOffsetPressure(-32);
+    
+    while(1) 
+    {
+        sensor.readAltitude(&a);
+        sensor.readTemperature(&t);
+        
+        sensor.setModeStandby();
+        sensor.setModeBarometer();
+        sensor.setModeActive();
+        sensor.readPressure(&p);
+        
+        pc.printf("Altitude: %sft, Temp: %sºF, Pressure: %sPa\r\n", a.print(), t.print(), p.print());
+        
+        sensor.setModeStandby();
+        sensor.setModeAltimeter();
+        sensor.setModeActive();
+        
+        wait(1.0);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Nov 06 18:51:53 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file