Difference between revisions of "Matrix - Pressure and Temperature Sensor"

From FriendlyELEC WiKi
Jump to: navigation, search
(Created page with "English ==介绍== SPI_TFT * ==特性== * PCB尺寸(mm): File:xxx.png * 引脚说明: {| class="wikita...")
 
(Update Log)
 
(31 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Matrix - SPI TFT|English]]
+
[[Matrix - Pressure and Temperature Sensor/zh|查看中文]]
  
==介绍==
+
==Introduction==
[[File:xxx.png|thumb|SPI_TFT]]
+
[[File:Matrix-Pressure_and_Temperature_Sensor.png|thumb|]]
*
+
* The BMP180 is a high precision, ultra-low power small digital pressure sensor for consumer applications in  mobile phones, PDAs, GPS navigation devices and outdoor equipments. With a low altitude noise of merely 0.25m at fast conversion time, the BMP180 offers superior performance. The I2C interface allows for easy system integration with a microcontroller.
==特性==
+
* The BMP180 is based on piezo-resistive technology for EMC robustness, high accuracy and linearity as well as long term stability.
* PCB尺寸(mm):
+
* The BMP180 consists of a piezo-resistive sensor, an analog to digital converter and a control unit with E2PROM and a serial I2C interface. The E2PROM has stored 176 bit of individual calibration data. This is used to compensate offset, temperature dependence and other parameters of the sensor.
[[File:xxx.png|frameless|400px|]]
+
  
* 引脚说明:
+
==Features==
 +
* I2C,3.3V
 +
* Pressure data(16 to 19 bit)
 +
* Temperature data(16 bit)
 +
* PCB Dimension(mm): 16 x 16
 +
 
 +
[[File:Matrix-Pressure_and_Temperature_Sensor_PCB.png|frameless|400px|]]
 +
 
 +
* Pin Description:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
|名称 || 描述
+
|Pin  || Description
 
|-
 
|-
|S   || GPIO
+
|SDA   || I2C SDA
 
|-
 
|-
|V   || 电源5V
+
|SCL   || I2C SCL
 +
|-
 +
|5V    || Supply Voltage 5V
 
|-
 
|-
|G   ||
+
|GND   || Ground
 
|}
 
|}
  
==工作原理==
+
==Basic Device Operation==
 +
* The mode (ultra low power, standard, high, ultra high resolution) can be selected by the variable oversampling_setting (0, 1, 2, 3) in the C code.
 +
* Calculation of true temperature and pressure in steps of 1Pa (= 0.01hPa = 0.01mbar) and temperature in steps of 0.1°C.
 +
* With the measured pressure p and the pressure at sea level p0 e.g. 1013.25hPa, the altitude in meters can be calculated with the international barometric formula: [[File:Matrix-Pressure_and_Temperature_Sensor_Calculat.png|frameless|400px|]]
 +
* With the measured pressure p and the absolute altitude the pressure at sea level can be calculated:
 +
[[File:Matrix-Pressure_and_Temperature_Sensor_Calculat01.png|frameless|400px|]]
 +
Thus, a difference in altitude of ∆altitude = 10m corresponds to 1.2hPa pressure change at sea level.
  
==下载Matrix源码==
+
==Applications==
Matrix配件相关的代码是完全开源的,统一由一个仓库进行管理:git://github.com/friendlyarm/matrix.git <br>
+
===Connect to NanoPi M1===
该仓库里不同的分支代表着Matrix配件所支持的不同开发板。<br>
+
Refer to the following connection diagram to connect the module to the NanoPi M1:<br>
* nanopi分支包含了Matrix对NanoPi的支持;
+
[[File:Matrix-Pressure_and_Temperature_Sensor_nanopi_m1.jpg|frameless|600px|Matrix-Pressure_and_Temperature_Sensor_nanopi_m1]]
* tiny4412分支包含了Matrix对Tiny4412的支持;
+
* raspberrypi分支包含了Matrix对RaspberryPi的支持;
+
  
