示例#1
0
def main():

    post = phant.Phant("zD9obXl4K3UM1E0MY5q2", "privateKey")
    (chip_id, chip_version) = bme280.readBME280ID()
    total_temp = 0
    total_pressure = 0
    total_humidity = 0
    cycle_counter = 0
    print "Chip ID     :", chip_id
    print "Version     :", chip_version
    while 1:
        temperature, pressure, humidity = bme280.readBME280All()
        total_temp += temperature
        total_pressure += pressure
        total_humidity += humidity
        cycle_counter += 1
        time.sleep(1)
        if (cycle_counter == 60):
            post.post_data("{0:.2f}".format(total_humidity / cycle_counter),
                           "{0:.2f}".format(total_pressure / cycle_counter),
                           "{0:.2f}".format(total_temp / cycle_counter))
            print "Temperature : ", total_temp / cycle_counter, "C"
            print "Pressure : ", total_pressure / cycle_counter, "hPa"
            print "Humidity : ", total_humidity / cycle_counter, "%"
            total_pressure = total_temp = total_humidity = cycle_counter = 0
示例#2
0
def bme280_values():
    try:
        # Get BME280 Temperature, Humidity, & Pressure
        (config.bme280_chip_id,
         config.bme280_chip_version) = bme280.readBME280ID()
        config.bme280_temperature, config.bme280_pressure, config.bme280_humidity = bme280.readBME280All(
        )
        # Convert to Fahrenheit = 9.0/5.0 * Celsius + 32
        config.bme280_tempF = ((9 / 5 * config.bme280_temperature) + 32.00)
        # temp calibration equation
        # config.bme280_tempF = ((0.646 * config.bme280_tempF) + (33.0))
        # config.bme280_tempF = ((0.646 * config.bme280_tempF) + (33.786))
        config.bme280_tempF = 1.5107 * (config.bme280_tempF) - 14.541

        config.bme280_tempF = round(config.bme280_tempF, 1)

        # humid calibration equation
        config.bme280_humidity = (0.8223 * config.bme280_humidity + 15.386)
        config.bme280_humidity = round(config.bme280_humidity, 1)
        config.bme280_pressure = round(config.bme280_pressure / 33.864, 1)
    except IOError:
        print("BME280 Temp/Humid/Pressure Sensor Error")

    if (config.DEBUG):
        print("BME280 Temp/Humidity/Pressure is: ", config.bme280_tempF,
              config.bme280_humidity, config.bme280_pressure)
        print("get.bme280_values module done")
    time.sleep(1)
示例#3
0
    def Chip_version(self):
        """
        Chip_version.

        Returns
        -------
        None.

        """
        (chip_id, chip_version) = bme280.readBME280ID()
        print("Chip ID : {}").format(chip_id)
        print("Version : {}").format(chip_version)
示例#4
0
def gatherTempAndPressureData():
    (chip_id, chip_version) = bme280.readBME280ID()
    print("Chip ID :" + chip_id)
    print("Version :" + chip_version)

    (temperature, pressure, humidity) = bme280.readBME280All()

    print("Temperature : " + temperature + "C")
    print("Pressure : " + pressure + "hPa")
    print("Humidity : " + humidity + "%")

    return (temperature, pressure)
示例#5
0
    def getID3(self):
        print "getting baromentric sensor ID v3 on I2C bus address 0x%02X..." % (
            self.port)

        (chip_id, chip_version) = bme280.readBME280ID(self.port)

        print "Chip ID     :", chip_id
        print "Version     :", chip_version

        ids3["barometricSensor.chipId"] = chip_id
        ids3["barometricSensor.chipVersion"] = chip_version

        return ids3
示例#6
0
    def getID(self):
        print "getting baromentric sensor ID on I2C bus address 0x%02X..." % (
            self.port)

        (chip_id, chip_version) = bme280.readBME280ID(self.port)

        print "Chip ID     :", chip_id
        print "Version     :", chip_version

        ids['barometricSensor'][0]['value'] = chip_id
        ids['barometricSensor'][1]['value'] = chip_version

        return ids
示例#7
0
def main():
    (chip_id, chip_version) = bme280.readBME280ID()
    temperature, pressure, humidity = bme280.readBME280All()

    display = GroveOledDisplay128x64()

    display.set_cursor(0, 0)
    display.puts('Chip ID: ')
    display.puts(str(chip_id))
    display.set_cursor(1, 0)
    display.puts('Version: ')
    display.puts(str(chip_version))
    display.set_cursor(2, 0)
    display.puts('Temperature (C)')
    display.set_cursor(3, 1)
    display.puts(str(temperature))
    display.set_cursor(4, 0)
    display.puts('Pressure (hPa)')
    display.set_cursor(5, 1)
    display.puts(str(pressure))
    display.set_cursor(6, 0)
    display.puts('Humidity (%)')
    display.set_cursor(7, 1)
    display.puts(str(humidity))
示例#8
0
import bme280

(chip_id, chip_version) = bme280.readBME280ID()
print("Chip ID :", chip_id)
print("Version :", chip_version)

temperature, pressure, humidity = bme280.readBME280All()

print("Temperature : ", temperature, "C")
print("Pressure : ", pressure, "hPa")
print("Humidity : ", humidity, "%")
示例#9
0
#sensor = BMP085.BMP085(busnum=2)

# You can also optionally change the BMP085 mode to one of BMP085_ULTRALOWPOWER,
# BMP085_STANDARD, BMP085_HIGHRES, or BMP085_ULTRAHIGHRES.  See the BMP085
# datasheet for more details on the meanings of each mode (accuracy and power
# consumption are primarily the differences).  The default mode is STANDARD.
#sensor = BMP085.BMP085(mode=BMP085.BMP085_ULTRAHIGHRES)

 
UDP_IP = "127.0.0.1"
UDP_PORT = 8056

sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP

(chip_id, chip_version) = readBME280ID()
print "Chip ID     :", chip_id
print "Version     :", chip_version

temperature,pressure,humidity = readBME280All()

print "Temperature : ", temperature, "C"
print "Pressure : ", pressure, "hPa"
print "Humidity : ", humidity, "%"
                     
while(True):
    #pressure = sensor.read_pressure()
    temperature,pressure,humidity = readBME280All()
    pressure = pressure * 100
    avgFilter.Update(pressure)
    if avgFilter.GetCount() % 50 == 0: