Test BME80

Committer:
zillkhan
Date:
Tue Sep 21 12:08:54 2021 +0000
Revision:
2:8b4e41e5a4a1
Parent:
1:6dd878905b5c
test bme

Who changed what in which revision?

UserRevisionLine numberNew contents of line
morgandu 0:a0e92a018ff2 1 #include "mbed.h"
morgandu 0:a0e92a018ff2 2 #include "mbed_bme680.h"
morgandu 0:a0e92a018ff2 3
zillkhan 2:8b4e41e5a4a1 4 #define I2C_SDA D14
zillkhan 2:8b4e41e5a4a1 5 #define I2C_SCL D15
zillkhan 2:8b4e41e5a4a1 6
morgandu 1:6dd878905b5c 7 I2C i2c(I2C_SDA, I2C_SCL); // Used inside the BME680 Mbed Lib.
morgandu 0:a0e92a018ff2 8
zillkhan 2:8b4e41e5a4a1 9 BME680 bme680(0xEE);
morgandu 0:a0e92a018ff2 10
morgandu 0:a0e92a018ff2 11 int main()
zillkhan 2:8b4e41e5a4a1 12 {
morgandu 0:a0e92a018ff2 13 if (!bme680.begin()) {
morgandu 0:a0e92a018ff2 14 printf("BME680 Begin failed \r\n");
morgandu 0:a0e92a018ff2 15 return 1;
morgandu 0:a0e92a018ff2 16 }
morgandu 0:a0e92a018ff2 17
morgandu 0:a0e92a018ff2 18 while (true) {
zillkhan 2:8b4e41e5a4a1 19 if (bme680.performReading())
morgandu 0:a0e92a018ff2 20 {
morgandu 0:a0e92a018ff2 21 printf("\r\nTemperature Humidity Pressure VOC\r\n"
morgandu 0:a0e92a018ff2 22 " degC %% hPa KOhms\r\n"
morgandu 0:a0e92a018ff2 23 "------------------------------------------\r\n");
morgandu 0:a0e92a018ff2 24 printf(" %.2f ", bme680.getTemperature());
morgandu 0:a0e92a018ff2 25 printf("%.2f ", bme680.getHumidity());
morgandu 0:a0e92a018ff2 26 printf("%.2f ", bme680.getPressure() / 100.0);
morgandu 0:a0e92a018ff2 27 printf("%0.2f\r\n", bme680.getGasResistance() / 1000.0);
morgandu 0:a0e92a018ff2 28 }
morgandu 0:a0e92a018ff2 29
morgandu 0:a0e92a018ff2 30 thread_sleep_for(1000);
morgandu 0:a0e92a018ff2 31 }
morgandu 0:a0e92a018ff2 32 }