在主机PC上安装git,以Ubuntu14.04为例
+
Connection Details:
 +
{| class="wikitable"
 +
|-
 +
|Matrix-Pressure_and_Temperature_Sensor || NanoPi M1     
 +
|-
 +
|SDA    || Pin3
 +
|-
 +
|SCL    || Pin5
 +
|-
 +
|5V    || Pin4
 +
|-
 +
|GND    || Pin6
 +
|}
 +
 
 +
===Connect to NanoPi 2===
 +
Refer to the following connection diagram to connect the module to the NanoPi 2:<br>
 +
[[File:Matrix-Pressure_and_Temperature_Sensor_nanopi_2.jpg|frameless|600px|Matrix-Pressure_and_Temperature_Sensor_nanopi_2]]
 +
 
 +
Connection Details:
 +
{| class="wikitable"
 +
|-
 +
|Matrix-Pressure_and_Temperature_Sensor || NanoPi 2
 +
|-
 +
|SDA    || Pin3
 +
|-
 +
|SCL    || Pin5
 +
|-
 +
|5V    || Pin4
 +
|-
 +
|GND    || Pin6
 +
|}
 +
 
 +
===Connect to NanoPi M2 / NanoPi 2 Fire===
 +
Refer to the following connection diagram to connect the module to the NanoPi M2/ NanoPi 2 Fire:<br>
 +
[[File:Matrix-Pressure_and_Temperature_Sensor_nanopi_M2.jpg|frameless|600px|Matrix-Pressure_and_Temperature_Sensor_nanopi_M2]]
 +
 
 +
Connection Details:
 +
{| class="wikitable"
 +
|-
 +
| || NanoPi M2     
 +
|-
 +
|SDA    || Pin3
 +
|-
 +
|SCL    || Pin5
 +
|-
 +
|5V    || Pin4
 +
|-
 +
|GND    || Pin6
 +
|}
 +
 
 +
===Connect to NanoPC-T2===
 +
Refer to the following connection diagram to connect the module to the NanoPC-T2:<br>
 +
[[File:Matrix-Pressure_and_Temperature_Sensor_NanoPC-T2.jpg|frameless|600px|Matrix-Pressure_and_Temperature_Sensor_NanoPC-T2]]
 +
 
 +
Connection Details:
 +
{| class="wikitable"
 +
|-
 +
|Matrix-Pressure_and_Temperature_Sensor || NanoPC-T2
 +
|-
 +
|SDA    || Pin6
 +
|-
 +
|SCL    || Pin5
 +
|-
 +
|5V    || Pin29
 +
|-
 +
|GND    || Pin30
 +
|}
 +
 
 +
==Compile & Run Test Program==
 +
Boot your ARM board with Debian and copy the matrix code:
 +
<syntaxhighlight lang="bash">
 +
$ apt-get update && apt-get install git
 +
$ git clone https://github.com/friendlyarm/matrix.git
 +
</syntaxhighlight>
 +
If your cloning is done successfully a "matrix" directory will be generated.
 +
 
 +
Compile and install Matrix:
 +
<syntaxhighlight lang="bash">
 +
$ cd matrix
 +
$ make && make install
 +
</syntaxhighlight>
 +
 
 +
Run test program:
 +
<syntaxhighlight lang="bash">
 +
$ matrix-pressure_temp
 +
</syntaxhighlight>
 +
Note: this module is not plug and play therefore before running the module please make sure it is connected to an ARM board.<br>
 +
Here is what you should observe:<br>
 +
<syntaxhighlight lang="bash">
 +
The temperature is 26.6 C
 +
The pressure is 983.91 hPa
 +
The altitude is 247.18
 +
</syntaxhighlight>
 +
 
 +
==Code Sample==
 +
This Matrix code sample can work with all the ARM boards mentioned in this module's wiki. The name of this code sample is "matrix-pressure_and_temperature_sensor". Here is its source code:
 +
