Bme680Driver 2.0.0

dotnet add package Bme680Driver --version 2.0.0
NuGet\Install-Package Bme680Driver -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bme680Driver" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bme680Driver --version 2.0.0
#r "nuget: Bme680Driver, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Bme680Driver as a Cake Addin
#addin nuget:?package=Bme680Driver&version=2.0.0

// Install Bme680Driver as a Cake Tool
#tool nuget:?package=Bme680Driver&version=2.0.0

BME680 Build Library

C# driver for the Bosch BME680 temperature/humidity/pressure/air quality sensor. This driver is ported from the Bosch C driver.

The driver only supports the I²C protocol at the moment.

The datasheet can be found here.

Example on how to use this library

The easiest way to use this library is by getting it from Nuget or from Github Packages.

A similar version of this driver is included in the Iot.Device.Bindings library which includes many other device bindings.

You can either use the default settings of the sensor which will perform a measurement of temperature, humidity, pressure and gas (volatile organic compounds) or change those settings to suit your use case.

To use the default settings you could do something like this:

class Program
    {
        static async Task Main(string[] args)
        {
            // The constructor will use the default I2C busId (1) and default deviceId (0x76) if non are specified
            using var bme680 = new Bme680(Bme680.SecondaryI2cAddress);

            while (true)
            {
                var measurement = await bme680.PerformMeasurementAsync();

                Console.WriteLine($"Temperature: {measurement.Temperature:0.##}°C");
                Console.WriteLine($"Humidity: {measurement.Humidity:0.##}%");
                Console.WriteLine($"Pressure: {measurement.Pressure:0.##} Pa");
                Console.WriteLine($"Gas Resistance: {measurement.GasResistance:0.##} Ohm");
                Console.WriteLine();

                await Task.Delay(1000);
            }
        }
    }

To use your custom settings you could do something like this:

class Program
    {
        static async Task Main(string[] args)
        {
            // The constructor will use the default I2C busId (1) and default deviceId (0x76) if non are specified
            using var bme680 = new Bme680(Bme680.SecondaryI2cAddress);

            // set custom device settings (A higher sampling also increases the time a measurement will take)
            // A sampling rate of X4 will take roughly 4 times longer than a sampling rate of X1
            // You can find out how long a measurement will take by using the method GetProfileDuration()
            bme680.HumiditySampling = Sampling.X4;
            bme680.TemperatureSampling = Sampling.X1;
            bme680.PressureSampling = Sampling.Skipped;
            bme680.FilterCoefficient = FilterCoefficient.C31;

            // set custom settings for gas conversion
            bme680.GasConversionIsEnabled = true;
            bme680.HeaterIsEnabled = true;
            
            // The BME680 sensor can save up to 10 heater profiles for use                
            // this profile will set the target temperature of the heating plate to 330°C
            // with a heating duration of 120ms and an ambient temperature of 24.0°C
            bme680.SaveHeaterProfileToDevice(HeaterProfile.Profile3, 330, 120, 24.0);
            bme680.CurrentHeaterProfile = HeaterProfile.Profile3;

            Console.WriteLine("Performing measurements with custom configuration:\n");
            while (true)
            {
                // perform the measurement
                var measurement = await bme680.PerformMeasurementAsync();

                // print results
                Console.WriteLine($"Temperature: {measurement.Temperature:0.##}°C");
                Console.WriteLine($"Humidity: {measurement.Humidity:0.##}%");
                Console.WriteLine($"Pressure: {measurement.Pressure:0.##} Pa");
                Console.WriteLine($"Gas Resistance: {measurement.GasResistance:0.##} Ohm");
                Console.WriteLine();

                // it can make sense to update the heater profile continually since the ambient temperature
                // is taken into account when the heater profile is set
                bme680.SaveHeaterProfileToDevice(HeaterProfile.Profile3, 330, 120, measurement.Temperature);
                Task.Delay(1000).Wait();
            }
        }
    }

You can find these examples in the samples folder.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 350 11/24/2022
1.1.0 552 6/23/2020
1.0.10 428 6/20/2019
1.0.9 298 6/20/2019

Breaking Change! Further simplified API usage. Fixed heater configuration not being saved correctly. Now multi-targets frameworks .NET 5/6/7. Upgrade to System.Device.Gpio 2.2.0.