BME280 Environmental Sensor
This documentation includes installation guidelines and sample code for your hardware.
Windows 10 IoT Core Library
We upgraded the BME280 sensor to BME680 in the IoT HAT revision 2. We're keeping this documentation for backward compatibility. If you have the IoT HAT revision 2, please use the BME680 library.
The new BME680 sensor adds gas resistance (hence, air quality) reading to the IoT HAT.
BME280Sensor library is responsible for communicating with the BME280 sensor.
To use the library, add the following using statement to the top of your C# code.
Then, create an instance of the BME280Sensor class.
Now you're ready to access the library by calling the bme instance.
Initialization
BME280Sensor
Initiates the BME280 sensor to get temperature, humidity, pressure and altitude.
Parameters
None
Basic Members
Read Temperature
Reads the temperature in Celcius.
Parameters
None
Returns
Double: Temperature in Celcius.
Read Humidity
Reads the relative humidity.
Parameters
None
Returns
Double: Relative humidity.
Read Pressure
Reads the pressure in Pa.
Parameters
None
Returns
Double: Pressure in Pa.
Calculate Altitude
Reads the altitude from the sea level in meters.
Parameters
Double meanSeaLevelPressureInBar: Mean sea level pressure in bar.
Returns
Double: Altitude from the sea level in meters.
Advanced Members
Set Oversamplings and Mode
Sets the oversamplings and sensor mode.
Parameters
HumidityOversampling ho: Humidity oversampling.
TemperatureOversampling to: Temperature oversampling.
PressureOversampling po: Pressure oversampling.
SensorMode mode: Sensor mode.
Returns
Bool: True if successful. False if not.
Set Configuration
Sets the sensor configuration.
Parameters
InactiveDuration id: Inactive duration between normal mode measurements.
FilterCoefficient fc: Filter coefficient.
Returns
Bool: True if successful. False if not.
Disposal
To clean up the resources used by the class, call the Dispose() method it when the application is closing.
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.
BME280 Sample App
This application demonstrates reading environmental data from the sensor.
To run the example:
Open the sample project you downloaded.
Make sure "ARM" is selected from the solution platforms selection.
Deploy the sample to the Raspberry Pi using the "F5" key.
Sample Code
Result
When you run the sample, it prints the environmental data to the Visual Studio Output / Immediate Window.
To stop the application, use the "Stop" button on the Visual Studio.
Last updated