Matrix - Pressure and Temperature Sensor

From FriendlyARM WiKi
Revision as of 14:47, 23 June 2016 by Yftan (Talk | contribs) (Update Log)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



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.


  • 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
5V Supply Voltage 5V
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: 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.


Connect to NanoPi M1

Refer to the following connection diagram to connect the module to the NanoPi M1:

Connection Details:

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:

Connection Details:

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:

Connection Details:

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:

Connection Details:

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:

$ apt-get update && apt-get install git
$ git clone

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

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



Update Log


  • Added the whole English version


  • Translated into English


  • Re-organized and simplified wiki