The Barometric Pressure Sensor Module provides extremely accurate atmospheric pressure readings along with a reference temperature reading. The resolution allows altitude changes as small as 13cm to be detected.

The module includes an onboard voltage regulator and logic level shifters, allowing it to operate between 2.3V and 6V. This makes it compatible out of the box with any Arduino boards running at either 3.3V or 5V, with no external level shifters required.

Connections

The module requires 4 connections to your microcontroller:

  • GND
  • VCC (2.3 to 6V)
  • SCL
  • SDA

Connect the module GND, SCL, and SDA pads to your Arduino's matching GND, SCL, and SDA pads as shown below. Connect the module VCC pad to your Arduino's IOREF pad.

Note: some older Arduino boards with pre-R3 headers don't have specific headers for SCL, SDA, and IOREF. In those cases you can connect SCL and SDA to the appropriate connections elsewhere on the headers. For example, the module VCC connection should be linked to 5V if your Arduino runs at 5V, or to 3.3V if your Arduino runs at 3.3V. On Arduino boards based on the ATmega238P MCU, the SCL connection is also available on analog input A5, and the SDL connection is available on analog input A4.

Arduino library

Download the "BaroSensor" library, and install it in your Arduino IDE.

The library can be downloaded from github.com/freetronics/BaroSensor/archive/master.zip.

For detailed instructions on library installation, please see our tutorial How To Install Arduino Libraries.

Example sketch

After the library has been installed in your Arduino IDE, quit and relaunch the IDE to ensure the library has been loaded.

Open the example sketch at File -> Examples -> BaroSensor -> SimpleBaro, or create a new sketch and paste in the following code:

#include <Wire.h>
#include <BaroSensor.h>

void setup()
{
  Serial.begin(9600);
  BaroSensor.begin();
}

void loop()
{
  if(!BaroSensor.isOK()) {
    Serial.print("Sensor not Found/OK. Error: "); 
    Serial.println(BaroSensor.getError());
    BaroSensor.begin(); // Try to reinitialise the sensor if we can
  }
  else {
    Serial.print("Temperature: "); 
    Serial.println(BaroSensor.getTemperature());
    Serial.print("Pressure:    ");
    Serial.println(BaroSensor.getPressure());
  }
  delay(1000);
}

Compile and upload the sketch to your Arduino, then open the Serial Monitor and set the baud rate to 9600bps.

If everything is working correctly, you will see the current temperature and pressure values reported once per second. Try moving the sensor up and down to see if the pressure value changes.

Disabling I2C pull-ups

The I2C bus requires pull-up resistors to function correctly. If you have multiple devices on the bus, each providing their own pull-up resistors, you may need to disable the pull-ups included on the Barometric Pressure Sensor Module. To disable the pull-ups, use a sharp knife such as a scalpel to cut the two tiny tracks that bridge the set of three solder jumper pads together, as shown below.

If you need to reinstate the pull-ups later, you can bridge across the three pads with solder to reconnect them.