Last active
July 9, 2019 12:00
-
-
Save Isaac-the-Man/c1ea944f0e9d82ba162579515156876b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * BME680 multi-function sensor | |
| * By Steven Wang @simplycodebased.org | |
| * 7/9/2019 | |
| */ | |
| #include <Wire.h> | |
| #include <Adafruit_Sensor.h> | |
| #include "Adafruit_BME680.h" | |
| #define SEALEVELPRESSURE_HPA (1013.25) | |
| Adafruit_BME680 bme; // I2C | |
| void setup() { | |
| Serial.begin(9600); | |
| while (!Serial); | |
| Serial.println(F("BME680 test")); | |
| if (!bme.begin()) { | |
| Serial.println("Could not find a valid BME680 sensor, check wiring!"); | |
| while (1); | |
| } | |
| // Set up oversampling and filter initialization | |
| bme.setTemperatureOversampling(BME680_OS_8X); | |
| bme.setHumidityOversampling(BME680_OS_2X); | |
| bme.setPressureOversampling(BME680_OS_4X); | |
| bme.setIIRFilterSize(BME680_FILTER_SIZE_3); | |
| bme.setGasHeater(320, 150); // 320*C for 150 ms | |
| } | |
| void loop() { | |
| if (! bme.performReading()) { | |
| Serial.println("Failed to perform reading :("); | |
| return; | |
| } | |
| Serial.print("Temperature = "); | |
| Serial.print(bme.temperature); | |
| Serial.println(" *C"); | |
| Serial.print("Pressure = "); | |
| Serial.print(bme.pressure / 100.0); | |
| Serial.println(" hPa"); | |
| Serial.print("Humidity = "); | |
| Serial.print(bme.humidity); | |
| Serial.println(" %"); | |
| Serial.print("Gas = "); | |
| Serial.print(bme.gas_resistance / 1000.0); | |
| Serial.println(" KOhms"); | |
| Serial.print("Approx. Altitude = "); | |
| Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); | |
| Serial.println(" m"); | |
| Serial.println(); | |
| delay(2000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment