Barometric Pressure & Temperature Sensor (BMP280)

Let us see how to get the temperature and barometric pressure values using the O Watch sensor board. Before you proceed find out what is barometric pressure.

PressureSensor

The specific sensor used in O Watch is a product/chip named BMP280. To use this sensor we need a software library with easy to use functions to read the sensor values. In this case we will use the BMP280 Library from the awesome folks at Adafruit.

  • The Adafruit BMP library requires the Adafruit Sensor library. Frist download and rename the uncompressed folder Adafruit_Sensor and check that the Adafruit_Sensor folder contains Adafruit_Sensor.h
  • Click to download the Adafruit BMP280 Library.
  • Rename the uncompressed folder Adafruit_BMP280 and check that the Adafruit_BMP280 folder contains Adafruit_BMP280.cpp and Adafruit_BMP280.h.
  • Place both the Adafruit_Sensor and the Adafruit_BMP280 library folders in your arduino/libraries/ folder.
    You may need to create the libraries subfolder if its your first library.
  • Restart the Arduino IDE.

Barometric Pressure, Altitude and Temperature Demo

Here is a simple example that shows these values. This demo is derived from the example provided by Adafruit in their library.

You can copy and paste the above code to load it to your O Watch and see it working. Note the following based on Adafruit documentation:

  • Temperature is calculated and returned in degrees C in the library, it is converted to to F in the example by using the classic F = C * 9/5 + 32 equation.
  • Pressure is returned by the library function in the SI units of Pascals. 100 Pascals = 1 hPa = 1 millibar. Often times barometric pressure is reported in millibar or inches-mercury. For future reference 1 pascal =0.000295333727 inches of mercury, or 1 inch Hg = 3386.39 Pascal. So if you take the pascal value of say 100734 and divide by 3389.39 you’ll get 29.72 inches-Hg. This calculation is done in the example and the result printed is in Hg.
  • You can also calculate Altitude. However, you can only really do a good accurate job of calculating altitude if you know the hPa pressure at sea level for your location and day! The sensor is quite precise but if you do not have the data updated for the current day then it can be difficult to get more accurate than 10 meters.
  • To get the sea level pressure for your location, in US you can use this website: http://www.aviationweather.gov/adds/metars/. Find the station code for your nearest airport from stations.txt link on that page and use that code and select ‘translated’ results. In the resulting page you will be able to see the pressure at the station as well as it gives you the sea level pressure.
  • Substitute the sea level pressure value in the altitude function to get the correct altitude for your location. You can check the altitude(elevation) for your location (choose meters) at http://www.whatismyelevation.com. Be aware that sea level pressure changes during the day and even slight variations impact the altitude calculation.

<< Back: O Watch Sensors | Next: Humidity Sensor >>