Links

BME680 Environmental Sensor

This documentation includes installation guidelines and sample code for your hardware.

Windows 10 IoT Core Library

BME680Sensor library is responsible for communicating with the BME680 sensor.
To use the library, add the following using statement to the top of your C# code.
using TurtaIoTHAT;
Then, create an instance of the BME680Sensor class.
BME680Sensor bme;
Now you're ready to access the library by calling the bme instance.

Initialization

BME680Sensor

Initiates the BME680 sensor to get temperature, humidity, pressure, altitude, and gas resistance.
BME680Sensor()
  • Parameters
    • None

Basic Members

Read Temperature

Reads the temperature in Celcius.
double ReadTemperature()
  • Parameters
    • None
  • Returns
    • Double: Temperature in Celcius.

Read Humidity

Reads the relative humidity.
double ReadHumidity()
  • Parameters
    • None
  • Returns
    • Double: Relative humidity.

Read Pressure

Reads the pressure in Pa.
double ReadPressure()
  • Parameters
    • None
  • Returns
    • Double: Pressure in Pa.

Calculate Altitude

Reads the altitude from the sea level in meters.
double ReadAltitude(double meanSeaLevelPressureInBar)
  • Parameters
    • Double meanSeaLevelPressureInBar: Mean sea level pressure in bar.
  • Returns
    • Double: Altitude from the sea level in meters.

Read Gas Resistance

Reads the gas resistance.
double ReadGasResistance()
  • Parameters
    • None
  • Returns
    • Double: Gas resistance in Ohms.

Read Temperature, Pressure and RH

Reads temperature, pressure and relative humidity.
double[] ReadTPH()
  • Parameters
    • None
  • Returns
    • Double[]: Temperature in Celcius, pressure in Pa and relative humidity respectively.

Disposal

To clean up the resources used by the class, call the Dispose() method it when the application is closing.
void Dispose()
This method cleans the resources used by the class.

Samples

You can copy the example code from https://github.com/Turta-io/IoTHAT/tree/master/Samples/Windows10IoTCore address. There is one example of this library.

BME680 Sample App

This application demonstrates reading environmental data from the sensor.
To run the example:
  1. 1.
    Open the sample project you downloaded.
  2. 2.
    Make sure "ARM" is selected from the solution platforms selection.
  3. 3.
    Deploy the sample to the Raspberry Pi using the "F5" key.
Sample Code
MainPage.xaml.cs
using System.Diagnostics;
using System.Threading;
using Windows.UI.Xaml.Controls;
using TurtaIoTHAT;
namespace BME680SampleApp
{
public sealed partial class MainPage : Page
{
// BME680 Sensor
static BME680Sensor bme;
// Sea level pressure in bar
// Update this from weather forecast to get precise altitude
static double slp = 1033.0;
// Sensor timer
Timer sensorTimer;
public MainPage()
{
this.InitializeComponent();
// Initialize sensor and timer
Initialize();
}
private void Initialize()
{
// Create sensor instance
bme = new BME680Sensor();
// Configure timer to 2000ms delayed start and 2000ms interval
sensorTimer = new Timer(new TimerCallback(SensorTimerTick), null, 2000, 2000);
}
private static void SensorTimerTick(object state)
{
// Write sensor data to output / immediate window
Debug.WriteLine("Temperature.....: " + bme.ReadTemperature().ToString("00.0") + "C");
Debug.WriteLine("Humidity........: %" + bme.ReadHumidity().ToString("00.0" + "RH"));
Debug.WriteLine("Pressure........: " + bme.ReadPressure().ToString(".0") + "Pa");
Debug.WriteLine("Altitude........: " + bme.ReadAltitude(slp).ToString(".0") + "m");
Debug.WriteLine("Gas Resistance..: " + bme.ReadGasResistance().ToString(".0") + "Ohms");
Debug.WriteLine("-----");
}
}
}
Result
When you run the sample, it prints the environmental data to the Visual Studio Output / Immediate Window.
Temperature.....: 24.5C
Humidity........: %56.7RH
Pressure........: 100000.0Pa
Altitude........: 100.0m
Gas Resistance..: 120000Ohms
-----
To stop the application, use the "Stop" button on the Visual Studio.