<syntaxhighlight lang="c">
 +
int main(int argc, char ** argv)
 +
{
 +
    int ret = -1;
 +
    int bmpTemp=0, bmpPressure=0;
 +
    int board;
 +
    float altitude = 0;
 +
   
 +
    if ((board = boardInit()) < 0) {
 +
        printf("Fail to init board\n");
 +
        return -1;
 +
    }
 +
   
 +
    system("modprobe "DRIVER_MODULE);
 +
    if ((ret = bmp180Read(BMP180_TEMP, &bmpTemp)) != -1) {
 +
        printf("The temperature is %.1f C\n", (float)bmpTemp / 10);
 +
    } else {
 +
        printf("Faided to get humidity\n");
 +
    }
 +
    if ((ret = bmp180Read(BMP180_PRESSURE, &bmpPressure)) != -1) {
 +
        printf("The pressure is %.2f hPa\n", (float)bmpPressure / 100);
 +
    } else {
 +
        printf("Faided to get pressure\n");
 +
    }
 +
 
 +
    altitude = 44330 * ( 1 - pow( ((float)bmpPressure / 100 / 1013.25), (1/5.255) ) );
 +
    printf("The altitude is %.2f m\n", altitude);
 +
    system("rmmod "DRIVER_MODULE);
 +
    return 0;
 +
}
 +
</syntaxhighlight>
 +
For more details about this APIs called in this code sample refer to [[Matrix API reference manual]] <br>
 +
<!---
 +
==Download Matrix Source Code==
 +
All the matrix modules' code samples are open source. They are maintained on GitHub - https://github.com/friendlyarm/matrix.git <br>
 +
Each branch in this hub contains the matrix modules' code samples for a board that the matrix modules can work with.<br>
 +
* The nanopi branch contains the matrix modules' code samples for the NanoPi
 +
* The nanopi 2 branch contains the matrix modules' code samples for the NanoPi 2
 +
* The tiny4412 branch contains the matrix modules' code samples for the Tiny4412
 +
* The raspberrypi branch contains the matrix modules' code samples for the RaspberryPi
 +
 
 +
Please follow the steps below to get the source code:<br>
 +
Install the git utility on a PC running Ubuntu14.04
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ sudo apt-get install git
 
$ sudo apt-get install git
 
</syntaxhighlight>
 
</syntaxhighlight>
  
克隆Matrix配件代码仓库
+
Clone the matrix code from GitHub
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ git clone git://github.com/friendlyarm/matrix.git
+
$ git clone https://github.com/friendlyarm/matrix.git
 
</syntaxhighlight>
 
</syntaxhighlight>
克隆完成后会得到一个matrix目录,里面存放着所有Matrix配件的代码。
+
If this is successful a "matrix" directory will be generated, which will contain all the matrix modules' code samples.
  
==与NanoPi连接使用==
+
==Connect to NanoPi 2==
===准备工作===
+
===Hardware Connection===
在NanoPi上运行Debian系统,然后在主机PC上安装并使用相应的编译器。参考wiki:[[NanoPi/zh|NanoPi]] <br>
+
Please refer to the following connection diagram to connect the Matrix-Pressure_and_Temperature_Sensor to the NanoPi 2:<br>
注意:必须使用nanopi-v4.1.y-matrix分支编译出来的内核。<br>
+
[[File:Matrix-Pressure_and_Temperature_Sensor_nanopi_2.jpg|frameless|600px|Matrix-Pressure_and_Temperature_Sensor_nanopi_2]]
下载NanoPi内核源代码并编译
+
 
 +
Connection Details:
 +
{| class="wikitable"
 +
|-
 +
|Matrix-Pressure_and_Temperature_Sensor_nanopi || NanoPi 2
 +
|-
 +
|SDA    || Pin3
 +
|-
 +
|SCL    || Pin5
 +
|-
 +
|5V    || Pin4
 +
|-
 +
|GND    || Pin6
 +
|}
 +
 
 +
