예제 #1
0
파일: bmp085.py 프로젝트: lab4d/WZSenses
 def __init__(self, data):
     self.sensorName = "BMP085"
     self.readingType = "sample"
     if "temp" in data["measurement"].lower():
         self.valName = "Temperature"
         self.valUnit = "Celsius"
         self.valSymbol = "C"
         if "unit" in data:
             if data["unit"] == "F":
                 self.valUnit = "Fahrenheit"
                 self.valSymbol = "F"
     elif "pres" in data["measurement"].lower():
         self.valName = "Pressure"
         self.valSymbol = "hPa"
         self.valUnit = "Hectopascal"
         self.altitude = 0
         self.mslp = False
         if "mslp" in data:
             if data["mslp"].lower() in ["on", "true", "1", "yes"]:
                 self.mslp = True
                 if "altitude" in data:
                     self.altitude = data["altitude"]
                 else:
                     print "To calculate MSLP, please provide an 'altitude' config setting (in m) for the BMP085 pressure module"
                     self.mslp = False
     if "description" in data:
         self.description = data["description"]
     else:
         self.description = "BOSCH combined temperature and pressure sensor."
     if (BMP085.bmpClass == None):
         BMP085.bmpClass = bmpBackend.BMP085(bus=int(data["i2cbus"]))
     return
예제 #2
0
 def __init__(self, data):
     self.sensorName = "BMP085"
     self.valName = data["measurement"]
     self.ontology = data["ontology"]
     self.valUnit = data["uom_name"]
     self.valUnitSymbol = data["uom_symbol"]
     self.uom_ontology = data["uom_ontology"]
     self.sensor_longName = data["sensor_longName"]
     self.sensor_shortName = data["sensor_shortName"]
     self.sensor_manufacturerURL = data["sensor_manufacturerURL"]
     self.sensor_manufacturer = data["sensor_manufacturer"]
     self.sensor_URN = data["sensor_URN"]
     if "pres" in data["measurement"].lower():
         self.altitude = 0
         self.mslp = False
         if "mslp" in data:
             if data["mslp"].lower in ["on", "true", "1", "yes"]:
                 self.mslp = True
                 if "altitude" in data:
                     self.altitude = data["altitude"]
                 else:
                     print "To calculate MSLP, please provide an 'altitude' config setting (in m) for the BMP085 pressure module"
                     self.mslp = False
     if (BMP085.bmpClass == None):
         BMP085.bmpClass = bmpBackend.BMP085(bus=int(data["i2cbus"]))
     return
예제 #3
0
    def __init__(self, data):
        """Initialise BMP085 sensor class.

        Initialise the BMP085 sensor class using parameters passed in 'data'.
        Instances of this class can be set to monitor either temperature
        ('temp') or pressure ('pres'). This is determined by the contents of
        'data' passed to this __init__ function. If you want to read both
        properties, you'll need two instances of the class.
        When set to read temperature, self.valname is 'Temperature-BMP' to
        differentiate it from other temperature sensors on the AirPi (such as
        the DHT22). By default temperatures are read in Celsius; data["unit"]
        can be set to "F" to return readings in Fahrenheit instead if required.
        Pressures are returned in Hectopascals. If data["altitude"] is provided,
        and data["mslp"] is true, then Mean Sea Level Pressure will be returned
        by getval() instead of absolute local pressure.

        Args:
            self: self.
            data: A dict containing the parameters to be used during setup.

        Return:

        """
        self.readingtype = "sample"
        if "temp" in data["measurement"].lower():
            self.sensorname = "BMP085-temp"
            self.valname = "Temperature-BMP"
            self.valunit = "Celsius"
            self.valsymbol = "C"
            if "unit" in data:
                if data["unit"] == "F":
                    self.valunit = "Fahrenheit"
                    self.valsymbol = "F"
        elif "pres" in data["measurement"].lower():
            self.sensorname = "BMP085-pres"
            self.valname = "Pressure"
            self.valsymbol = "hPa"
            self.valunit = "Hectopascal"
            self.altitude = 0
            self.mslp = False
            if "mslp" in data:
                if data["mslp"].lower() in ["on", "true", "1", "yes"]:
                    self.mslp = True
                    if "altitude" in data:
                        self.altitude = data["altitude"]
                    else:
                        msg = "To calculate MSLP, please provide an 'altitude'"
                        msg += " (in m) for the BMP085 pressure module."
                        print(msg)
                        self.mslp = False
        if "description" in data:
            self.description = data["description"]
        else:
            self.description = "BOSCH combined temperature and pressure sensor."
        if BMP085.bmpClass == None:
            BMP085.bmpClass = bmpBackend.BMP085(bus=int(data["i2cbus"]))
        return
예제 #4
0
파일: bmp085.py 프로젝트: prokingvan/pyEfis
    def __init__(self, data):
        self.sensorName = "BMP085"
        if "temp" in data["measurement"].lower():
            self.valName = "CAT"
            self.valUnit = "Celsius"
            self.valSymbol = "C"
            if "unit" in data:
                if data["unit"] == "F":
                    self.valUnit = "Fahrenheit"
                    self.valSymbol = "F"
        elif "pres" in data["measurement"].lower():
            self.valName = "Pressure"
            self.valSymbol = "hPa"
            self.valUnit = "Hectopascal"
            self.altitude = 0
            self.mslp = False
            if "mslp" in data:
                if data["mslp"].lower in ["on", "true", "1", "yes"]:
                    self.mslp = True
                    if "altitude" in data:
                        self.altitude = data["altitude"]
                    else:
                        print "To calculate MSLP, please provide an 'altitude' config setting (in m) for the BMP085 pressure module"
                        self.mslp = False
        elif "alt" in data["measurement"].lower():
            self.valName = "Altitude"
            self.valSymbol = ""
            self.valUnit = "Feet"
            if "unit" in data:
                if data["unit"].lower in ["meter", "Meter", "M", "m"]:
                    self.valUnit = "Meter"
                    self.valSymbol = "M"

        if (BMP085.bmpClass == None):
            BMP085.bmpClass = bmpBackend.BMP085()
        return
 def __init__(self):
     self.bmp = bmpBackend.BMP085(bus=1)
     self.temperature = 0
     self.pressure = 0
     self.lastValue = (0, 0)