Zhang Yuexin

C# programmer. Know a bit of hardware knowledge. 3D model design novice.

张高兴 - 土味儿编程


张高兴的 Windows 10 IoT 开发笔记:BMP180 气压传感器

本文约 295 字,包含 0 张图片,5 个代码段,阅读时间约 1 分钟
QR Code


This is a Windows 10 IoT Core project on the Raspberry Pi 2/3, coded by C#.



Sensor data 'Altitude' is inaccurate !

This project does not include try-catch.


  • SDA - Pin3
  • SCL - Pin5
  • VCC - 3.3/5V
  • GND - GND


In English : https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/BMP180/Reference

What Contains

In BMP180.cs file

Two Structs

Calibration and BMP180Data. In Calibration, there are sensor calibration data. BMP180Data is used to return sensor data.

One Enum Type

Resolution. It is used to set BMP180 sensor pressure sampling accuracy modes.

One Constructor

You need to pass 'Resolution' to create a new object.

Seven Methods

Include four private methods and three public methods.

Private Methods

// Read calibration data from sensor
private void ReadCalibrationData();
// Get uncompensated temperature
private async Task<double> ReadUncompensatedTempDataAsync();
// Get uncompensated pressure
private async Task<double> ReadUncompensatedPressDataAsync();
// Get true data by calculating
private void CalculateTrueData(double UT, double UP, out double T, out double P);

Public Methods

// Initialize BMP180 sensor
public async Task InitializeAsync();
// Read data from BMP180 sensor
public async Task<BMP180Data> ReadAsync();
// Cleanup
public void Dispose();

How to Use

  • First, you need to create a BMP180 object. After that you should call InitializeAsync() to initialize.
BMP180 sensor = new BMP180(Resolution.UltrHighResolution);
await sensor.InitializeAsync();
  • Second, ReadAsync().
var data = await sensor.ReadAsync();
  • If you want to close the sensor, call Dispose().
最后更新时间 : 2017/01/24 21:14 张高兴 阅读(776) 评论(0)
文章标签: C# UWP IoT Raspberry Pi
Click to Refresh