首页 > 解决方案 > 使用 Raspberry Pi 3 的 Full Weather Station 使用 Python 编写的难题

问题描述

我正在尝试使用 Raspberry Pi 3 建立气象站代码将用 Python 编写 Raspberry Pi 将直接与 Adafruit DHT-22 传感器、BMP-180 传感器和 DS18B20 传感器连接远程站将使用ESP-8266 和 Raspberry Pi 将从 Open Weather Maps 进行测量,这将是一个 GUI,并且测量结果将显示在 Thinkspeak 上(对于 IOT 部分)我现在的问题是我想显示来自传感器,但我也想显示与 ESP-8266 传感器和开放天气图的区别

#类似这样的事情#“站和卫星的温差是……”#or#“测量值相等”

有没有办法在 Python 中创建一个命令,因为 Pycharm 对我的代码不满意......

import Adafruit_DHT
import pyowm

DHT22Sensor = Adafruit_DHT.DHT22
DHTpin = 16

humidity_indoors, temperature_indoors = Adafruit_DHT.read_retry(DHT22Sensor, DHTpin)

degree_sign = u'\N{DEGREE SIGN}'
owm = pyowm.OWM('')
observation = owm.weather_at_place('Larissa, GR')
weather_sat = observation.get_weather()
status_sat = weather.get_detailed_status()
temperature_sat = weather.get_temperature('celsius')['temp']
wind_sat = weather.get_wind('miles_hour')['speed']
humidity_sat = weather.get_humidity()

def mphtokmh(wind):
    kmh = (float)(wind * 1.60)
    return kmh

if humidity_indoors is not None and temperature_indoors is not None :
    print('Temp={0:0.1 f} * C Humidity={1:0.1 f}%' .format(temperature_indoors, humitity_indoors))
else :
    print('Failed to get reading, Try Again!')

print("The Sky is...{}".format(status_sat))
print("the temperature in our town is...{}C".format(temperature_sat))
print("the windspeed is...{}Km/h".format(wind_sat))
print("humid is...{}"%.format(humitity_sat))

if temperature_sat==temperature_indoors
    print("No Difference to show")

if temperature_sat>temperature_indoors
    print(temperature_sat)

if temperature_sat<temperature_indoors
    print(temperature_indoors)

(ps这只是一个测试代码)

标签: pythonraspberry-pi

解决方案


推荐阅读