当前位置: 首页>>代码示例>>Python>>正文


Python SenseHat.get_pressure方法代码示例

本文整理汇总了Python中sense_hat.SenseHat.get_pressure方法的典型用法代码示例。如果您正苦于以下问题:Python SenseHat.get_pressure方法的具体用法?Python SenseHat.get_pressure怎么用?Python SenseHat.get_pressure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sense_hat.SenseHat的用法示例。


在下文中一共展示了SenseHat.get_pressure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_press

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
def get_press(altitude):

 # enable SenseHat modules
    from sense_hat import SenseHat
    
    sense=SenseHat()
    raw_pressure1 = sense.get_pressure()
    time.sleep(0.1) 
    raw_pressure2 = sense.get_pressure()
    time.sleep(0.1) 
    raw_pressure3 = sense.get_pressure()
    raw_pressure=(raw_pressure1+raw_pressure2+raw_pressure3)/3
    pressure = raw_pressure/math.pow(1 - 0.0065*altitude/288.15,5.25588)
    #print(pressure)
    return pressure
开发者ID:amonsain,项目名称:Raspberry,代码行数:17,代码来源:Pressure.py

示例2: time

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
class SensorHatLogger:

    """
    Logs the hostname, time (unixtime), temperature, humidity, and pressure to Kafka in JSON format. The data is
    generated by a Raspberry Pi with a Sense Hat: https://www.raspberrypi.org/products/sense-hat/
    
    This captures a read approx. every 10 seconds.

    TODO: https://github.com/initialstate/wunderground-sensehat/wiki/Part-3.-Sense-HAT-Temperature-Correction
    
    """

    def __init__(self):
        self.producer = KafkaProducer(bootstrap_servers='hdp01.woolford.io:6667')
        self.sense = SenseHat()
        self.sensor_record = dict()

    def read_values_from_sensor(self):
        self.sensor_record['host'] = socket.gethostname()
        self.sensor_record['timestamp'] = int(time.time())
        self.sensor_record['temperature'] = self.sense.get_temperature()
        self.sensor_record['humidity'] = self.sense.get_humidity()
        self.sensor_record['pressure'] = self.sense.get_pressure()

    def send_record_to_kafka(self):
        sensor_record_json = json.dumps(self.sensor_record)
        self.producer.send("temperature_humidity_json", sensor_record_json)

    def run(self):
        self.read_values_from_sensor()
        self.send_record_to_kafka()
开发者ID:alexwoolford,项目名称:htu21d_logger,代码行数:33,代码来源:pi_sense_hat_logger.py

示例3: get_sensors

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
def get_sensors(precision):
	sense = SenseHat()
	data = {}
	data['temperature'] = round(sense.get_temperature(), precision)
	data['pressure'] = round(sense.get_pressure(), precision)
	data['humidity'] = round(sense.get_humidity(), precision)
	return data
开发者ID:sofixa,项目名称:Pi-Sense-Hat-to-InfluxDB,代码行数:9,代码来源:sense-influxdb.py

示例4: sense_data

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
def sense_data():
    sense = SenseHat()
    comx, comy, comz = sense.get_compass_raw().values()
    accx, accy, accz = sense.get_accelerometer_raw().values()
    gyrox, gyroy, gyroz = sense.get_accelerometer_raw().values()
    temperature = sense.get_temperature_from_humidity()
    humidity = sense.get_humidity()
    pressure = sense.get_pressure()

    timestamp = datetime.now().isoformat()

    if accy > 0.1 :
        drop_flg = 1
    else:
        drop_flg = 0
            

    message = { "deviceid": deviceid, \
                "timestamp" : timestamp, \
                "temperature" : temperature, \
                "humidity" : humidity, \
                "pressure" : pressure, \
                "comx" : comx, \
                "comy" : comy, \
                "comz" : comz, \
                "gyrox" : gyrox, \
                "gyroy" : gyroy, \
                "gyroz" : gyroz, \
                "accx" : accx, \
                "accy" : accy, \
                "accz" : accz, \
                "drop" : drop_flg
                 }
    print accx, accy, accz, drop_flg
    return message