===Compile Test Program===
 +
Please login the matrix hub and enter the nanopi2 branch
 +
<syntaxhighlight lang="bash">
 +
$ cd matrix
 +
$ git checkout nanopi2
 +
</syntaxhighlight>
 +
 
 +
Compile the matrix code
 +
<syntaxhighlight lang="bash">
 +
$ make CROSS_COMPILE=arm-linux- clean
 +
$ make CROSS_COMPILE=arm-linux-
 +
$ make CROSS_COMPILE=arm-linux- install
 +
</syntaxhighlight>
 +
Note: please make sure to install the cross compiler "arm-linux-gcc-4.9.3" on your PC, which is used to compile files for the NanoPi 2.<br>
 +
Generated library files are under the "install/lib" directory. The test program is under the "install/usr/bin" directory.<br>
 +
The modules are under the "modules" directory. The driver's source code is in github: https://github.com/friendlyarm/linux-3.4.y.git <br>
 +
 
 +
===Run Test Program===
 +
Please insert a TF card which is flashed with Debian to a Linux host and mount its boot and rootfs sections.<br>
 +
We assume the rootfs is mounted to /media/rootfs then please run the following commands to copy the module, library and test program to the card.<br>
 +
<syntaxhighlight lang="bash">
 +
$ cp modules /media/rootfs/ -r
 +
