2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
[![Arduino CI](https://github.com/RobTillaart/MS5611/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
2021-12-22 04:13:21 -05:00
|
|
|
[![Arduino-lint](https://github.com/RobTillaart/MS5611/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/MS5611/actions/workflows/arduino-lint.yml)
|
|
|
|
[![JSON check](https://github.com/RobTillaart/MS5611/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/MS5611/actions/workflows/jsoncheck.yml)
|
2021-01-29 06:31:58 -05:00
|
|
|
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/MS5611/blob/master/LICENSE)
|
|
|
|
[![GitHub release](https://img.shields.io/github/release/RobTillaart/MS5611.svg?maxAge=3600)](https://github.com/RobTillaart/MS5611/releases)
|
|
|
|
|
2021-12-22 04:13:21 -05:00
|
|
|
|
2020-11-27 05:20:37 -05:00
|
|
|
# MS5611
|
|
|
|
|
2021-12-22 04:13:21 -05:00
|
|
|
Arduino library for MS5611 temperature and pressure sensor.
|
2020-11-27 05:20:37 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2020-11-27 05:20:37 -05:00
|
|
|
## Description
|
|
|
|
|
|
|
|
The MS5611 is a high resolution temperature and pressure sensor.
|
2021-01-29 06:31:58 -05:00
|
|
|
The high resolution is made possible by oversampling (many times).
|
|
|
|
|
2021-12-22 04:13:21 -05:00
|
|
|
The device address is 0x76 or 0x77 depending on the CSB pin.
|
|
|
|
|
2022-01-14 07:34:56 -05:00
|
|
|
This library only implements the I2C interface.
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
// +--------+
|
|
|
|
//
|
|
|
|
// PS to VCC ==> I2C
|
|
|
|
// PS to GND ==> SPI
|
|
|
|
// CS to VCC ==> 0x76
|
|
|
|
// CS to GND ==> 0x77
|
|
|
|
//
|
|
|
|
```
|
|
|
|
|
|
|
|
## important Changes
|
|
|
|
|
|
|
|
#### 0.3.0 breaking change
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2021-12-22 04:13:21 -05:00
|
|
|
1. fixed math error so previous versions are **obsolete**.
|
2021-01-29 06:31:58 -05:00
|
|
|
2. temperature is a float expressed in degrees Celsius.
|
|
|
|
3. pressure is a float expressed in mBar.
|
2020-11-27 05:20:37 -05:00
|
|
|
|
|
|
|
|
2022-01-14 07:34:56 -05:00
|
|
|
#### 0.3.5 NANO 33 BLE
|
|
|
|
|
|
|
|
After lots of hours of testing it appeared that the I2C/Wire library of the NANO 33 BLE
|
|
|
|
does not handle **isConnected()** like other platforms do.
|
|
|
|
It looks like an uninitialized length of the I2C buffer, causing failure when calling **begin()**.
|
|
|
|
Adding a **wire->write(0x00)** seems to fix the issue.
|
|
|
|
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
## Interface
|
2020-11-27 05:20:37 -05:00
|
|
|
|
2021-12-22 04:13:21 -05:00
|
|
|
- **MS5611(uint8_t deviceAddress)** constructor.
|
2021-01-29 06:31:58 -05:00
|
|
|
- **bool begin(uint8_t sda, uint8_t scl, TwoWire \*wire = &Wire)** for ESP and alike, optionally set Wire interface. initializes internals,
|
2021-12-22 04:13:21 -05:00
|
|
|
- **bool begin(TwoWire \*wire = &Wire)** for UNO and alike, optionally set Wire interface. Initializes internals.
|
|
|
|
- **bool isConnected()** checks availability of device address on the I2C bus.
|
|
|
|
- **reset()** resets the chip and loads constants from its ROM.
|
2021-12-24 06:14:45 -05:00
|
|
|
- **int read(uint8_t bits)** the actual reading of the sensor. Returns MS5611_READ_OK upon success.
|
2022-01-14 07:34:56 -05:00
|
|
|
- **int read()** the actual reading of the sensor, uses the preset oversampling (see below). Returns MS5611_READ_OK upon success.
|
2021-12-24 06:14:45 -05:00
|
|
|
- **void setOversampling(osr_t samplingRate)** sets the amount of oversampling.
|
|
|
|
See table below and test example how to use.
|
|
|
|
- **osr_t getOversampling()** returns amount of oversampling.
|
|
|
|
- **float getTemperature()** returns temperature in °C. Subsequent calls will return same value until a new **read()** is called.
|
2021-01-29 06:31:58 -05:00
|
|
|
- **float getPressure()** pressure is in mBar. Subsequent calls will return same value until a new **read()** is called.
|
|
|
|
- **int getLastResult()** checks last I2C communication (replace with more informative error handling?)
|
2022-01-14 07:34:56 -05:00
|
|
|
- **uint32_t lastRead()** last time when **read()** was called in milliseconds since startup.
|
2021-12-24 06:14:45 -05:00
|
|
|
|
|
|
|
|
|
|
|
#### Oversampling table
|
|
|
|
|
2022-01-14 07:34:56 -05:00
|
|
|
(numbers from datasheet, actual time differs - todo)
|
|
|
|
|
2021-12-27 14:39:07 -05:00
|
|
|
| definition | value | oversampling ratio | resolution (mbar) | time (ms) | notes |
|
|
|
|
|:--------------:|:-----:|:------------------:|:----------------:|:---------:|:------:|
|
|
|
|
| OSR_ULTRA_HIGH | 12 | 4096 | 0.012 | 8.22 |
|
|
|
|
| OSR_HIGH | 11 | 2048 | 0.018 | 4.1 |
|
|
|
|
| OSR_STANDARD | 10 | 1024 | 0.027 | 2.1 |
|
|
|
|
| OSR_LOW | 9 | 512 | 0.042 | 1.1 |
|
|
|
|
| OSR_ULTRA_LOW | 8 | 256 | 0.065 | 0.5 | Default = backwards compatible
|
2020-11-27 05:20:37 -05:00
|
|
|
|
|
|
|
|
|
|
|
## Disclaimer
|
|
|
|
|
2022-01-14 07:34:56 -05:00
|
|
|
The library is still experimental. So all feedback is welcome.
|
2020-11-27 05:20:37 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2021-12-22 04:13:21 -05:00
|
|
|
## Operation
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2021-12-22 04:13:21 -05:00
|
|
|
See examples
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
|
2021-12-22 04:13:21 -05:00
|
|
|
## Future
|
|
|
|
|
|
|
|
- update documentation
|
|
|
|
- create a SPI based library (same base class if possible?)
|
2022-01-14 07:34:56 -05:00
|
|
|
- first get it working 100%
|
2021-12-22 04:13:21 -05:00
|
|
|
- proper error handling
|
|
|
|
- redo lower level functions?
|
2022-01-14 07:34:56 -05:00
|
|
|
- handle the read + math of temperature first?
|
|
|
|
- add get- and setPressureOffset()
|
|
|
|
- add get- and setTemperatureOffset()
|
2020-11-27 05:20:37 -05:00
|
|
|
|