Added new functions

This commit is contained in:
Joachim Hummel 2017-01-06 15:22:17 +01:00
parent 5567c8c144
commit 6c25a1f986
2 changed files with 38 additions and 18 deletions

View File

@ -10,7 +10,7 @@ import Adafruit_BMP.BMP085 as BMP085
# #
# For the Beaglebone Black the library will assume bus 1 by default, which is # For the Beaglebone Black the library will assume bus 1 by default, which is
# exposed with SCL = P9_19 and SDA = P9_20. # exposed with SCL = P9_19 and SDA = P9_20.
sensor = BMP085.BMP085() #sensor = BMP085.BMP085()
# Optionally you can override the bus number: # Optionally you can override the bus number:
#sensor = BMP085.BMP085(busnum=2) #sensor = BMP085.BMP085(busnum=2)
@ -19,9 +19,19 @@ sensor = BMP085.BMP085()
# BMP085_STANDARD, BMP085_HIGHRES, or BMP085_ULTRAHIGHRES. See the BMP085 # BMP085_STANDARD, BMP085_HIGHRES, or BMP085_ULTRAHIGHRES. See the BMP085
# datasheet for more details on the meanings of each mode (accuracy and power # datasheet for more details on the meanings of each mode (accuracy and power
# consumption are primarily the differences). The default mode is STANDARD. # consumption are primarily the differences). The default mode is STANDARD.
#sensor = BMP085.BMP085(mode=BMP085.BMP085_ULTRAHIGHRES) sensor = BMP085.BMP085(mode=BMP085.BMP085_ULTRAHIGHRES)
# Please set your locale altitude
# http://www.latlong.net/ Helps to find your Langitude and Latitude
# http://www.mapcoordinates.net/ Helps to Find the Data in Meter
locale_altitude = 570
seapFloat = sensor.read_sealevel_pressure(locale_altitude)
pressure = sensor.read_pressure()
psea = pressure / pow(1.0 - locale_altitude/44330.0, 5.255)
print 'Temp = {0:0.2f} *C'.format(sensor.read_temperature()) print 'Temp = {0:0.2f} *C'.format(sensor.read_temperature())
print 'Altitude = {0:0.2f} m'.format(sensor.read_altitude()) print 'Altitude = {0:0.2f} m'.format(sensor.read_altitude(seapFloat))
print 'Pressure = {0:0.2f} hPa'.format(sensor.read_pressure()/100) print 'Pressure = {0:0.2f} hPa'.format(sensor.read_pressure()/100)
print 'Pressure NN = {0:0.2f} hPa'.format(sensor.read_sealevel_pressure()/100) print "Pressure NN =%8.2f hPa" % (psea / 100.0)

View File

@ -19,6 +19,12 @@ sensor2 = "/sys/bus/w1/devices/w1_bus_master1/28-041470306aff/w1_slave"
sensor3 = "/sys/bus/w1/devices/w1_bus_master1/28-0414709c63ff/w1_slave" sensor3 = "/sys/bus/w1/devices/w1_bus_master1/28-0414709c63ff/w1_slave"
sensor4 = "" sensor4 = ""
# Please set your locale altitude
# http://www.latlong.net/ Helps to find your Langitude and Latitude
# http://www.mapcoordinates.net/ Helps to Find the Data in Meter
local_altitude = 570
# Optionally you can override the bus number: # Optionally you can override the bus number:
#sensor = BMP085.BMP085(busnum=2) #sensor = BMP085.BMP085(busnum=2)
@ -28,6 +34,10 @@ sensor4 = ""
# consumption are primarily the differences). The default mode is STANDARD. # consumption are primarily the differences). The default mode is STANDARD.
#sensor = BMP085.BMP085(mode=BMP085.BMP085_ULTRAHIGHRES) #sensor = BMP085.BMP085(mode=BMP085.BMP085_ULTRAHIGHRES)
# getSeaLelvelPres
# Sensor = BMP180
# Output = SeaPresFloat
SeaPresFlot = sensor1.read_sealevel_pressure(local_altitude)
# getTemp1() method # getTemp1() method
# Sensor1 = BMP085 # Sensor1 = BMP085
@ -116,11 +126,11 @@ def getPressure():
# getSeaPressure() method # getSeaPressure() method
# Sensor1 = BMP085 # Sensor1 = BMP085
# Output = Sea_Pressure
def getSeaPressure(): def getSeaPressure():
sea_pressure = format(sensor1.read_sealevel_pressure()/100) #sea_pressure = format(sensor1.read_sealevel_pressure()/100)
sea_pressure = round((sensor1.read_sealevel_pressure()/100)) #sea_pressure = round((sensor1.read_sealevel_pressure()/100))
pressure = round((sensor1.read_pressure()/100))
sea_pressure = round(pressure / pow(1.0 - locale_altitude/44330.0, 5.255))
if(sea_pressure==0): if(sea_pressure==0):
return 0 return 0
else: else:
@ -131,8 +141,8 @@ def getSeaPressure():
# Output = Altitude # Output = Altitude
def getAltitude(): def getAltitude():
altitude = format(sensor1.read_altitude()) #altitude = format(sensor1.read_altitude())
altitude = round((sensor1.read_altitude())) altitude = round((sensor1.read_altitude(SeaPresFlot)))
if(altitude==0): if(altitude==0):
return 0 return 0
else: else:
@ -151,26 +161,26 @@ def getHumidity():
return humidity return humidity
Temp1=getTemp1() Temp1=getTemp1()
#print Temp1 print Temp1
Temp2=getTemp2() Temp2=getTemp2()
#print Temp2 print Temp2
Temp3=getTemp3() Temp3=getTemp3()
#print Temp3 print Temp3
Temp4=getTemp4() Temp4=getTemp4()
#print Temp4 print Temp4
Pressure=getPressure() Pressure=getPressure()
#print Pressure print Pressure
Sea_pressure=getSeaPressure() Sea_pressure=getSeaPressure()
#print Sea_pressure print Sea_pressure
Altitude =getAltitude() Altitude =getAltitude()
#print Altitude print Altitude
Humidity=getHumidity() Humidity=getHumidity()
#print Humidity print Humidity