0.4.0 MS5611

This commit is contained in:
Rob Tillaart 2023-11-14 16:25:27 +01:00
parent 08d123b360
commit 596e6d78f8
23 changed files with 360 additions and 99 deletions

View File

@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.4.0] - 2023-11-14
- simplify begin()
- refactor constructor
- update readme.md
- update examples
- add ESP32 and RP2040 minimal example.
- update keywords.txt
----
## [0.3.9] - 2022-10-26 ## [0.3.9] - 2022-10-26
- add RP2040 support to build-CI - add RP2040 support to build-CI
- add CHANGELOG.md - add CHANGELOG.md

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2014-2023 Rob Tillaart Copyright (c) 2014-2024 Rob Tillaart
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -2,8 +2,8 @@
// FILE: MS5611.cpp // FILE: MS5611.cpp
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// Erni - testing/fixes // Erni - testing/fixes
// VERSION: 0.3.9 // VERSION: 0.4.0
// PURPOSE: MS5611 Temperature & Humidity library for Arduino // PURPOSE: Arduino library for MS5611 temperature and pressure sensor
// URL: https://github.com/RobTillaart/MS5611 // URL: https://github.com/RobTillaart/MS5611
// //
// HISTORY see changelog.md // HISTORY see changelog.md
@ -24,9 +24,10 @@
// //
// PUBLIC // PUBLIC
// //
MS5611::MS5611(uint8_t deviceAddress) MS5611::MS5611(uint8_t deviceAddress, TwoWire * wire)
{ {
_address = deviceAddress; _address = deviceAddress;
_wire = wire;
_samplingRate = OSR_ULTRA_LOW; _samplingRate = OSR_ULTRA_LOW;
_temperature = MS5611_NOT_READ; _temperature = MS5611_NOT_READ;
_pressure = MS5611_NOT_READ; _pressure = MS5611_NOT_READ;
@ -39,30 +40,9 @@ MS5611::MS5611(uint8_t deviceAddress)
} }
#if defined (ESP8266) || defined(ESP32) bool MS5611::begin()
bool MS5611::begin(uint8_t dataPin, uint8_t clockPin, TwoWire * wire)
{ {
if ((_address < 0x76) || (_address > 0x77)) return false; if ((_address < 0x76) || (_address > 0x77)) return false;
_wire = wire;
if ((dataPin < 255) && (clockPin < 255))
{
_wire->begin(dataPin, clockPin);
} else {
_wire->begin();
}
if (! isConnected()) return false;
return reset();
}
#endif
bool MS5611::begin(TwoWire * wire)
{
if ((_address < 0x76) || (_address > 0x77)) return false;
_wire = wire;
_wire->begin();
if (! isConnected()) return false; if (! isConnected()) return false;
return reset(); return reset();

View File

@ -3,7 +3,7 @@
// FILE: MS5611.h // FILE: MS5611.h
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// Erni - testing/fixes // Erni - testing/fixes
// VERSION: 0.3.9 // VERSION: 0.4.0
// PURPOSE: Arduino library for MS5611 temperature and pressure sensor // PURPOSE: Arduino library for MS5611 temperature and pressure sensor
// URL: https://github.com/RobTillaart/MS5611 // URL: https://github.com/RobTillaart/MS5611
@ -30,7 +30,7 @@
// CS to GND ==> 0x77 // CS to GND ==> 0x77
#define MS5611_LIB_VERSION (F("0.3.9")) #define MS5611_LIB_VERSION (F("0.4.0"))
#ifndef MS5611_DEFAULT_ADDRESS #ifndef MS5611_DEFAULT_ADDRESS
#define MS5611_DEFAULT_ADDRESS 0x77 #define MS5611_DEFAULT_ADDRESS 0x77
@ -54,12 +54,9 @@ enum osr_t
class MS5611 class MS5611
{ {
public: public:
explicit MS5611(uint8_t deviceAddress = MS5611_DEFAULT_ADDRESS); explicit MS5611(uint8_t deviceAddress = MS5611_DEFAULT_ADDRESS, TwoWire *wire = &Wire);
#if defined (ESP8266) || defined(ESP32) bool begin();
bool begin(uint8_t sda, uint8_t scl, TwoWire *wire = &Wire);
#endif
bool begin(TwoWire *wire = &Wire);
bool isConnected(); bool isConnected();
// reset command + get constants // reset command + get constants

View File

@ -2,13 +2,16 @@
[![Arduino CI](https://github.com/RobTillaart/MS5611/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) [![Arduino CI](https://github.com/RobTillaart/MS5611/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/MS5611/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/MS5611/actions/workflows/arduino-lint.yml) [![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) [![JSON check](https://github.com/RobTillaart/MS5611/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/MS5611/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/MS5611.svg)](https://github.com/RobTillaart/MS5611/issues)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/MS5611/blob/master/LICENSE) [![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) [![GitHub release](https://img.shields.io/github/release/RobTillaart/MS5611.svg?maxAge=3600)](https://github.com/RobTillaart/MS5611/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/MS5611.svg)](https://registry.platformio.org/libraries/robtillaart/MS5611)
# MS5611 # MS5611
Arduino library for MS5611 pressure (and temperature) sensor. Arduino library for MS5611 temperature and pressure sensor.
## Description ## Description
@ -118,19 +121,29 @@ The library implements **reset(uint8_t mathMode = 0)** to select the mathMode.
See issue #33. See issue #33.
#### 0.4.0 breaking change
refactored the Wire dependency. Affected are:
- constructor
- begin()
User has to call **Wire.begin()** (or equivalent) before calling **ms5611.begin()**
## Interface ## Interface
```cpp
#include "MS5611.h"
```
#### Base #### Base
- **MS5611(uint8_t deviceAddress = MS5611_DEFAULT_ADDRESS)** constructor. - **MS5611(uint8_t deviceAddress = MS5611_DEFAULT_ADDRESS, TwoWire \*wire = &Wire)** constructor.
Since 0.3.7 a default address 0x77 is added. Since 0.3.7 a default address 0x77 is added. Optionally set Wire interface.
- **bool begin(uint8_t sda, uint8_t scl, TwoWire \*wire = &Wire)** for ESP and alike, optionally set Wire interface. - **bool begin()**
Initializes internals by calling reset().
Return false indicates either isConnected() error or reset() error.
- **bool begin(TwoWire \*wire = &Wire)** for UNO and alike, optionally set Wire interface.
Initializes internals by calling reset(). Initializes internals by calling reset().
Return false indicates either isConnected() error or reset() error. Return false indicates either isConnected() error or reset() error.
One must call **Wire.begin()** (or equivalent) before calling **begin()**.
- **bool isConnected()** checks availability of device address on the I2C bus. - **bool isConnected()** checks availability of device address on the I2C bus.
(see note above NANO 33 BLE). (see note above NANO 33 BLE).
- **bool reset(uint8_t mathMode = 0)** resets the chip and loads constants from its ROM. - **bool reset(uint8_t mathMode = 0)** resets the chip and loads constants from its ROM.
@ -218,22 +231,30 @@ Disabling the compensation will be slightly faster but you loose precision.
- **getCompensation()** returns flag set above. - **getCompensation()** returns flag set above.
## Operation
See examples
## Future ## Future
#### must #### Must
- update documentation - update documentation
#### should #### Should
- proper error handling. - proper error handling.
- move all code to .cpp - move all code to .cpp
#### could #### Could
- redo lower level functions? - redo lower level functions?
- handle the read + math of temperature first? - handle the read + math of temperature first?
#### 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,

View File

@ -26,6 +26,7 @@
// CS to VCC ==> 0x76 // CS to VCC ==> 0x76
// CS to GND ==> 0x77 // CS to GND ==> 0x77
MS5611 MS5611(0x77); MS5611 MS5611(0x77);
#ifndef LED_BUILTIN #ifndef LED_BUILTIN
@ -39,14 +40,15 @@ void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); while (!Serial);
pinMode(LED_BUILTIN, OUTPUT);
Serial.println(); Serial.println();
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("MS5611_LIB_VERSION: "); Serial.print("MS5611_LIB_VERSION: ");
Serial.println(MS5611_LIB_VERSION); Serial.println(MS5611_LIB_VERSION);
Serial.println();
pinMode(LED_BUILTIN, OUTPUT);
Wire.begin();
if (MS5611.begin() == true) if (MS5611.begin() == true)
{ {
Serial.println("MS5611 found."); Serial.println("MS5611 found.");

View File

@ -6,8 +6,8 @@
// URL: https://github.com/RobTillaart/MS5611 // URL: https://github.com/RobTillaart/MS5611
#include "Arduino.h" #include "MS5611.h"
#include "Wire.h"
// BREAKOUT MS5611 aka GY63 - see datasheet // BREAKOUT MS5611 aka GY63 - see datasheet
// //
@ -31,12 +31,18 @@
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial);
Serial.println();
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("MS5611_LIB_VERSION: ");
Serial.println(MS5611_LIB_VERSION);
Serial.println();
Wire.begin(); Wire.begin();
Wire.beginTransmission(0x76); Wire.beginTransmission(0x76);
Wire.write(0); Wire.write(0);
int x = Wire.endTransmission(); int x = Wire.endTransmission();
Wire.beginTransmission(0x77); Wire.beginTransmission(0x77);
Wire.write(0); Wire.write(0);
int y = Wire.endTransmission(); int y = Wire.endTransmission();

View File

@ -26,6 +26,7 @@
// CS to VCC ==> 0x76 // CS to VCC ==> 0x76
// CS to GND ==> 0x77 // CS to GND ==> 0x77
MS5611 MS5611(0x77); MS5611 MS5611(0x77);
@ -36,14 +37,15 @@ void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); while (!Serial);
pinMode(LED_BUILTIN, OUTPUT);
Serial.println(); Serial.println();
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("MS5611_LIB_VERSION: "); Serial.print("MS5611_LIB_VERSION: ");
Serial.println(MS5611_LIB_VERSION); Serial.println(MS5611_LIB_VERSION);
Serial.println();
pinMode(LED_BUILTIN, OUTPUT);
Wire.begin();
if (MS5611.begin() == true) if (MS5611.begin() == true)
{ {
Serial.print("MS5611 found: "); Serial.print("MS5611 found: ");

View File

@ -8,6 +8,7 @@
#include "MS5611.h" #include "MS5611.h"
// BREAKOUT MS5611 aka GY63 - see datasheet // BREAKOUT MS5611 aka GY63 - see datasheet
// //
// SPI I2C // SPI I2C
@ -26,19 +27,21 @@
// CS to VCC ==> 0x76 // CS to VCC ==> 0x76
// CS to GND ==> 0x77 // CS to GND ==> 0x77
MS5611 MS5611(0x77); MS5611 MS5611(0x77);
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while(!Serial); while (!Serial);
Serial.println(); Serial.println();
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("MS5611_LIB_VERSION: "); Serial.print("MS5611_LIB_VERSION: ");
Serial.println(MS5611_LIB_VERSION); Serial.println(MS5611_LIB_VERSION);
Serial.println();
Wire.begin();
if (MS5611.begin() == true) if (MS5611.begin() == true)
{ {
Serial.println("MS5611 found."); Serial.println("MS5611 found.");

View File

@ -0,0 +1,29 @@
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:
packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
# - uno
# - due
# - zero
# - leonardo
# - m4
- esp32
# - esp8266
# - mega2560
# - rpipico

View File

@ -0,0 +1,70 @@
//
// FILE: MS5611_minimal_ESP32.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo application
// DATE: 2023-11-14
// URL: https://github.com/RobTillaart/MS5611
#include "MS5611.h"
// 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
MS5611 MS5611(0x77);
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println();
Serial.println(__FILE__);
Serial.print("MS5611_LIB_VERSION: ");
Serial.println(MS5611_LIB_VERSION);
Serial.println();
Wire.begin(22, 23); // adjust ESP32 pins if needed
if (MS5611.begin() == true)
{
Serial.println("MS5611 found.");
}
else
{
Serial.println("MS5611 not found. halt.");
while (1);
}
Serial.println();
}
void loop()
{
MS5611.read(); // note no error checking => "optimistic".
Serial.print("T:\t");
Serial.print(MS5611.getTemperature(), 2);
Serial.print("\tP:\t");
Serial.print(MS5611.getPressure(), 2);
Serial.println();
delay(1000);
}
// -- END OF FILE --

View File

@ -0,0 +1,29 @@
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:
packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
# - uno
# - due
# - zero
# - leonardo
# - m4
# - esp32
# - esp8266
# - mega2560
- rpipico

View File

@ -0,0 +1,72 @@
//
// FILE: MS5611_minimal_RP2040.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo application
// DATE: 2023-11-14
// URL: https://github.com/RobTillaart/MS5611
#include "MS5611.h"
// 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
MS5611 MS5611(0x77);
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println();
Serial.println(__FILE__);
Serial.print("MS5611_LIB_VERSION: ");
Serial.println(MS5611_LIB_VERSION);
Serial.println();
Wire.begin();
Wire.setSDA(14); // adjust RP2040 pins if needed
Wire.setSCL(15); // adjust RP2040 pins if needed
if (MS5611.begin() == true)
{
Serial.println("MS5611 found.");
}
else
{
Serial.println("MS5611 not found. halt.");
while (1);
}
Serial.println();
}
void loop()
{
MS5611.read(); // note no error checking => "optimistic".
Serial.print("T:\t");
Serial.print(MS5611.getTemperature(), 2);
Serial.print("\tP:\t");
Serial.print(MS5611.getPressure(), 2);
Serial.println();
delay(1000);
}
// -- END OF FILE --

View File

@ -8,6 +8,7 @@
#include "MS5611.h" #include "MS5611.h"
// BREAKOUT MS5611 aka GY63 - see datasheet // BREAKOUT MS5611 aka GY63 - see datasheet
// //
// SPI I2C // SPI I2C
@ -26,6 +27,7 @@
// CS to VCC ==> 0x76 // CS to VCC ==> 0x76
// CS to GND ==> 0x77 // CS to GND ==> 0x77
MS5611 MS5611(0x77); MS5611 MS5611(0x77);
@ -35,15 +37,15 @@ uint32_t start, stop, count;
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while(!Serial); while (!Serial);
Serial.println(); Serial.println();
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("MS5611_LIB_VERSION: "); Serial.print("MS5611_LIB_VERSION: ");
Serial.println(MS5611_LIB_VERSION); Serial.println(MS5611_LIB_VERSION);
Serial.println();
Wire.begin();
// Wire.setClock(100000);
if (MS5611.begin() == true) if (MS5611.begin() == true)
{ {
Serial.println("MS5611 found."); Serial.println("MS5611 found.");
@ -55,7 +57,6 @@ void setup()
} }
Serial.println(); Serial.println();
// Wire.setClock(100000);
count = 0; count = 0;
} }

View File

@ -8,6 +8,7 @@
#include "MS5611.h" #include "MS5611.h"
// BREAKOUT MS5611 aka GY63 - see datasheet // BREAKOUT MS5611 aka GY63 - see datasheet
// //
// SPI I2C // SPI I2C
@ -26,6 +27,7 @@
// CS to VCC ==> 0x76 // CS to VCC ==> 0x76
// CS to GND ==> 0x77 // CS to GND ==> 0x77
MS5611 MS5611(0x77); MS5611 MS5611(0x77);
@ -35,13 +37,14 @@ uint32_t start, stop;
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while(!Serial); while (!Serial);
Serial.println(); Serial.println();
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("MS5611_LIB_VERSION: "); Serial.print("MS5611_LIB_VERSION: ");
Serial.println(MS5611_LIB_VERSION); Serial.println(MS5611_LIB_VERSION);
Serial.println();
Wire.begin();
if (MS5611.begin() == true) if (MS5611.begin() == true)
{ {
Serial.println("MS5611 found."); Serial.println("MS5611 found.");
@ -108,6 +111,7 @@ void setup()
Serial.println("\ndone..."); Serial.println("\ndone...");
} }
void loop() void loop()
{ {
} }

View File

@ -8,6 +8,7 @@
#include "MS5611.h" #include "MS5611.h"
// BREAKOUT MS5611 aka GY63 - see datasheet // BREAKOUT MS5611 aka GY63 - see datasheet
// //
// SPI I2C // SPI I2C
@ -26,6 +27,7 @@
// CS to VCC ==> 0x76 // CS to VCC ==> 0x76
// CS to GND ==> 0x77 // CS to GND ==> 0x77
MS5611 MS5611(0x77); MS5611 MS5611(0x77);
#ifndef LED_BUILTIN #ifndef LED_BUILTIN
@ -39,14 +41,15 @@ void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); while (!Serial);
pinMode(LED_BUILTIN, OUTPUT);
Serial.println(); Serial.println();
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("MS5611_LIB_VERSION: "); Serial.print("MS5611_LIB_VERSION: ");
Serial.println(MS5611_LIB_VERSION); Serial.println(MS5611_LIB_VERSION);
Serial.println();
pinMode(LED_BUILTIN, OUTPUT);
Wire.begin();
if (MS5611.begin() == true) if (MS5611.begin() == true)
{ {
Serial.println("MS5611 found."); Serial.println("MS5611 found.");

View File

@ -8,6 +8,7 @@
#include "MS5611.h" #include "MS5611.h"
// BREAKOUT MS5611 aka GY63 - see datasheet // BREAKOUT MS5611 aka GY63 - see datasheet
// //
// SPI I2C // SPI I2C
@ -26,6 +27,7 @@
// CS to VCC ==> 0x76 // CS to VCC ==> 0x76
// CS to GND ==> 0x77 // CS to GND ==> 0x77
MS5611 MS5611(0x77); MS5611 MS5611(0x77);
@ -36,14 +38,15 @@ void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); while (!Serial);
pinMode(LED_BUILTIN, OUTPUT);
Serial.println(); Serial.println();
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("MS5611_LIB_VERSION: "); Serial.print("MS5611_LIB_VERSION: ");
Serial.println(MS5611_LIB_VERSION); Serial.println(MS5611_LIB_VERSION);
Serial.println();
pinMode(LED_BUILTIN, OUTPUT);
Wire.begin();
if (MS5611.begin() == true) if (MS5611.begin() == true)
{ {
Serial.println("MS5611 found."); Serial.println("MS5611 found.");
@ -75,6 +78,7 @@ void setup()
OSR_LOW -> 1.1 millis OSR_LOW -> 1.1 millis
OSR_ULTRA_LOW -> 0.5 millis Default = backwards compatible OSR_ULTRA_LOW -> 0.5 millis Default = backwards compatible
*/ */
void loop() void loop()
{ {
digitalWrite(LED_BUILTIN, HIGH); digitalWrite(LED_BUILTIN, HIGH);

View File

@ -8,6 +8,7 @@
#include "MS5611.h" #include "MS5611.h"
// BREAKOUT MS5611 aka GY63 - see datasheet // BREAKOUT MS5611 aka GY63 - see datasheet
// //
// SPI I2C // SPI I2C
@ -26,6 +27,7 @@
// CS to VCC ==> 0x76 // CS to VCC ==> 0x76
// CS to GND ==> 0x77 // CS to GND ==> 0x77
MS5611 MS5611(0x77); MS5611 MS5611(0x77);
@ -33,10 +35,17 @@ void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); while (!Serial);
Serial.begin(115200);
while (!Serial);
Serial.println();
Serial.println(__FILE__);
Serial.print("MS5611_LIB_VERSION: ");
Serial.println(MS5611_LIB_VERSION);
Serial.println();
pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
Serial.println(); Wire.begin();
if (MS5611.begin() == true) if (MS5611.begin() == true)
{ {
Serial.println("MS5611 found."); Serial.println("MS5611 found.");
@ -53,6 +62,7 @@ void setup()
} }
} }
Serial.println("TEMP\tPRESSURE"); Serial.println("TEMP\tPRESSURE");
// scale T & P to same range :) // scale T & P to same range :)
MS5611.setPressureOffset(-1000); MS5611.setPressureOffset(-1000);
} }

View File

@ -8,6 +8,7 @@
#include "MS5611.h" #include "MS5611.h"
// BREAKOUT MS5611 aka GY63 - see datasheet // BREAKOUT MS5611 aka GY63 - see datasheet
// //
// SPI I2C // SPI I2C
@ -38,14 +39,15 @@ void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); while (!Serial);
pinMode(LED_BUILTIN, OUTPUT);
Serial.println(); Serial.println();
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("MS5611_LIB_VERSION: "); Serial.print("MS5611_LIB_VERSION: ");
Serial.println(MS5611_LIB_VERSION); Serial.println(MS5611_LIB_VERSION);
Serial.println();
pinMode(LED_BUILTIN, OUTPUT);
Wire.begin();
if (ONE.begin() == true) if (ONE.begin() == true)
{ {
Serial.println("MS5611 0x76 found."); Serial.println("MS5611 0x76 found.");

View File

@ -24,6 +24,9 @@ getTemperatureOffset KEYWORD2
setPressureOffset KEYWORD2 setPressureOffset KEYWORD2
getPressureOffset KEYWORD2 getPressureOffset KEYWORD2
getLastResult KEYWORD2
lastRead KEYWORD2
getDeviceID KEYWORD2 getDeviceID KEYWORD2
setCompensation KEYWORD2 setCompensation KEYWORD2
@ -43,3 +46,9 @@ MS5611_READ_OK LITERAL1
MS5611_ERROR_2 LITERAL1 MS5611_ERROR_2 LITERAL1
MS5611_NOT_READ LITERAL1 MS5611_NOT_READ LITERAL1
OSR_ULTRA_HIGH LITERAL1
OSR_HIGH LITERAL1
OSR_STANDARD LITERAL1
OSR_LOW LITERAL1
OSR_ULTRA_LOW LITERAL1

View File

@ -18,9 +18,9 @@
"type": "git", "type": "git",
"url": "https://github.com/RobTillaart/MS5611.git" "url": "https://github.com/RobTillaart/MS5611.git"
}, },
"version": "0.3.9", "version": "0.4.0",
"license": "MIT", "license": "MIT",
"frameworks": "arduino", "frameworks": "*",
"platforms": "*", "platforms": "*",
"headers": "MS5611.h" "headers": "MS5611.h"
} }

View File

@ -1,5 +1,5 @@
name=MS5611 name=MS5611
version=0.3.9 version=0.4.0
author=Rob Tillaart <rob.tillaart@gmail.com> author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com> maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for MS5611 temperature and pressure sensor sentence=Arduino library for MS5611 temperature and pressure sensor

View File

@ -72,6 +72,8 @@ unittest(test_constants)
unittest(test_constructor) unittest(test_constructor)
{ {
MS5611 sensor(0x77); MS5611 sensor(0x77);
Wire.begin();
assertFalse(sensor.begin()); // as there is no sensor, and no ROM values. assertFalse(sensor.begin()); // as there is no sensor, and no ROM values.
assertEqualFloat(-9.99, sensor.getTemperature(), 0.01); assertEqualFloat(-9.99, sensor.getTemperature(), 0.01);
@ -85,6 +87,7 @@ unittest(test_read_sensor)
{ {
MS5611 sensor(0x77); MS5611 sensor(0x77);
Wire.begin();
assertFalse(sensor.begin()); assertFalse(sensor.begin());
assureEqual(MS5611_READ_OK, sensor.read()); assureEqual(MS5611_READ_OK, sensor.read());
@ -101,6 +104,7 @@ unittest(test_overSampling)
{ {
MS5611 sensor(0x77); MS5611 sensor(0x77);
Wire.begin();
assertFalse(sensor.begin()); assertFalse(sensor.begin());
// default // default
@ -118,6 +122,9 @@ unittest(test_overSampling)
assureEqual(OSR_ULTRA_HIGH, sensor.getOversampling()); assureEqual(OSR_ULTRA_HIGH, sensor.getOversampling());
} }
unittest_main() unittest_main()
// --------
// -- END OF FILE --