开发者ID:aquaviter,项目名称:sko2015-hackathon,代码行数:37,代码来源:sensor.py

示例5: readSensor

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
	def readSensor(self):
		from sense_hat import SenseHat
		senseHat = SenseHat()
		self.humidity   = senseHat.get_humidity()
		self.tempH      = senseHat.get_temperature_from_humidity()
		self.pressure   = senseHat.get_pressure() + PRESSURE_OFFSET
		self.tempP      = senseHat.get_temperature_from_pressure()
		self.mesureTime = time.time()
开发者ID:vrampal,项目名称:RpiWeather,代码行数:10,代码来源:SenseHat.py

示例6: __init__

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
class Sensor :
    def __init__(self) :
        self.sensor_id = "sensor hat"
        self.fileplace = 'tempplace.conf'
        self.total_count = 0
        self.device_file = "/dev/null"
        self.sense = SenseHat()
        self.place = self.readplacename()

    def reinit(self) :
        self.__init__()

    def sensorid(self) :
        return self.sensor_id

    def total_count(self) :
        return self.total_count

    def placename(self):
        return self.place

    def setplacename(self, name):
        self.place = setplace_db(name)

    def readplacename(self):
        self.place = getplace_db()
        return self.place

    def read_temp(self):
        temp = "null"
        tt = self.sense.get_temperature()
        th = self.sense.get_temperature_from_humidity()
        tf = self.sense.get_temperature_from_pressure()

        tf = float(tt)
        tf = tf - 10.0 # Fattore di correzione
        tt = round(tt, 2)
        tc = round(tf, 2)
        th = round(th, 2)
        tf = round(tf, 2)

        self.total_count += 1
        return str(tc)

    def read_pressure(self):
        p = self.sense.get_pressure()
        p = round(p, 2)
        self.total_count += 1
        return str(p)

    def read_humidity(self):
        h = self.sense.get_humidity()
        h = round(h, 2)
        self.total_count += 1
        return str(h)

    def sensordebug(self):
        return 'Sense Hat'
开发者ID:ernitron,项目名称:temperature-server,代码行数:60,代码来源:SensorHat.py

示例7: get_press

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
def get_press(altitude):
 # enable SenseHat modules
    from sense_hat import SenseHat
    
    sense=SenseHat()
    raw_pressure = sense.get_pressure()
    pressure = raw_pressure/math.pow(1 - 0.0065*altitude/288.15,5.25588)
    #print(pressure)
    return pressure
开发者ID:amonsain,项目名称:Raspberry,代码行数:11,代码来源:PressureAvg.py

示例8: __init__

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
class SenseLogger:
    def __init__(self):
        self.sense = SenseHat()
        self.filename = "./logs/Senselogg-"+str(datetime.now())+".csv"
        self.file_setup(self.filename)

    def write_line(self, line):
        with open(self.filename, "a") as f:
            f.write(line + "\n")
        
    def log_data(self):
        sense_data = self.get_sense_data()
        line = ",".join(str(value) for value in sense_data)
        self.write_line(line)

    def file_setup(self, filename):
        header = ["datetime", "temp_h", "temp_p", "humidity", "pressure", "pitch",
                  "roll", "yaw", "mag_x", "mag_y", "mag_z",
                  "accel_x", "accel_y", "accel_z",
                  "gyro_x", "gyro_y", "gyro_z"]

        with open(filename, "w") as f:
            f.write(",".join(str(value) for value in header)+ "\n")

    def get_sense_data(self):
        sense_data = []
        sense_data.append(datetime.now())
        sense_data.append(self.sense.get_temperature_from_humidity())
        sense_data.append(self.sense.get_temperature_from_pressure())
        sense_data.append(self.sense.get_humidity())
        sense_data.append(self.sense.get_pressure())

        o = self.sense.get_orientation()
        yaw = o["yaw"]
        pitch = o["pitch"]
        roll = o["roll"]
        sense_data.extend([pitch, roll, yaw])

        mag = self.sense.get_compass_raw()
        x = mag["x"]
        y = mag["y"]
        z = mag["z"]
        sense_data.extend([x, y, z])    

        acc = self.sense.get_accelerometer_raw()
        x = acc["x"]
        y = acc["y"]
        z = acc["z"]
        sense_data.extend([x, y, z])  

        gyro = self.sense.get_gyroscope_raw()
        x = gyro["x"]
        y = gyro["y"]
        z = gyro["z"]
        sense_data.extend([x, y, z])

        return sense_data
