本文整理汇总了Python中sense_hat.SenseHat.get_temperature_from_pressure方法的典型用法代码示例。如果您正苦于以下问题:Python SenseHat.get_temperature_from_pressure方法的具体用法?Python SenseHat.get_temperature_from_pressure怎么用?Python SenseHat.get_temperature_from_pressure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sense_hat.SenseHat
的用法示例。
在下文中一共展示了SenseHat.get_temperature_from_pressure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readSensor
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_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()
示例2: __init__
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_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'
示例3: __init__
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_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
示例4: Hat
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_pressure [as 别名]
class Hat(object):
''' `sensed` sensor module for the Raspberry Pi Sense HAT. This
module returns a dictionary of all built in sensors. '''
def __init__(self, config: DotMap) -> None:
if config.sensed.test is not True:
from sense_hat import SenseHat
self.sense = SenseHat()
def get_data(self) -> dict:
# Environmental sensors
humid = self.sense.humidity
temp = self.sense.temperature
temp_h = self.sense.get_temperature_from_humidity()
temp_p = self.sense.get_temperature_from_pressure()
press = self.sense.pressure
# IMU (inertial measurement unit) sensors
orient_r = self.sense.orientation_radians
orient_d = self.sense.orientation
compass = self.sense.compass
compass_r = self.sense.compass_raw
gyro = self.sense.gyroscope
gyro_r = self.sense.gyroscope_raw
accel = self.sense.accelerometer
accel_r = self.sense.accelerometer_raw
return {'environment': {'humidity': humid,
'temperature': temp,
'temperature_h': temp_h,
'temperature_p': temp_p,
'pressure': press},
'imu': {'orientation_rad': orient_r,
'orientation_deg': orient_d,
'compass': compass,
'compass_r': compass_r,
'gyroscope': gyro,
'gyroscope_r': gyro_r,
'accelerometer': accel,
'accelerometer_raw': accel_r}}
def test(self) -> dict:
return {'environment': {'humidity': 1,
'temperature': 2,
'temperature_h': 3,
'temperature_p': 4,
'pressure': 5},
'imu': {'orientation_rad': 6,
'orientation_deg': 7,
'compass': 8,
'compass_r': 9,
'gyroscope': 10,
'gyroscope_r': 11,
'accelerometer': 12,
'accelerometer_raw': 13}}
示例5: __init__
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_pressure [as 别名]
class _SenseHat:
def __init__(self, board_object, colour=""):
self.board = board_object
self.colour = colour
self.sense = SenseHat()
def magnetometer_on(self):
self.sense.set_imu_config(True, False, False) # gyroscope only
@property
def temp_c(self):
return (self.sense.get_temperature_from_humidity() +
self.sense.get_temperature_from_pressure())/2
@property
def pressure(self):
return self.sense.pressure
@property
def humidity(self):
return self.sense.humidity
def led_all(self, colour):
lcd = []
for i in range(0, 64):
lcd.append(colour)
self.sense.set_pixels(lcd)
def led_1(self, colour):
self.sense.set_pixel(0, 0, colour)
self.sense.set_pixel(0, 1, colour)
self.sense.set_pixel(1, 0, colour)
self.sense.set_pixel(1, 1, colour)
def led_2(self, colour):
self.sense.set_pixel(2, 2, colour)
self.sense.set_pixel(2, 3, colour)
self.sense.set_pixel(3, 2, colour)
self.sense.set_pixel(3, 3, colour)
def led_3(self, colour):
self.sense.set_pixel(4, 4, colour)
self.sense.set_pixel(4, 5, colour)
self.sense.set_pixel(5, 4, colour)
self.sense.set_pixel(5, 5, colour)
def led_4(self, colour):
self.sense.set_pixel(6, 6, colour)
self.sense.set_pixel(6, 7, colour)
self.sense.set_pixel(7, 6, colour)
self.sense.set_pixel(7, 7, colour)
def clear(self):
self.sense.clear()
示例6: update
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_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()
示例7: root
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_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"
示例8: TemperatureEventEmitter
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_pressure [as 别名]
class TemperatureEventEmitter(EventEmitter):
def __init__(self, servers, topic, identifier):
EventEmitter.__init__(self, servers, topic)
self.contents = dict()
self.contents["id"] = identifier
self.event["@timestamp"] = datetime.utcnow()
self.event["data"] = self.contents
self.sense = SenseHat()
def update_event(self):
self.event["@timestamp"] = datetime.utcnow()
self.event["data"]["temperature"] = round( (self.sense.get_temperature_from_pressure()+self.sense.get_temperature_from_humidity())/2,1)
self.event["data"]["pressure"] = round(self.sense.get_pressure(),1)
self.event["data"]["humidity"] = round(self.sense.get_humidity(),1)
self.send()
示例9: get_current_data
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_pressure [as 别名]
def get_current_data():
if(enable_sense_hat):
sense = SenseHat()
sense.clear()
t = sense.get_temperature()
p = sense.get_pressure()
h = sense.get_humidity()
tp = sense.get_temperature_from_pressure()
data = {
'temperature':str(round(t, 1)),
'pressure':str(round(p,1)),
'humidity':str(round(h,1)),
'temperatureP':str(round(tp,1)),
'datetime' : datetime.now()
}
else:
data = {
'temperature': 0,
'pressure':0,
'humidity':0,
'temperatureP':0,
'datetime' : datetime.now()
}
return data
示例10: print
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_pressure [as 别名]
logging.error(err_str)
# Print to stanard out
print(err_str)
## Entry point.
try:
# Setup log
logging.basicConfig(filename=log_filename,
level=logging.ERROR)
# Access to sense hat library
sense = SenseHat()
# Pull all sensor readings
temperature = (sense.get_temperature() * 9/5) + 32
temperature_pressure = (sense.get_temperature_from_pressure() * 9/5)+32
humidity = sense.get_humidity()
pressure = sense.get_pressure()
# Get the current date and time
current_datetime = datetime.datetime.now()
# Attempt to connect to the mysql database
cnx = mysql.connector.connect(user='root', password='ENTER_PASSWORD',
host='127.0.0.1', database='wordpress')
cursor = cnx.cursor()
# Add measurements to the table
cursor.execute("INSERT INTO weather (temperature, temperature_pressure,"
" humidity, pressure, year, month, day, hour, minute, second) "
示例11: SenseHat
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_pressure [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sense_hat import SenseHat
from time import sleep
sh = SenseHat()
try:
while True:
th = sh.get_temperature()
tp = sh.get_temperature_from_pressure()
p = sh.get_pressure()
h = sh.get_humidity()
th = round( th, 1 )
tp = round( tp, 1 )
p = round( p, 1 )
h = round( h, 1 )
print( "Temp (H) = %s°C Temp (P) = %s°C Prsr = %smb Hmdt = %s%%" %(th,tp,p,h) )
sleep( 1 )
except KeyboardInterrupt:
print( "Exiting..." );
示例12: sleep
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_pressure [as 别名]
mqttc.connect(awshost, awsport, keepalive=60)
mqttc.loop_start()
while True:
message = {}
device = {}
device['cpuTemperature'] = os.popen('vcgencmd measure_temp').readline().replace("temp=","").replace("'C\n","")
environment = {}
temp = {}
temp['basedOnHumidity'] = sense.get_temperature_from_humidity()
temp['basedOnPressure'] = sense.get_temperature_from_pressure()
environment['humidity'] = sense.get_humidity()
environment['pressure'] = sense.get_pressure()
environment['temperature'] = temp
message['device'] = device
message['environment'] = environment
jsonData = json.dumps(message)
if connflag == True:
mqttc.publish("environmentData", jsonData, qos=1)
print jsonData
sleep(10)
else:
示例13: PiSenseHat
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_pressure [as 别名]
class PiSenseHat(object):
"""Raspberry Pi 'IoT Sense Hat API Driver Class'."""
# Constructor
def __init__(self):
self.sense = SenseHat()
# enable all IMU functions
self.sense.set_imu_config(True, True, True)
# pixel display
def set_pixel(self,x,y,color):
# red = (255, 0, 0)
# green = (0, 255, 0)
# blue = (0, 0, 255)
self.sense.set_pixel(x, y, color)
# clear pixel display
def clear_display(self):
self.sense.clear()
# Pressure
def getPressure(self):
return self.sense.get_pressure()
# Temperature
def getTemperature(self):
return self.sense.get_temperature()
# Humidity
def getHumidity(self):
return self.sense.get_humidity()
def getHumidityTemperature(self):
return self.sense.get_temperature_from_humidity()
def getPressureTemperature(self):
return self.sense.get_temperature_from_pressure()
def getOrientationRadians(self):
return self.sense.get_orientation_radians()
def getOrientationDegrees(self):
return self.sense.get_orientation_degrees()
# degrees from North
def getCompass(self):
return self.sense.get_compass()
def getAccelerometer(self):
return self.sense.get_accelerometer_raw()
def getEnvironmental(self):
sensors = {'name' : 'sense-hat', 'environmental':{}}
return sensors
def getJoystick(self):
sensors = {'name' : 'sense-hat', 'joystick':{}}
return sensors
def getInertial(self):
sensors = {'name' : 'sense-hat', 'inertial':{}}
def getAllSensors(self):
sensors = {'name' : 'sense-hat', 'environmental':{}, 'inertial':{}, 'joystick':{}}
sensors['environmental']['pressure'] = { 'value':self.sense.get_pressure(), 'unit':'mbar'}
sensors['environmental']['temperature'] = { 'value':self.sense.get_temperature(), 'unit':'C'}
sensors['environmental']['humidity'] = { 'value':self.sense.get_humidity(), 'unit': '%RH'}
accel = self.sense.get_accelerometer_raw()
sensors['inertial']['accelerometer'] = { 'x':accel['x'], 'y':accel['y'], 'z': accel['z'], 'unit':'g'}
orientation = self.sense.get_orientation_degrees()
sensors['inertial']['orientation'] = { 'compass':self.sense.get_compass(), 'pitch':orientation['pitch'], 'roll':orientation['roll'], 'yaw': orientation['yaw'], 'unit':'degrees'}
return sensors
示例14: move_left
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_pressure [as 别名]
#HUMIDITY 4
d=humidity = my_weather[0]['humidity']
#RAINFALL 5
e=rainfall = my_weather[0]['rainfall']
#AIRPRESSURE 6
a=air_pressure = my_weather[0]['air_pressure']
#GROUNDTEMP 1
c=ground_temp = my_weather[0]['ground_temp']
#AMBIENTTEMP 2
b=ambient_temp = my_weather[0]['ambient_temp']
f=((sense.get_temperature_from_humidity()+sense.get_temperature_from_pressure())/2)
i=0
def move_left (event):
if event.action=='pressed':
global i
i = i-1
print(i)
print(event)
def move_right (event):
if event.action=='pressed':
global i
i = i+1
print(i)
示例15: execute
# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import get_temperature_from_pressure [as 别名]
def execute(self):
sense = SenseHat()
temp = sense.get_temperature()-ADJUSTMENT
temp_hum = sense.get_temperature_from_humidity()-ADJUSTMENT
temp_pre = sense.get_temperature_from_pressure()-ADJUSTMENT
return dict(temp=temp, temp_hum=temp_hum, temp_pre=temp_pre)