Skip to content

Commit 48a38de

Browse files
committed
0.3.0 MS5837
1 parent 45c2486 commit 48a38de

File tree

10 files changed

+89
-33
lines changed

10 files changed

+89
-33
lines changed

libraries/MS5837/.github/workflows/arduino-lint.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ jobs:
66
runs-on: ubuntu-latest
77
timeout-minutes: 5
88
steps:
9-
- uses: actions/checkout@v4
10-
- uses: arduino/arduino-lint-action@v1
9+
- uses: actions/checkout@v5
10+
- uses: arduino/arduino-lint-action@v2
1111
with:
1212
library-manager: update
13-
compliance: strict
14-
13+
compliance: strict

libraries/MS5837/.github/workflows/arduino_test_runner.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ jobs:
88
timeout-minutes: 20
99

1010
steps:
11-
- uses: actions/checkout@v4
11+
- uses: actions/checkout@v5
1212
- uses: ruby/setup-ruby@v1
1313
with:
1414
ruby-version: 2.6
1515
- run: |
16-
sudo sysctl vm.mmap_rnd_bits=28
1716
gem install arduino_ci
1817
arduino_ci.rb

libraries/MS5837/.github/workflows/jsoncheck.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ on:
55
paths:
66
- '**.json'
77
pull_request:
8+
paths:
9+
- '**.json'
810

911
jobs:
1012
test:
1113
runs-on: ubuntu-latest
1214
timeout-minutes: 5
1315
steps:
14-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1517
- name: json-syntax-check
1618
uses: limitusus/json-syntax-check@v2
1719
with:

libraries/MS5837/CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9+
## [0.3.0] - 2025-09-27
10+
- sync MS5611
11+
- add getAltitudeFeet()
12+
- add getDepthFeet()
13+
- add getPressurePascal()
14+
- update GitHub actions
15+
- update README.md
16+
- minor edits
17+
18+
----
19+
920
## [0.2.0] - 2025-06-13
1021
- fix #4, read() error after test with hardware
11-
- change API to **int read()** for better debugability
22+
- change API to **int read()** for better debug-ability
1223
- improve demo sketch - add getLastError()
1324
- redo getAltitude() formula
1425
- add sketch MS5837_performance.ino

libraries/MS5837/MS5837.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: MS5837.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.2.0
4+
// VERSION: 0.3.0
55
// DATE: 2023-11-12
66
// PURPOSE: Arduino library for MS5837 temperature and pressure sensor.
77
// URL: https://github.com/RobTillaart/MS5837
@@ -110,7 +110,6 @@ int MS5837::read(uint8_t bits)
110110
}
111111

112112
uint32_t start = millis();
113-
114113
// while loop prevents blocking RTOS
115114
while (millis() - start < wait)
116115
{
@@ -232,15 +231,21 @@ uint32_t MS5837::lastRead()
232231
}
233232

234233

234+
float MS5837::getTemperature()
235+
{
236+
return _temperature;
237+
}
238+
239+
235240
float MS5837::getPressure()
236241
{
237242
return _pressure;
238243
}
239244

240245

241-
float MS5837::getTemperature()
246+
float MS5837::getPressurePascal()
242247
{
243-
return _temperature;
248+
return _pressure * 100.0;
244249
}
245250

246251

@@ -249,11 +254,19 @@ float MS5837::getTemperature()
249254
// https://en.wikipedia.org/wiki/Pressure_altitude
250255
float MS5837::getAltitude(float airPressure)
251256
{
257+
// _pressure is in mBar - differs from MS5611
252258
float ratio = _pressure / airPressure;
253259
return 44307.694 * (1 - pow(ratio, 0.190284));
254260
}
255261

256262

263+
float MS5837::getAltitudeFeet(float airPressure)
264+
{
265+
float ratio = _pressure / airPressure;
266+
return 145366.45 * (1 - pow(ratio, 0.190284));
267+
}
268+
269+
257270
//////////////////////////////////////////////////////////////////////
258271
//
259272
// DENSITY for depth
@@ -279,6 +292,13 @@ float MS5837::getDepth(float airPressure)
279292
return (_pressure - airPressure)/(_density * 9.80665 * 10);
280293
}
281294

295+
float MS5837::getDepthFeet(float airPressure)
296+
{
297+
// optimized
298+
return 0.033455768 * (_pressure - airPressure)/_density;
299+
// return getDepth() * 3.2808399;
300+
}
301+
282302

283303
//////////////////////////////////////////////////////////////////////
284304
//

libraries/MS5837/MS5837.h

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: MS5837.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.2.0
5+
// VERSION: 0.3.0
66
// DATE: 2023-11-12
77
// PURPOSE: Arduino library for MS5837 temperature and pressure sensor.
88
// URL: https://github.com/RobTillaart/MS5837
@@ -12,7 +12,7 @@
1212
#include "Wire.h"
1313

1414

15-
#define MS5837_LIB_VERSION (F("0.2.0"))
15+
#define MS5837_LIB_VERSION (F("0.3.0"))
1616

1717

1818
// TYPES
@@ -55,15 +55,22 @@ class MS5837
5555
int read(uint8_t bits = 8);
5656
uint32_t lastRead();
5757

58-
// see https://github.com/RobTillaart/pressure for conversions.
59-
// returns mBar
60-
float getPressure();
6158
// see https://github.com/RobTillaart/temperature for conversions.
6259
// returns Celsius
6360
float getTemperature();
61+
// see https://github.com/RobTillaart/pressure for conversions.
62+
// returns mBar
63+
float getPressure();
6464
// compensate for actual air pressure if needed
6565
// returns meters.
66+
// pressure is in Pascal (SI-unit)
67+
float getPressurePascal();
68+
//
69+
// ALTITUDE
70+
// air pressure in mBar, returns meters
6671
float getAltitude(float airPressure = 1013.25);
72+
// idem, returns feet.
73+
float getAltitudeFeet(float airPressure = 1013.25);
6774

