Remarks

Bmp180
Status
Source code GitHub
NuGet package

The BMP180 is a high-precision, low-power barometric pressure sensor. The BMP180 offers a measuring range of 300 to 1100 hPa with an absolute accuracy of down to 0.03 hPa. It's based on piezo-resistive technology for EMC robustness, high accuracy and linearity as well as long term stability. It is designed to be connected directly to a micro-controller via the I2C bus.

Code Example

public class MeadowApp : App<F7Micro, MeadowApp>
{
    Bmp180 bmp180;

    public MeadowApp()
    {
        Console.WriteLine("Initializing...");

        // configure our BME280 on the I2C Bus
        var i2c = Device.CreateI2cBus();
        bmp180 = new Bmp180(i2c);

        // Example that uses an IObersvable subscription to only be notified
        // when the temperature changes by at least a degree, and humidty by 5%.
        // (blowing hot breath on the sensor should trigger)
        bmp180.Subscribe(new FilterableObserver<AtmosphericConditionChangeResult, AtmosphericConditions>(
            h => {
                Console.WriteLine($"Temp and pressure changed by threshold; new temp: {h.New.Temperature}, old: {h.Old.Temperature}");
            },
            e => {
                return (
                    (Math.Abs(e.Delta.Temperature) > 1)
                    &&
                    (Math.Abs(e.Delta.Pressure) > 5)
                    );
            }
            ));

        // classical .NET events can also be used:
        bmp180.Updated += (object sender, AtmosphericConditionChangeResult e) => {
            Console.WriteLine($"Temperature: {e.New.Temperature}°C, Pressure: {e.New.Pressure}hPa");
        };

        // get an initial reading
        ReadConditions().Wait();

        // start updating continuously
        bmp180.StartUpdating();
    }

    protected async Task ReadConditions()
    {
        var conditions = await bmp180.Read();
        Console.WriteLine($"Temperature: {conditions.Temperature}°C, Pressure: {conditions.Pressure}hPa");
    }
}

Sample projects available on GitHub

Wiring Example

To wire a BMP180 to your Meadow board, connect the following:

BMP180 Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3

It should look like the following diagram:

Characteristic Locus
Inheritance System.Object > Bmp180
Implements IAtmosphericSensor IBarometricPressureSensor ITemperatureSensor
Namespace Meadow.Foundation.Sensors.Atmospheric
Assembly Bmp180.dll

Syntax

public class Bmp180 : FilterableChangeObservableBase<AtmosphericConditionChangeResult, AtmosphericConditions>, IAtmosphericSensor, IBarometricPressureSensor, ITemperatureSensor

Constructors

Bmp180(II2cBus, Byte, Bmp180.DeviceMode)

Provide a mechanism for reading the temperature and humidity from a Bmp085 temperature / humidity sensor.

Declaration
public Bmp180(II2cBus i2cBus, byte address = 119, Bmp180.DeviceMode deviceMode = Bmp180.DeviceMode.Standard)

Parameters

Type Name Description
II2cBus i2cBus
System.Byte address
Bmp180.DeviceMode deviceMode

Properties

Conditions

The AtmosphericConditions from the last reading.

Declaration
public AtmosphericConditions Conditions { get; protected set; }

Property Value

Type Description
AtmosphericConditions

DEFAULT_SPEED

Declaration
public static int DEFAULT_SPEED { get; }

Property Value

Type Description
System.Int32

IsSampling

Gets a value indicating whether the analog input port is currently sampling the ADC. Call StartSampling() to spin up the sampling process.

Declaration
public bool IsSampling { get; protected set; }

Property Value

Type Description
System.Boolean

true if sampling; otherwise, false.

Pressure

Pressure

Declaration
public float Pressure { get; }

Property Value

Type Description
System.Single

Temperature

The temperature, in degrees celsius (°C), from the last reading.

Declaration
public float Temperature { get; }

Property Value

Type Description
System.Single

Methods

Dispose()

Declaration
public void Dispose()

RaiseChangedAndNotify(AtmosphericConditionChangeResult)

Declaration
protected void RaiseChangedAndNotify(AtmosphericConditionChangeResult changeResult)

Parameters

Type Name Description
AtmosphericConditionChangeResult changeResult

Read()

Convenience method to get the current sensor readings. For frequent reads, use StartSampling() and StopSampling() in conjunction with the SampleBuffer.

Declaration
public Task<AtmosphericConditions> Read()

Returns

Type Description
System.Threading.Tasks.Task<AtmosphericConditions>

StartUpdating(Int32)

Declaration
public void StartUpdating(int standbyDuration = 1000)

Parameters

Type Name Description
System.Int32 standbyDuration

StopUpdating()

Stops sampling the temperature.

Declaration
public void StopUpdating()

Events

Updated

Declaration
public event EventHandler<AtmosphericConditionChangeResult> Updated

Event Type

Type Description
System.EventHandler<AtmosphericConditionChangeResult>