开发者ID:PaulSolheim,项目名称:Robotkurs,代码行数:59,代码来源:senselogger.py

示例9: SensorClient

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
class SensorClient(object):

	def __init__(self, broker, broker_port):
		self.sense=SenseHat()
		self.broker=broker
		self.broker_port=broker_port
		self.client_id=uname()[1]
		
		sub_topics=	{	"temperature"	:	lambda: self.sense.get_temperature(),
					"humidity"	:	lambda: self.sense.get_humidity(),
					"pressure"	:	lambda:	self.sense.get_pressure() }

		self.topics={}
		root_topic="%s/sensehat"%self.client_id
		for sub_topic in sub_topics.keys():
			topic="%s/%s"%(root_topic, sub_topic)
			self.topics[topic]=sub_topics[sub_topic]
			

	def on_connect(self, client, userdate, flags, rc):
		for topic in sorted(self.topics):
			print "Subscribing to %s"%(topic)
			client.subscribe( topic )
		self.publish_sensor_topics()

	# If we recieve the payload of '?' (question-mark)
	# Then publish the value to the topic
	def on_message(self, client, userdata, msg):
		if msg.payload=="?":
			try:
				self.publish_topic( msg.topic )
			except Exception as e:
				print "Error when trying to publish '%s' ?"%msg.topic
		else:
			print "Ignoring message %s=%s"%(msg.topic, msg.payload)
		
	
	def publish_topic( self, topic ):
		topic_value=self.topics[topic]() # execute the Lambda to fetch value
		print "Publishing %s=%s"%(topic, topic_value)
		self.mqtt_client.publish( topic, topic_value )

	# Publish all topics (called when we first connect)
	def publish_sensor_topics(self):
		for topic in sorted(self.topics):
			self.publish_topic( topic )

	def run(self):
		self.mqtt_client=mqtt.Client( self.client_id )
		self.mqtt_client.on_message=self.on_message
		self.mqtt_client.on_connect=self.on_connect
		self.mqtt_client.connect(broker, broker_port)
		self.mqtt_client.loop_forever()
开发者ID:midijohnny,项目名称:sensehat,代码行数:55,代码来源:sensor_client.py

示例10: root

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
def root():
    sense = SenseHat()
    temp1 = sense.get_temperature()   
    temp2 = sense.get_temperature_from_pressure() 
    pressure = sense.get_pressure()
    north = sense.get_compass()
    accel_only = sense.get_accelerometer()
    acc_raw = sense.get_accelerometer_raw()
    temp = "Temp {:10.4f}".format(temp1) + " {:10.4f}".format(temp2) 
    other = "Pres {:10.4f}".format(pressure) + " Compas {:10.4f}".format(north)
    acc1 = "p: {pitch}, r: {roll}, y: {yaw}".format(**accel_only)
    acc2 = "x: {x}, y: {x}, z: {z}".format(**acc_raw)
    print temp + "\n" + other + "\n" + acc1 + "\n" + acc2 + "\n"
开发者ID:rtibell,项目名称:sens1,代码行数:15,代码来源:app1.py

示例11: update

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
 def update(self):
     """Get the latest data from Sense HAT."""
     from sense_hat import SenseHat
     sense = SenseHat()
     temp_from_h = sense.get_temperature_from_humidity()
     temp_from_p = sense.get_temperature_from_pressure()
     t_cpu = get_cpu_temp()
     t_total = (temp_from_h + temp_from_p) / 2
     t_correct = t_total - ((t_cpu - t_total) / 1.5)
     t_correct = get_average(t_correct)
     self.temperature = t_correct
     self.humidity = sense.get_humidity()
     self.pressure = sense.get_pressure()
开发者ID:Teagan42,项目名称:home-assistant,代码行数:15,代码来源:sensehat.py