$ cp install/lib/* /media/rootfs/lib/ -d
 +
$ cp install/usr/bin/* /media/rootfs/usr/bin/
 +
</syntaxhighlight>
 +
 
 +
Insert this TF card to your NanoPi 2, power on and run the following command to load the driver<br>
 +
<syntaxhighlight lang="bash">
 +
$ cd /modules
 +
$ insmod bmp085.ko
 +
</syntaxhighlight>
 +
 
 +
Start the matrix-pressure_temp program<br>
 +
<syntaxhighlight lang="bash">
 +
$ matrix-pressure_temp
 +
</syntaxhighlight>
 +
Note: this module is not plug and play therefore before running the module please make sure it is connected to a NanoPi 2.<br>
 +
Here is what you expect to observe:<br>
 +
[[File:matrix-pressure_temp_result.png|frameless|600px|matrix-pressure_temp_result]]
 +
 
 +
===Code Sample===
 +
<syntaxhighlight lang="c">
 +
int main(int argc, char ** argv)
 +
{
 +
    int ret = -1;
 +
    int bmpTemp = 0;
 +
    int bmpPressure = 0;
 +
    float altitude = 0;
 +
   
 +
    if ((ret = bmp180Read(BMP180_TEMP, &bmpTemp)) != -1) {
 +
        printf("Get temperature : %.1f C\n", (float)bmpTemp / 10);
 +
    } else {
 +
        printf("Faided to get humidity\n");
 +
    }
 +
 
 +
    if ((ret = bmp180Read(BMP180_PRESSURE, &bmpPressure)) != -1) {
 +
        printf("Get pressure : %.2f hPa\n", (float)bmpPressure / 100);
 +
    } else {
 +
        printf("Faided to get pressure\n");
 +
    }
 +
 
 +
    altitude = 44330 * ( 1 - pow( ((float)bmpPressure / 100 / 1013.25), (1/5.255) ) );
 +
    printf("Get altitude : %.2f m\n", altitude);
 +
    return 0;
 +
}
 +
</syntaxhighlight>
 +
 
 +
==Connect to NanoPi==
 +
===Preparations===
 +
Please install a Debian on a NanoPi and an appropriate cross compiler on a PC. Please refer to wiki: [NanoPi] & [How to Build the Compiling Environment].<br>
 +
Note: please use the kernel's source code from the nanopi-v4.1.y-matrix branch.<br>
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ git clone https://github.com/friendlyarm/linux-4.x.y.git
 
$ git clone https://github.com/friendlyarm/linux-4.x.y.git
Line 53: Line 289:
 
$ make
 
$ make
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
After it is done a zImage will be generated under arch/arm/boot/. You can use it to replace the existing file under sd-fuse_nanopi/prebuilt.
  
===硬件连接===
+
===Hardware Connection===
参考下图连接模块Matrix-SPI_TFT和NanoPi <br>
+
Please refer to the following connection diagram to connect the Matrix-Pressure_and_Temperature_Sensor to the NanoPi:<br>
[[File:Matrix-SPI_TFT_nanopi.jpg|frameless|600px|Matrix-SPI_TFT_nanopi]]
+
[[File:Matrix-Pressure_and_Temperature_Sensor_nanopi.jpg|frameless|600px|Matrix-Pressure_and_Temperature_Sensor_nanopi]]
  
连接说明:
+
Connection Details:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
|Matrix-SPI_TFT || NanoPi
+
|Matrix-Pressure_and_Temperature_Sensor_nanopi || NanoPi
 
|-
 
|-
||| Pin7
+
|SDA    || Pin3
 
|-
 
|-
|V   || Pin4
+
|SCL   || Pin5
 
|-  
 
|-  
||| Pin6
+
|5V    || Pin4
 +
|-
 +
|GND    || Pin6
 
|}
 
|}
  
===加载驱动模块===
+
===Compile Test Program===
启动NanoPi,在其Debian的shell终端上加载芯片的驱动模块
+
Please login the matrix hub and enter the nanopi branch
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ modprobe fbtft_device name=matrix-spi_tft gpios=dc:161,reset:162,cs:163
+
$ cd matrix
$ modprobe matrix_ads7846
+
$ git checkout nanopi
 
</syntaxhighlight>
 
</syntaxhighlight>
fbtft_device是芯片ili9341的驱动,matrix_ads7846是芯片xpt2046的驱动
 
  
===安装软件包===
+
Compile the matrix code
在NanoPi的shell终端上安装软件包qtembedded和matrix-tslib
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ apt-get update
+
$ make CROSS_COMPILE=arm-linux- clean
$ apt-get install qtembedded
+
$ make CROSS_COMPILE=arm-linux-
$ apt-get install matrix-tslib
+
$ make CROSS_COMPILE=arm-linux- install
 
</syntaxhighlight>
 
</syntaxhighlight>
qtembedded是qt相关的库,matrix-tslib则用于触摸屏校准。
+
Note: please make sure to install the cross compiler "arm-linux-gcc-4.4.3" on your PC, which is used to compile files for the NanoPi-Debian.<br>
 +
Generated library files are under the "install/lib" directory. Applications are under the "install/usr/bin" directory. The test program for the "Matrix-Pressure_and_Temperature_Sensor" module is "matrix-pressure_temp".<br>
  
===运行测试程序===
+
===Run Test Program===
启动Qt应用程序
+
Please insert a TF card which is flashed with Debian to a Linux host and mount its boot and rootfs sections.<br>
 +
We assume the rootfs is mounted to /media/rootfs then please run the following commands to copy the module, library and test program to the card.<br>
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ . /usr/bin/matrix-setqt4env
+
$ cp modules /media/rootfs/ -r
$ /usr/local/Trolltech/QtEmbedded-4.8.5-arm/examples/tetrix -qws
+
$ cp install/lib/* /media/rootfs/lib/ -d
 +
$ cp install/usr/bin/* /media/rootfs/usr/bin/
 
</syntaxhighlight>
 
</syntaxhighlight>
matrix-setqt4env用于设置环境变量,第一次运行该脚本时,会出现触摸校准的界面,点击5个点后完成校准。
 
tetrix是一个qt4编写俄罗斯方块小游戏,点击start可以开始娱乐。
 
  
==与Tiny4412连接使用==
+
Insert this TF card to your NanoPi, power on and run the following command to load the driver<br>
 +
<syntaxhighlight lang="bash">
 +
$ cd /modules
 +
$ insmod bmp085-i2c.ko
 +
</syntaxhighlight>
 +
 
 +
Start the matrix-pressure_temp program.<br>
 +
<syntaxhighlight lang="bash">
 +
$ matrix-pressure_temp
 +
</syntaxhighlight>
 +
Note: this module is not plug and play therefore before running the module please make sure it is connected to a NanoPi.<br>
 +
 
 +
===Code Sample===
 +
<syntaxhighlight lang="c">
 +
int main(int argc, char ** argv)
 +
{
 +
    int ret = -1;
 +
    int bmpTemp = 0;
 +
    int bmpPressure = 0;
 +
    float altitude = 0;
 +
   
 +
    if ((ret = bmp180Read(BMP180_TEMP, &bmpTemp)) != -1) {
 +
        printf("Get temperature : %.1f C\n", (float)bmpTemp / 10);
 +
    } else {
 +
        printf("Faided to get humidity\n");
 +
    }
 +
 
 +
    if ((ret = bmp180Read(BMP180_PRESSURE, &bmpPressure)) != -1) {
 +
        printf("Get pressure : %.2f hPa\n", (float)bmpPressure / 100);
 +
    } else {
 +
        printf("Faided to get pressure\n");
 +
    }
 +
 
 +
    altitude = 44330 * ( 1 - pow( ((float)bmpPressure / 100 / 1013.25), (1/5.255) ) );
 +
    printf("Get altitude : %.2f m\n", altitude);
 +
    return 0;
 +
}
 +
</syntaxhighlight>
 +
 
 +
==Connect to Tiny4412==
 +
 
 +
==Connect to RaspberryPi==
 +
 
 +
==Connect to Arduino==
 +
--->
 +
 
 +
==Resources==
 +
[https://ae-bst.resource.bosch.com/media/products/dokumente/bmp180/BST-BMP180-DS000-12~1.pdf BMP180.pdf]
  
==与RaspberryPi连接使用==
+
==Update Log==
 +
===Feb-24-2016===
 +
* Added the whole English version
  
==与Arduino连接使用==
+
===Feb-26-2016===
 +
* Translated into English
  
==相关资料==
+
===June-23-2016===
 +
* Re-organized and simplified wiki

Latest revision as of 14:47, 23 June 2016

查看中文

1 Introduction

Matrix-Pressure and Temperature Sensor.png
  • The BMP180 is a high precision, ultra-low power small digital pressure sensor for consumer applications in mobile phones, PDAs, GPS navigation devices and outdoor equipments. With a low altitude noise of merely 0.25m at fast conversion time, the BMP180 offers superior performance. The I2C interface allows for easy system integration with a microcontroller.
  • The BMP180 is based on piezo-resistive technology for EMC robustness, high accuracy and linearity as well as long term stability.
  • The BMP180 consists of a piezo-resistive sensor, an analog to digital converter and a control unit with E2PROM and a serial I2C interface. The E2PROM has stored 176 bit of individual calibration data. This is used to compensate offset, temperature dependence and other parameters of the sensor.

2 Features

  • I2C,3.3V
  • Pressure data(16 to 19 bit)
  • Temperature data(16 bit)
  • PCB Dimension(mm): 16 x 16

Matrix-Pressure and Temperature Sensor PCB.png

  • Pin Description:
Pin Description
SDA I2C SDA
SCL I2C SCL
5V Supply Voltage 5V
GND Ground

3 Basic Device Operation

  • The mode (ultra low power, standard, high, ultra high resolution) can be selected by the variable oversampling_setting (0, 1, 2, 3) in the C code.
  • Calculation of true temperature and pressure in steps of 1Pa (= 0.01hPa = 0.01mbar) and temperature in steps of 0.1°C.
  • With the measured pressure p and the pressure at sea level p0 e.g. 1013.25hPa, the altitude in meters can be calculated with the international barometric formula: Matrix-Pressure and Temperature Sensor Calculat.png
  • With the measured pressure p and the absolute altitude the pressure at sea level can be calculated:

Matrix-Pressure and Temperature Sensor Calculat01.png Thus, a difference in altitude of ∆altitude = 10m corresponds to 1.2hPa pressure change at sea level.

4 Applications

4.1 Connect to NanoPi M1

Refer to the following connection diagram to connect the module to the NanoPi M1:
Matrix-Pressure_and_Temperature_Sensor_nanopi_m1

Connection Details:

Matrix-Pressure_and_Temperature_Sensor NanoPi M1
SDA Pin3
SCL Pin5
5V Pin4
GND Pin6

4.2 Connect to NanoPi 2

Refer to the following connection diagram to connect the module to the NanoPi 2:
Matrix-Pressure_and_Temperature_Sensor_nanopi_2

Connection Details:

Matrix-Pressure_and_Temperature_Sensor NanoPi 2
SDA Pin3
SCL Pin5
5V Pin4
GND Pin6

4.3 Connect to NanoPi M2 / NanoPi 2 Fire

Refer to the following connection diagram to connect the module to the NanoPi M2/ NanoPi 2 Fire:
Matrix-Pressure_and_Temperature_Sensor_nanopi_M2

Connection Details:

NanoPi M2
SDA Pin3
SCL Pin5
5V Pin4
GND Pin6

4.4 Connect to NanoPC-T2

Refer to the following connection diagram to connect the module to the NanoPC-T2:
Matrix-Pressure_and_Temperature_Sensor_NanoPC-T2

Connection Details:

Matrix-Pressure_and_Temperature_Sensor NanoPC-T2
SDA Pin6
SCL Pin5
5V Pin29
GND Pin30

5 Compile & Run Test Program

Boot your ARM board with Debian and copy the matrix code:

$ apt-get update && apt-get install git
$ git clone https://github.com/friendlyarm/matrix.git

If your cloning is done successfully a "matrix" directory will be generated.

Compile and install Matrix:

$ cd matrix
$ make && make install

Run test program:

$ matrix-pressure_temp

Note: this module is not plug and play therefore before running the module please make sure it is connected to an ARM board.
Here is what you should observe:

The temperature is 26.6 C
The pressure is 983.91 hPa
The altitude is 247.18

6 Code Sample

This Matrix code sample can work with all the ARM boards mentioned in this module's wiki. The name of this code sample is "matrix-pressure_and_temperature_sensor". Here is its source code:

int main(int argc, char ** argv) 
{ 
    int ret = -1;
    int bmpTemp=0, bmpPressure=0;
    int board;
    float altitude = 0;
 
    if ((board = boardInit()) < 0) {
        printf("Fail to init board\n");
        return -1;
    }
 
    system("modprobe "DRIVER_MODULE);
    if ((ret = bmp180Read(BMP180_TEMP, &bmpTemp)) != -1) {
        printf("The temperature is %.1f C\n", (float)bmpTemp / 10);
    } else {
        printf("Faided to get humidity\n");
    }
    if ((ret = bmp180Read(BMP180_PRESSURE, &bmpPressure)) != -1) {
        printf("The pressure is %.2f hPa\n", (float)bmpPressure / 100);
    } else {
        printf("Faided to get pressure\n");
    }
 
    altitude = 44330 * ( 1 - pow( ((float)bmpPressure / 100 / 1013.25), (1/5.255) ) );
    printf("The altitude is %.2f m\n", altitude);
    system("rmmod "DRIVER_MODULE);
    return 0;
}

For more details about this APIs called in this code sample refer to Matrix API reference manual

7 Resources

BMP180.pdf

8 Update Log

8.1 Feb-24-2016

  • Added the whole English version

8.2 Feb-26-2016

  • Translated into English

8.3 June-23-2016

  • Re-organized and simplified wiki