The Library.
Now you are ready to use the library to your own Apps.
Just copy the fileĀ Bmp180Sensor.cs
from my project to your project and change the namespace to match your projectās namespace.
Use the library like this:
Create a Bmp180Sensor and initialize the sensor (get the calibration data from the sensor and calculate polynomial coefficients).
var
_bmp180 = new
Bmp180Sensor();
await
_bmp180.InitializeAsync();
When the sensor is initialized, if you need to display the calibration data use this property to access them.
_bmp180.CalibrationData
To query the sensor for a Pressure/Temperature measurement use those commands:
var
sensorData = await
_bmp180.GetSensorDataAsync(Bmp180AccuracyMode
.UltraHighResolution);
var
temperature = sensorData.Temperature.ToString(āF1ā);
var
pressure = sensorData.Pressure.ToString(āF2ā);
You can pick between four accuracy modes offered. I am using UltraHighResolution for the best accuracy.
- UltraLowPower: 1 sample/~5ms
- Standard: 2 samples/~8ms
- HighResolution: 4 samples/~14ms
- UltraHighResolution: 8 samples/~26ms
By using different modes the optimum compromise between power consumption, speed and resolution can be selected. Check the table on the senorās datasheet at page 12.
Have fun!
Troubleshooting
If you receiveĀ the exception error "Slave address was not acknowledged."
, itĀ means that your device is not communicating with the Raspberry Pi. You need to check the following things:
- Double check that you have connect your device properly. (i.e. if you have connect the 3.3V Raspberry Pi VCC to the deviceās 5V VCCĀ is wrong! Pi has separate 5V VCC.)
- CheckĀ your module specifications. Some devices work only on 5V. If this is true connect your Raspberry Pi pin 2 or 4 (VCC 5V) to your deviceās VCC pin.
- Make sure that your deviceĀ is not defective.