Skip to content

Commit a416817

Browse files
committed
adding hectopascals to the sealevel setter
1 parent ffe7899 commit a416817

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

adafruit_mpl3115a2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,6 @@ def sealevel_pressure(self):
288288

289289
@sealevel_pressure.setter
290290
def sealevel_pressure(self, val):
291-
# Convert to bars of pressure and write to the sealevel register.
292-
bars = val // 2
291+
# Convert from hectopascals to bars of pressure and write to the sealevel register.
292+
bars = int(val * 50)
293293
self._write_u16_be(_MPL3115A2_BAR_IN_MSB, bars)

examples/mpl3115a2_simpletest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
# This value has to be looked up from your local weather forecast or meteorological
2222
# reports. It will change day by day and even hour by hour with weather
2323
# changes. Remember altitude estimation from barometric pressure is not exact!
24-
# Set this to a value in pascals:
25-
sensor.sealevel_pressure = 102250
24+
# Set this to a value in hectopascals:
25+
sensor.sealevel_pressure = 1022.5
2626

2727
# Main loop to read the sensor values and print them every second.
2828
while True:

0 commit comments

Comments
 (0)