14.2.2018

foto Petr Bravenec

Petr Bravenec
Twitter: @BravenecPetr
+420 777 566 384
petr.bravenec@hobrasoft.cz

I received a very cheap sensor for measuring atmospheric pressure. The sensor can be purchased from Banggood or other sellers - look for BMP280.

For the price of several euros, the sensor has excellent features:

  • Connection via I2C or SPI.
  • Driver built directly into the Linux kernel.
  • Absolute accuracy ±1 hPa.
  • Relative accuracy ±0.12 hPa.
  • Power 3.3 V.
  • Consumption 2.7 μA.

Relative accuracy allows you to reliably recognize the height change of one meter. The sensor can therefore be used, for example, for the altimeter in RC models.

Connection

The sensor can be connected via both I2C and SPI. If the sensor is connected to BeagleBone, it is better to use I2C bus. The I2C pins are used for EEPROM memory and other I2C devices on expansion boards. Connecting another sensor on the I2C bus will not consume another CPU pins.

Na nabídku rozšiřujících desek se můžete podívat v sekci hardware.

For the first experiments I recommend using a universal board or a simple wire installation via interconnecting wires with end connectors.

SensorBeagleBone
VCCP9.3
GNDP9.1
SCLP9.19
SDAP9.20

Installation

Using i2cdetect utility find your sensor. I have found my sensor on address 0x76:

root@beaglebone:~# i2cdetect -y -r 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU
70: -- -- -- -- -- -- UU --
root@beaglebone:~#

On addresses 0x54, 0x55, 0x56 and 0x57 are EEPROMs of expanding boards. On address 0x6f is real time clock. And finaly on address 0x76 is the pressure sensor.

Then inform your linux kernel how to handle the sensor on I2C bus:

root@beaglebone:~# echo bmp280 0x76 > /sys/class/i2c-adapter/i2c-2/new_device

The appropriate kernel module will be loaded and the sensor will be made accessible. The pressure value can be read from file in /sys directory:

root@beaglebone:~# cat /sys/bus/i2c/devices/i2c-2/2-0076/iio\:device0/in_pressure_input
96.608011718

The pressure unit is kPa.

You can also find temperature data in the same directory or you can set the frequency of the measurement. Our sensor is located in a building, so the temperature data can not be used. Instead, values from two different thermometers located on the east and western window of the building are used. A lower temperature value is always used.

Current values

Time
Measured pressure Pa
Sea-level pressure Pa
Temperature °C

Sea-level pressure correnction

The output from the sensor is the absolute value of the atmospheric pressure. To compare air pressure from different places on the earth, the correction to sea-level is required:

P 0 = P 1- 0,0065h t+0,0065h+273,15 -5.258

To view the equation correctly, use a MathML-enabled web browser, such as Firefox.

Comparison with other sensors in Rožnov

The sensor is placed in Rožnov pod Radhoštěm. Several other sensors are located nearby:

The first two sensors come from the same manufacturer. Measured absolute pressure for these two sensors corresponds to the value measured in the Hobrasoft office. The pressure converted to sea level, however, varies considerably. Third sensor in Zašová (roughly 10 km away) gives a recalculated value comparable to our sensor.

The sea-level pressure of our sensor corresponds with tolerance up to one hPa with meteorological models Aladin or Klara.

The equations listed above, as well as the different calculators available on the Internet, denote the value of the first two sensors differently. Therefore, the conversion of the first two sensors is probably erroneous.

Conclusion

If you want to put the pressure sensor into the RC model, for example, it would be better to use a single-chip controller. Design with ARM Cortex-M0 CPU, the sensor, an EEPROM for data storage and a battery weights only a few grams. However, the development of such a device would take a lot of time.

Linux and BeagleBone is an amazing tool to control devices such the pressure sensor BMP280 is. Linux has a lot of drivers and known devices are often very easy to connect.

Hobrasoft s.r.o. | Contact