RobTillaart / MS5611

Arduino library for MS5611 temperature and pressure sensor
MIT License
17 stars 5 forks source link
arduino pressure sensor temperature

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

MS5611

Arduino library for MS5611 temperature and pressure sensor.

Description

The MS5611-01BA03 is a high resolution pressure (and temperature) sensor a.k.a GY-63. The high resolution is made possible by oversampling many times.

The device address is 0x76 or 0x77 depending on the CSB/CSO pin.

This library only implements the I2C interface.

An experimental SPI version of the library can be found here

Compatibility

The library should be compatible with MS56XX, MS57xx and MS58xx devices (to be tested). Some device types will returns only 50% of the pressure value. This is solved in 0.3.9 by calling reset(1) to select the math used.

Self heating

In some configurations especially when using SPI the sensor showed a self heating. First this was approached as a problem, so investigations were done to understand the cause and how to solve it. During this process the view changed of seeing the higher temperature as a problem to being the solution.

The sensor is primary a pressure sensor and if it is heated by a cause (don't care) it needs compensation. For that the temperature sensor is build in the device. Depending on the configuration self heating can be as low as 0.1°C to as high as 10++ °C.

WARNING One should NOT use 5V to control I2C address line, SPI select, or the protocol select line. This causes extreme heat build up > 10°C.

One should only use 3V3 lines for these "selection lines".

See also - https://github.com/RobTillaart/MS5611_SPI/issues/3

Note: the self heating offset can be compensated with setTemperatureOffset(offset) which allows you to match the temperature with the ambient temperature again. As the self heating effect is not expected to be linear over the full range of the temperature sensor the offset might work only in a smaller range. To have a reliable ambient temperature it is advised to use an dedicated temperature sensor for this (e.g. DS18B20).

Breakout GY-63

//
//  BREAKOUT  MS5611  aka  GY63 - see datasheet
//
//  SPI    I2C
//              +--------+
//  VCC    VCC  | o      |
//  GND    GND  | o      |
//         SCL  | o      |
//  SDI    SDA  | o      |
//  CSO         | o      |
//  SDO         | o L    |   L = led
//          PS  | o    O |   O = opening  PS = protocol select
//              +--------+
//
//  PS to VCC  ==>  I2C  (GY-63 board has internal pull up, so not needed)
//  PS to GND  ==>  SPI
//  CS to VCC  ==>  0x76
//  CS to GND  ==>  0x77
//

Related libraries

For pressure conversions see - https://github.com/RobTillaart/pressure

For temperature conversions see - https://github.com/RobTillaart/Temperature

Release Notes (major)

0.3.0 breaking change

0.3.5 NANO 33 BLE

The I2C/Wire library of the NANO 33 BLE does not see the device on the I2C bus. After hours of testing it looks like that the I2C/Wire library of the NANO 33 BLE does not handle isConnected() like other platforms do. Adding a wire->write(0x00) in isConnected() fixes the problem, however more investigation is needed to understand the root cause.

0.3.9 pressure math

There are MS5611 compatibles for which the math for the pressure is different. See AN520__004: C-code example for MS56xx, MS57xx (except analog sensor), and MS58xx series pressure sensors The difference is in the constants (powers of 2) used to calculate the pressure.

The library implements reset(uint8_t mathMode = 0) to select the mathMode.

See issue #33.

0.4.0 breaking change

refactored the Wire dependency. Affected are:

User has to call Wire.begin() (or equivalent) before calling ms5611.begin()

Interface

#include "MS5611.h"

Base

Oversampling

Some numbers from datasheet, page 3 MAX column rounded up. (see #23) (actual read time differs - see performance sketch)

definition value oversampling ratio resolution (mbar) time (us) notes
OSR_ULTRA_HIGH 12 4096 0.012 9100
OSR_HIGH 11 2048 0.018 4600
OSR_STANDARD 10 1024 0.027 2300
OSR_LOW 9 512 0.042 1200
OSR_ULTRA_LOW 8 256 0.065 600 Default = backwards compatible

Offset

The offset functions are added (0.3.6) to calibrate the sensor against e.g. a local weather station. This calibration can only be done runtime.

Misc

DeviceID

Having a device-ID can be used in many ways:

Note: this is not an official ID from the device / datasheet, it is made up from calibration data.

getManufacturer

The meaning of the manufacturer and serialCode value is unclear.

2nd order pressure compensation

Future

Must

Should

Could

Wont

Support

If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.

Thank you,