No changes

Files at this revision

API Documentation at this revision

Comitter:
noutram
Date:
Thu Nov 23 10:54:10 2017 +0000
Parent:
4:d884f14069c6
Child:
6:d95616e645bb
Commit message:
Now includes support for the pressure sensor. Depends on the BMP280 driver (see Task690)

Changed in this revision

sample_hardware.cpp Show annotated file Show diff for this revision Revisions of this file
sample_hardware.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/sample_hardware.cpp	Wed Nov 22 15:18:12 2017 +0000
+++ b/sample_hardware.cpp	Thu Nov 23 10:54:10 2017 +0000
@@ -17,11 +17,20 @@
 //Serial pc(USBTX, USBRX);
 AnalogIn adcIn(PA_0);
 
+//Environmental Sensor driver
+#ifdef BME
+BME280 sensor(D14, D15);
+#else
+BMP280 sensor(D14, D15);
+#endif
 
 //POWER ON SELF TEST
 void post() 
 {
     //POWER ON TEST (POT)
+    puts("**********STARTING POWER ON SELF TEST (POST)**********");
+    
+    //Test LEDs
     puts("ALL LEDs should be blinking");
     for (unsigned int n=0; n<10; n++) {
         redLED    = 1;
@@ -39,6 +48,23 @@
     
     //Output the ADC
     printf("ADC: %f\n\r", adcIn.read());
+    
+    //Read Sensors (I2C)
+    float temp = sensor.getTemperature();
+    float pressure = sensor.getPressure();
+    #ifdef BME
+    float humidity = sensor.getHumidity();
+    #endif
+   
+    //Display in PuTTY
+    printf("Temperature: %5.1f\n", temp);
+    printf("Pressure: %5.1f\n", pressure);
+    #ifdef BME
+    printf("Pressure: %5.1f\n", humidity);
+    #endif
+    
+    puts("**********POST END**********");
+ 
 }
 
 void errorCode(ELEC350_ERROR_CODE err)
--- a/sample_hardware.hpp	Wed Nov 22 15:18:12 2017 +0000
+++ b/sample_hardware.hpp	Thu Nov 23 10:54:10 2017 +0000
@@ -1,5 +1,13 @@
 #ifndef __sample_hardware__
 #define __sample_hardware__
+
+//#define BME
+#ifdef BME
+#include "BME280.h"
+#else
+#include "BMP280.h"
+#endif
+
 enum ELEC350_ERROR_CODE {OK, FATAL};
 
 extern DigitalOut onBoardLED;
@@ -13,6 +21,12 @@
 //extern Serial pc;
 extern AnalogIn adcIn;
 
+#ifdef BME
+extern BME280 sensor;
+#else
+extern BMP280 sensor;
+#endif
+
 extern void post();
 extern void errorCode(ELEC350_ERROR_CODE err);