示例12: sensors

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
def sensors():

    from sense_hat import SenseHat

    sense = SenseHat()

    tempC = sense.get_temperature()  # obtains temperature in Celsius from sensor
    tempC = round(tempC, 1)
    tempF = c_to_f(tempC)  # conversion from Celsius to Fahrenheit
    tempF = round(tempF, 1)

    print "\nThe temperature at the Sense Hat is", tempC, "C or", tempF, "F"

    humidity = sense.get_humidity()
    humidity = round(humidity, 1)

    print "The relative humidity at the Sense Hat is", humidity, "%"

    pressure = sense.get_pressure()
    pressure = round(pressure, 1)

    print "The atmospheric pressure at the Sense Hat is", pressure, "mbar\n"

    # outputing the temp, humidity, and pressure to the matrix
    sense.clear()  # clear the 8x8 matrix
    sense.set_rotation(0)  # sets orientation of Sense Hat matrix

    # setting colors for the scrolling text on the matrix
    red = (255, 0, 0)
    green = (0, 255, 0)
    blue = (0, 0, 255)

    speed = 0.02  # speed of text scroll (0.10 is default)
    sleep = 0.2  # time of pause in seconds

    sense.show_message("Temp:", text_colour=red, scroll_speed=speed)
    sense.show_message(str(tempC), text_colour=red, scroll_speed=speed)
    sense.show_message("C", text_colour=red, scroll_speed=speed)
    sense.show_message("or", text_colour=red, scroll_speed=speed)
    sense.show_message(str(tempF), text_colour=red, scroll_speed=speed)
    sense.show_message("F", text_colour=red, scroll_speed=speed)
    time.sleep(sleep)
    sense.show_message("Humidity:", text_colour=green, scroll_speed=speed)
    sense.show_message(str(humidity), text_colour=green, scroll_speed=speed)
    sense.show_message("%", text_colour=green, scroll_speed=speed)
    time.sleep(sleep)
    sense.show_message("Pressure:", text_colour=blue, scroll_speed=speed)
    sense.show_message(str(pressure), text_colour=blue, scroll_speed=speed)
    sense.show_message("mbar", text_colour=blue, scroll_speed=speed)

    sense.clear()
开发者ID:muku42,项目名称:initial-foray-into-raspberry-pi,代码行数:53,代码来源:sensor_plus_apollo_soyuz.py

示例13: lab_temp

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
def lab_temp(): 
	import sys 
	from sense_hat import SenseHat

	sense = SenseHat()

	temperature = sense.get_temperature()
	pressure = sense.get_pressure()
	humidity = sense.get_humidity()

	if temperature is not None and pressure is not None and humidity is not None: 
		return render_template("lab_temp.html",temp=temperature, pres=pressure, hum=int(humidity)) 
	else: 
		return render_template("no_sensor.html") 
开发者ID:davewri,项目名称:Raspberry-PI-Sensor-Web-App,代码行数:16,代码来源:lab_app.py

示例14: get_metrics

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
def get_metrics():

    if settings.SENSE_HAT:
        try:
            from sense_hat import SenseHat
        except ImportError:
            raise SystemExit('[ERROR] Please make sure sense_hat is installed properly')

    sense = SenseHat()
    data = {}
    data['temperature'] = sense.get_temperature();
    data['humidity'] = sense.get_humidity();
    data['pressure'] = sense.get_pressure();

    return data;
开发者ID:jregueirar,项目名称:pirest-sense-hat,代码行数:17,代码来源:cron.py

示例15: Sens_data

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_pressure [as 别名]
class Sens_data():
    def __init__(self):
        self.sense = SenseHat()

    def get_temperature(self):
        return "%.2f" % self.sense.get_temperature()

    def get_humidity(self):
        return "%.2f" % self.sense.get_humidity()

    def get_pressure(self):
        return "%.2f" % self.sense.get_pressure()

    def get_timestamp(self):
        return str(int(time.time()))
开发者ID:ariksidney,项目名称:Raspberry-Pi-real-time-meteo-data-with-AWS-IoT,代码行数:17,代码来源:iot_send_to_lambda.py


注:本文中的sense_hat.SenseHat.get_pressure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。