6875

6976
//////////////////////////////////////////////////////////////////////
@@ -78,9 +85,12 @@ class MS5837
7885
// density in grams / cm3 (so not in grams per liter
7986
void setDensity(float density = 0.99802);
8087
float getDensity();
81-
// returns meters (SI unit)
82-
// compensate for actual air pressure if needed
88+
//
89+
// returns meters (SI unit)
90+
// compensate for actual air pressure if needed
8391
float getDepth(float airPressure = 1013.25);
92+
// idem, returns feet.
93+
float getDepthFeet(float airPressure = 1013.25);
8494

8595

8696
//////////////////////////////////////////////////////////////////////
@@ -108,8 +118,8 @@ class MS5837
108118
uint8_t _address = 0x76;
109119
TwoWire * _wire = NULL;
110120

111-
float _pressure;
112-
float _temperature;
121+
float _pressure; // mBar
122+
float _temperature; // Celsius
113123

114124
float C[8];
115125
uint8_t _type = MS5837_TYPE_UNKNOWN;

libraries/MS5837/README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,20 @@ The call will block for 3 to 40 milliseconds, depending upon number of bits.
179179
- **uint32_t lastRead()** returns the timestamp of the last call to read() in
180180
milliseconds since start.
181181
It does not take into account if the read call is successful or not.
182+
- **float getTemperature()** returns temperature in degrees Celsius.
183+
Multiple calls will return the same value until read() is called again.
182184
- **float getPressure()** returns pressure in mBar.
183185
Multiple calls will return the same value until read() is called again.
184-
- **float getTemperature()** returns temperature in degrees Celsius.
186+
- **float getPressurePascal()** returns pressure in Pascal (SI-unit).
185187
Multiple calls will return the same value until read() is called again.
186188
- **float getAltitude(float airPressure = 1013.25)** calculates the altitude,
187-
based upon actual pressure measured and the current pressure at sea level.
188-
Returns the altitude in meters.
189-
Multiple calls will return the same value until read() is called again.
190-
One can compensate for the actual air pressure at sea level.
189+
based upon actual pressure measured and the current pressure at sea level (parameter airPressure).
190+
Returns the altitude in meters (SI-unit).
191+
Multiple calls will return the same altitude until a new pressure is **read()**.
192+
- **float getAltitudeFeet(float airPressure = 1013.25)** calculates the altitude,
193+
based upon actual pressure measured and the current pressure at sea level (parameter airPressure).
194+
Returns the altitude in feet.
195+
Multiple calls will return the same altitude until a new pressure is **read()**.
191196

192197
Experimental note.
193198

@@ -215,7 +220,12 @@ density water 20°C = 0.99802
215220
- **float getDensity()** returns set liquid density.
216221
- **float getDepth(float airPressure = 1013.25)** calculates the depth,
217222
based upon actual pressure and the pressure at sea level.
218-
Returns depth in meters.
223+
Returns depth in meters (SI-unit).
224+
One can compensate for the actual air pressure at sea level.
225+
Multiple calls will return the same value until read() is called again.
226+
- **float getDepthFeet(float airPressure = 1013.25)** calculates the depth,
227+
based upon actual pressure and the pressure at sea level.
228+
Returns depth in feet.
219229
One can compensate for the actual air pressure at sea level.
220230
Multiple calls will return the same value until read() is called again.
221231

libraries/MS5837/keywords.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,23 @@ getAddress KEYWORD2
1414
read KEYWORD2
1515
lastRead KEYWORD2
1616

17-
getPressure KEYWORD2
1817
getTemperature KEYWORD2
18+
getPressure KEYWORD2
19+
getPressurePascal KEYWORD2
1920
getAltitude KEYWORD2
21+
getAltitudeFeet KEYWORD2
2022

2123
setDensity KEYWORD2
2224
getDensity KEYWORD2
2325
getDepth KEYWORD2
26+
getDepthFeet KEYWORD2
2427

2528
getLastError KEYWORD2
2629

2730
getCRC KEYWORD2
2831
getProduct KEYWORD2
2932
getFactorySettings KEYWORD2
33+
getPromZero KEYWORD2
3034

3135

3236
# Constants (LITERAL1)
@@ -37,6 +41,7 @@ MS5803_TYPE_01 LITERAL1
3741
MS5837_TYPE_02 LITERAL1
3842
MS5837_TYPE_30 LITERAL1
3943

40-
4144
MS5837_OK LITERAL1
45+
MS5837_ERROR_I2C LITERAL1
46+
MS5837_ERROR_REQUEST LITERAL1
4247

libraries/MS5837/library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "MS5837",
3-
"keywords": "MS5837, MS5803, temperature, pressure",
3+
"keywords": "MS5837, MS5803, temperature, pressure,altitude,depth",
44
"description": "Arduino library for MS5837 temperature and pressure sensor.",
55
"authors":
66
[
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/MS5837.git"
1717
},
18-
"version": "0.2.0",
18+
"version": "0.3.0",
1919
"license": "MIT",
2020
"frameworks": "*",
2121
"platforms": "*",

libraries/MS5837/library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=MS5837
2-
version=0.2.0
2+
version=0.3.0
33
author=Rob Tillaart <rob.tillaart@gmail.com>
44
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
55
sentence=Arduino library for MS5837 temperature and pressure sensor.
6-
paragraph=MS5803
6+
paragraph=MS5803,altitude,depth
77
category=Sensors
88
url=https://github.com/RobTillaart/MS5837
99
architectures=*

0 commit comments

Comments
 (0)