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

From FriendlyELEC WiKi
Jump to: navigation, search
(代码说明)
(Update Log)
 
Line 389: Line 389:
 
===Feb-26-2016===
 
===Feb-26-2016===
 
* Translated into English
 
* 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