Whether you want to know what altitude your RC aircraft reached, the elevation of the mountain pass through which you’re driving, or how high you and your hiking buddies got on your last trek; the inexpensive MS5611 barometric pressure sensor/altimeter may meet your needs.

Hardware Overview

At the heart of the module is a very small, blazingly fast, precise, low power, low noise barometric pressure sensor, from MEAS Switzerland – MS5611.

ms5611 module hardware overview chip

The MS5611 can measure barometric pressure from 10 mbar to 1200 mbar with absolute accuracy of ±1.5 mbar over the pressure range of 450 to 1100 mbar. Outside that pressure range, the guaranteed accuracy is ± 2.5 mbar.

This barometric pressure sensor is optimized for altimeters and variometers with an altitude resolution of 0.012 mbar, which translates to about 10cm (4″) of altitude.

The MS5611 has an on-chip temperature sensor that can be used to compensate for the changes in the environment and to calibrate the measurements. This is a reasonably precise temperature sensor that measures the ‘die temperature’ in the range of -40˚C to +85˚C with an accuracy of ±0.8˚C.

Power Requirement

The module comes with a MIC5205 3.3V precise voltage regulator and voltage level translator, so you can use it with your favorite 3.3V or 5V microcontroller without worry.

ms5611 module voltage regulator translator

The MS5611 consumes less than 1.4mA during measurements and less than 0.15µA during standby mode. This low power consumption allow the implementation in battery driven devices such as handsets, wearables or smart watches.

Digital interfaces

The MS5611 communicates via either I2C or SPI. The PS (Protocol Select) pin determines which interface is operational.

ms5611 module i2c spi protocol selection pin

Pulling the PS pin to LOW selects the SPI interface, pulling PS to HIGH selects the I2C interface. A 1K pull-up resistor on the module pulls this pin HIGH, so I2C interface is selected by default.

I2C Interface

The sensor uses the I2C interface for communication with the Arduino. It supports two separate I2C addresses: 0x77Hex and 0x76Hex. This allows two MS5611 modules to be used on the same bus or to avoid address conflicts with another device on the bus.

ms5611 module i2c address selection pin

The CSB pin determines the I2C address of the module. This pin has a built-in 2.2K pull-down resistor. Therefore, when you leave the CSB pin unconnected, the default I2C address is 0x77Hex and when you connect it to VCC, the line is pulled HIGH and the I2C address becomes 0x76Hex.

SPI Interface

The sensor is capable of communicating over SPI as well! To enable the SPI interface, connect PS (Protocol Select) pin to ground.

Technical Specifications

Here are the complete specifications:

Power supply3.3V to 5.5V
Current draw~1.4mA (during measurements)
~0.15µA (during standby mode)
Pressure Measurement Range10 to 1200 mbar
Pressure Absolute Accuracy±1.5 mbar
ADC Resolution24 bit
Temperature Range-40ËšC to +85ËšC
Temperature Accuracy±0.8˚C

For more details, please refer below datasheet.

MS5611 Module Pinout

Now let’s have a look at the pinout.

ms5611 module pinout

Power Pins:

VCC is the power pin. You can connect it to 5V output from your Arduino.

GND is the common ground for power and logic.

SPI Logic pins:

SCL is the SPI Clock pin, its an input to the chip.

SDA is the Serial Data In (MOSI) pin, for data sent from your microcontroller to the MS5611.

CSB is the Chip Select pin. If you want to connect multiple MS5611’s to one microcontroller, have them share the SDA, SDO and SCL pins and assign each one a unique CSB pin.

SDO is the Serial Data Out (MISO) pin, for data sent from the MS5611 to your microcontroller.

PS is Protocol Select pin. Pull it LOW to enable an SPI communication.

I2C Logic pins:

SCL is also the I2C clock pin, connect to your microcontrollers I2C clock line.

SDA is also the I2C data pin, connect to your microcontrollers I2C data line.

CSB pin determines the I2C address of the module. When you leave the CSB pin unconnected, the default I2C address is 0x77Hex and when you connect it to VCC, the line is pulled HIGH and the I2C address becomes 0x76Hex.

PS is Protocol Select pin. Leave it unconnected to enable an I2C communication.

Wiring up a MS5611 Module to an Arduino

Now that we know everything about the module, we can begin hooking it up to our Arduino!

Start by connecting the VCC pin to the power supply, 3V-5V is fine. Use the same voltage that your microcontroller logic is based off of. For most Arduinos, that is 5V. For 3.3V logic devices, use 3.3V. Now connect GND to common ground.

Connect the SCL pin to the I2C clock pin and the SDA pin to the I2C data pin on your Arduino. Note that each Arduino Board has different I2C pins which should be connected accordingly. On the Arduino boards with the R3 layout, the SDA (data line) and SCL (clock line) are on the pin headers close to the AREF pin. They are also known as A5 (SCL) and A4 (SDA).

The following illustration shows the wiring.

wiring ms5611 module with arduino

Once your module is connected to the Arduino it’s time to write some code!

Library Installation

To begin reading sensor data, you will need to install the MS5611 library. It is available from the Arduino library manager.

To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries.

manage libraries

Filter your search by typing ‘ms5611‘ and install the library.

ms5611 library installation

WARNING EXPERIMENTAL:

Rob Tillart also wrote MS5611_SPI (an experimental SPI version of the library) to communicate with the MS5611 via the SPI interface. But unfortunately he found that somehow selecting SPI as the protocol causes internal heating, leading to incorrect temperature readings. That’s why we will only cover the I2C interface in our tutorial.

Arduino Code – Reading Pressure and Temperature

Below is a basic Arduino sketch. Go ahead and upload it to your Arduino. You should see pressure and temperature on the serial monitor.

#include "MS5611.h"

MS5611 MS5611(0x77);

void setup() {
  Serial.begin(115200);
  while(!Serial);

  if (!MS5611.begin()) {
    Serial.println("MS5611 not found, check wiring!");
    while (1);
  }
}

void loop() {
  MS5611.read();
  Serial.print("Temperature: ");
  Serial.print(MS5611.getTemperature(), 2);
  Serial.print("\tPressure: ");
  Serial.print(MS5611.getPressure(), 2);
  Serial.println();
  delay(1000);
}

Note that you must set your serial monitor to a speed of 115200 baud to try out the sketch.

You will see a lot of data displaying pressure and temperature values. Try moving your sensor around and notice how the data changes.

ms5611 sensor arduino output

Code Explanation:

The code is quite straightforward. At the beginning, MS5611.h library is included and an object is created in the global space MS5611 MS5611(0x77). Note that the object is constructed with the I2C address as a parameter.

#include <Wire.h>

MS5611 MS5611(0x77);

In the setup, we initialize the serial communication with PC and call the begin() function.

The MS5611.begin() function initializes I2C interface and checks if the chip ID is correct. It then resets the chip using soft-reset & waits for the sensor for calibration after wake-up.

void setup() {
  Serial.begin(115200);
  while(!Serial);

  if (!MS5611.begin()) {
    Serial.println("MS5611 not found, check wiring!");
    while (1);
  }
}

In the loop, we call the MS5611.read() function to perform a reading. Once this is done we can access object’s (MS5611) methods using the dot operator.

MS5611.getTemperature() returns temperature reading.

MS5611.getPressure() returns barometric pressure reading.

void loop() {
  MS5611.read();
  Serial.print("Temperature: ");
  Serial.print(MS5611.getTemperature(), 2);
  Serial.print("\tPressure: ");
  Serial.print(MS5611.getPressure(), 2);
  Serial.println();
  delay(1000);
}

Login
ADS CODE