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.
main.cpp@2:c6442e972e68, 2022-02-23 (annotated)
- Committer:
- itbusch
- Date:
- Wed Feb 23 19:17:37 2022 +0000
- Revision:
- 2:c6442e972e68
- Parent:
- 1:6dd878905b5c
xxx_Sensor-BME680
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
morgandu | 0:a0e92a018ff2 | 1 | #include "mbed.h" |
morgandu | 0:a0e92a018ff2 | 2 | #include "mbed_bme680.h" |
morgandu | 0:a0e92a018ff2 | 3 | |
itbusch | 2:c6442e972e68 | 4 | |
morgandu | 1:6dd878905b5c | 5 | I2C i2c(I2C_SDA, I2C_SCL); // Used inside the BME680 Mbed Lib. |
morgandu | 0:a0e92a018ff2 | 6 | |
morgandu | 0:a0e92a018ff2 | 7 | BME680 bme680(0x76 << 1); |
morgandu | 0:a0e92a018ff2 | 8 | |
morgandu | 0:a0e92a018ff2 | 9 | int main() |
morgandu | 0:a0e92a018ff2 | 10 | { |
morgandu | 0:a0e92a018ff2 | 11 | int count = 10; |
morgandu | 0:a0e92a018ff2 | 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) { |
morgandu | 0:a0e92a018ff2 | 19 | if (++count >= 10) |
morgandu | 0:a0e92a018ff2 | 20 | { |
morgandu | 0:a0e92a018ff2 | 21 | count = 0; |
morgandu | 0:a0e92a018ff2 | 22 | printf("\r\nTemperature Humidity Pressure VOC\r\n" |
morgandu | 0:a0e92a018ff2 | 23 | " degC %% hPa KOhms\r\n" |
morgandu | 0:a0e92a018ff2 | 24 | "------------------------------------------\r\n"); |
morgandu | 0:a0e92a018ff2 | 25 | } |
morgandu | 0:a0e92a018ff2 | 26 | |
morgandu | 0:a0e92a018ff2 | 27 | if (bme680.performReading()) |
morgandu | 0:a0e92a018ff2 | 28 | { |
morgandu | 0:a0e92a018ff2 | 29 | printf(" %.2f ", bme680.getTemperature()); |
morgandu | 0:a0e92a018ff2 | 30 | printf("%.2f ", bme680.getHumidity()); |
morgandu | 0:a0e92a018ff2 | 31 | printf("%.2f ", bme680.getPressure() / 100.0); |
morgandu | 0:a0e92a018ff2 | 32 | printf("%0.2f\r\n", bme680.getGasResistance() / 1000.0); |
morgandu | 0:a0e92a018ff2 | 33 | } |
morgandu | 0:a0e92a018ff2 | 34 | |
morgandu | 0:a0e92a018ff2 | 35 | thread_sleep_for(1000); |
morgandu | 0:a0e92a018ff2 | 36 | } |
morgandu | 0:a0e92a018ff2 | 37 | } |