Library of hardware declarations and utility functions for the ELEC350/1 Practicals and Coursework
Dependents: Task618-mbedos-F429ZI Task621-mbedos_FZ429ZI Task622-mbedos-FZ429ZI Task632-mbedos-FZ429 ... more
Diff: sample_hardware.cpp
- Revision:
- 5:58ba1a6dbf60
- Parent:
- 4:d884f14069c6
- Child:
- 6:d95616e645bb
--- 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)