Skip to content

Commit f3d3ea3

Browse files
committed
Fix barometric pressue.
Creating two classes (one for PRESSURE and one for ALTITUDE) was in fact changing the sensor permanently into ALTITUDE. For every reading it is now initialized in the correct mode.
1 parent a15f1cd commit f3d3ea3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pysense-example/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from MPL3115A2 import MPL3115A2, ALTITUDE, PRESSURE
1313

1414
py = Pysense()
15-
mpPress = MPL3115A2(py,mode=PRESSURE)
16-
mpAlt = MPL3115A2(py,mode=ALTITUDE)
1715
si = SI7006A20(py)
1816
lt = LTR329ALS01(py)
1917
li = LIS2HH12(py)
@@ -76,11 +74,14 @@
7674
lpp.add_relative_humidity(1, si.humidity())
7775
lpp.add_temperature(1, si.temperature())
7876

77+
mpPress = MPL3115A2(py,mode=PRESSURE)
7978
print('\n\n** Barometric Pressure Sensor with Altimeter (MPL3115A2)')
8079
print('Pressure (hPa)', mpPress.pressure()/100)
80+
lpp.add_barometric_pressure(1, mpPress.pressure()/100)
81+
82+
mpAlt = MPL3115A2(py,mode=ALTITUDE)
8183
print('Altitude', mpAlt.altitude())
8284
print('Temperature', mpAlt.temperature())
83-
lpp.add_barometric_pressure(1, mpPress.pressure()/100)
8485
lpp.add_gps(1, 0, 0, mpAlt.altitude())
8586
lpp.add_temperature(2, mpAlt.temperature())
8687

0 commit comments

Comments
 (0)