-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexample.py
More file actions
35 lines (27 loc) · 870 Bytes
/
example.py
File metadata and controls
35 lines (27 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/python
import ms5837
import time
sensor = ms5837.MS5837_30BA()
# We must initialize the sensor before reading it
if not sensor.init():
exit(1)
# We have to read values from sensor to update pressure and temperature
if not sensor.read():
exit(1)
print("Pressure: %.2f atm %.2f Torr %.2f psi",
sensor.pressure(ms5837.UNITS_atm))
print("Temperature: %.2f C %.2f F %.2f K",
sensor.temperature(ms5837.UNITS_Centigrade))
freshwaterDepth = sensor.depth() # default is freshwater
sensor.setFluidDensity(ms5837.DENSITY_SALTWATER)
saltwaterDepth = sensor.depth() # No nead to read() again
sensor.setFluidDensity(1000) # kg/m^3
time.sleep(5)
# Spew readings
while True:
if sensor.read():
print(
sensor.pressure(),
sensor.temperature())
else:
print("feh moshkela")