湿度读数可疑

时间:2018-08-28 15:17:22

标签: python-2.7 raspberry-pi

我有DHT11和BMP20吗?连接到我的RPi0W并位于我的爬网空间中。我的目标是维护随时间变化的温度和湿度读数数据库,并观察诸如用1000万塑料衬里“地板”的情况的影响。

这是我用来收集读数的代码:

#!/usr/bin/python   **Runs every ten minutes using Cron**
import sys
import Adafruit_DHT
import MySQLdb
import time

from Adafruit_BME280 import *

sensor = BME280(address=0x76,t_mode=BME280_OSAMPLE_8, p_mode=BME280_OSAMPLE_8, h_mode=BME280_OSAMPLE_8)

conn=MySQLdb.connect(host="192.168.2.204",user="jim",passwd="xxxxxxxxx",db="EnviroLogger")
c=conn.cursor()

humidity, temperaturec = Adafruit_DHT.read_retry(11, 4)
temperaturef=((temperaturec*9.000)/5.000)+32.000
datatime=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())

dhtvalues="(null,'DHT-8200-Crawl',"+str(temperaturef)+","+str(humidity)+",null,'"+datatime+"')"


time.sleep(1)
BMPtemperaturef = ((sensor.read_temperature()*9.000)/5.000)+32.000
hectopascals = sensor.read_pressure()/100.0000
BMPhumidity = sensor.read_humidity()

bmpvalues="(null,'BMP-8200-Crawl',"+str(temperaturef)+","+str(humidity)+","+str(hectopascals)+",'"+datatime+"');"

finalSQLstring="INSERT INTO ResDataLog(ID,Location,Temperature, Humidity, Pressure, RecDate) VALUES " + dhtvalues +","+bmpvalues
c.execute (finalSQLstring)
conn.commit()

问题是,我在95%的湿度和几乎77华氏度的温度下获得一致的读数。这是我的查询

SELECT
    CAST(
        DATE_FORMAT(RecDate, '%k') AS INTEGER
    ) AS TOD,
    AVG(Temperature),
    AVG(humidity)
FROM
    `ResDataLog`
WHERE
    recdate >= '2018-08-27'
GROUP BY
    TOD

相信我,“平均值”与细节完全相同。...

现在,当我将传感器包装从房屋内部移动到房屋下方时,读数确实发生了变化,但是仅从固体变为固体(从59%到95%。)

我是否有理想的湿度(我的除湿机在十英尺远的地方,否则……)还是在编码时出错?

0 个答案:

没有答案