大气污染对人类健康和生态环境产生着广泛而深远的影响。随着工业化进程的加速和城市化的快速发展,大气污染问题日益严重。
大气污染不仅会导致水源、土壤污染,还会在一定程度上增加人类患呼吸系统等疾病的风险,更会破坏生态系统平衡,威胁到生物多样性。而气象因素在大气污染的产生、扩散传播以及清除过程中起着至关重要的作用。
本项目旨在研究气象与大气污染之间的关联性,探究大气污染治理的技术与方法,提高大气污染监测、预报与治理能力。
”气象及大气质量监测可视化平台“中,使用主控器结合多种传感器模块、数据采集模块,实现项目功能。
主控器:为行空板。
传感器包括:Gravity: PM2.5空气质量传感器、Gravity: ENS160 空气质量传感器、云雀气象仪。
数据采集模块为:Gravity: SCI采集模块。
“气象及大气质量监测可视化平台“系统接线原理图如下:
“气象及大气质量监测可视化平台“系统实物接线图如下:
程序一:实时天气信息
程序二:一周AQI
程序三:AQI提醒
程序四:AQI分级天数
程序五:主程序
# -*- coding: UTF-8 -*-
# MindPlus
# Python
from DFRobot_Atmospherlum import *
from dfrobot_rp2040_sci import *
from pinpong.board import Board
from air import AIR
import requests
import base64
import siot
import time
# 自定义函数
def JinYiZhouAQI():
AQI7Day = air.aqi_next_week()
AQI7Date = air.week_next_week()
siot.publish_save(topic="siot/AQIDay1", data=(AQI7Date[0]))
siot.publish_save(topic="siot/AQIDay2", data=(AQI7Date[1]))
siot.publish_save(topic="siot/AQIDay3", data=(AQI7Date[2]))
siot.publish_save(topic="siot/AQIDay4", data=(AQI7Date[3]))
siot.publish_save(topic="siot/AQIDay5", data=(AQI7Date[4]))
siot.publish_save(topic="siot/AQIDay6", data=(AQI7Date[5]))
siot.publish_save(topic="siot/AQIDay7", data=(AQI7Date[6]))
siot.publish_save(topic="siot/AQI7Day", data=(str((AQI7Day[0])) + str((str(",") + str((str((AQI7Day[1])) + str((str(",") + str((str((AQI7Day[2])) + str((str(",") + str((str((AQI7Day[3])) + str((str(",") + str((str((AQI7Day[4])) + str((str(",") + str((str((AQI7Day[5])) + str((str(",") + str((AQI7Day[6]))))))))))))))))))))))))))
def ShiShiTianQiYuBao():
url = "https://www.yiketianqi.com/free/day?appid=" + "86943926" + "&appsecret=" + "Tj6vFcS0" + "&unescape=1&city=" + "西安"
response = requests.get(url)
data = response.json()
time.sleep(1)
siot.publish_save(topic="siot/wea", data=data["wea"])
siot.publish_save(topic="siot/tem", data=(str(data["tem"]) + str("℃")))
siot.publish_save(topic="siot/humidity", data=data["humidity"])
siot.publish_save(topic="siot/tem_night_day", data=(str((str(data["tem_night"]) + str((str("~") + str(data["tem_day"]))))) + str("℃")))
siot.publish_save(topic="siot/win", data=data["win"])
siot.publish_save(topic="siot/win_speed", data=data["win_speed"])
siot.publish_save(topic="siot/win_meter", data=data["win_meter"])
siot.publish_save(topic="siot/air", data=(str("空气质量:") + str(data["air"])))
siot.publish_save(topic="siot/pressure", data=(str("气压:") + str(data["pressure"])))
siot.publish_save(topic="siot/date", data=data["date"])
siot.publish_save(topic="siot/update_time", data=(str(data["date"]) + str((str(" ") + str(data["update_time"])))))
siot.publish_save(topic="siot/week", data=data["week"])
siot.publish_save(topic="siot/city", data=data["city"])
siot.publish_save(topic="siot/wea_img", data=encode_image((str("image/") + str((str(data["wea_img"]) + str(".png"))))))
def AQITuXiang():
url = "https://www.yiketianqi.com/free/day?appid=" + "86943926" + "&appsecret=" + "Tj6vFcS0" + "&unescape=1&city=" + "西安"
response = requests.get(url)
data = response.json()
time.sleep(1)
air.aqi_img()
siot.publish_save(topic="siot/aqi_img", data=encode_image("img.png"))
def KongQiZhiLiangFenJiTianShu():
You = 32
Liang = 69
QingDuWuRan = 47
ZhongDuWuRan = 19
ZhongDuWuRan1 = 8
YanZhongWuRan = 5
siot.publish_save(topic="siot/PieGraph", data=(str(You) + str((str(",") + str((str(Liang) + str((str(",") + str((str(QingDuWuRan) + str((str(",") + str((str(ZhongDuWuRan) + str((str(",") + str((str(ZhongDuWuRan1) + str((str(",") + str(YanZhongWuRan)))))))))))))))))))))
def AQITiXing():
global AQI
global PollutionLevel
global AQClass
global AQIGirl
global Effect
global TravelAdvice
if (AQI <= 50):
PollutionLevel = (str("优"))
AQClass = (str("一级"))
AQIGirl = 1
Effect = (str("空气质量令人满意,基本无空气污"))
TravelAdvice = (str("各类人群可正常活动"))
elif ((AQI >= 51) and (AQI <= 100)):
PollutionLevel = (str("良"))
AQClass = (str("二级"))
AQIGirl = 1
Effect = (str("空气质量可接受,但某些污染物可能对极少数异常敏感人群健康有较弱影响"))
TravelAdvice = (str("极少数异常敏感人群应减少户外活动"))
elif ((AQI >= 101) and (AQI <= 150)):
PollutionLevel = (str("轻度污染"))
AQClass = (str("三级"))
AQIGirl = 3
Effect = (str("易感人群症状有轻度加剧,健康人群出现刺激症状"))
TravelAdvice = (str("儿童、老年人及心脏病、呼吸系统疾病患者应减少长时间、高强度的户外锻炼"))
elif ((AQI >= 106) and (AQI <= 200)):
PollutionLevel = (str("中度污染"))
AQClass = (str("四级"))
AQIGirl = 4
Effect = (str("进一步加剧易感人群症状,可能对健康人群心脏、呼吸系统有影响"))
TravelAdvice = (str("儿童、老年人及心脏病、呼吸系统疾病患者避免长时间、高强度的户外锻炼,一般人群适量减少户外运动"))
elif ((AQI >= 201) and (AQI <= 300)):
PollutionLevel = (str("重度污染"))
AQClass = (str("五级"))
AQIGirl = 5
Effect = (str("心脏病和肺病患者症状显著加剧,运动耐受力降低,健康人群普遍出现症状"))
TravelAdvice = (str("儿童、老年人及心脏病、肺病患者应停留在室内,停止户外运动,一般人群减少户外运动"))
elif (AQI >= 300):
PollutionLevel = (str("严重污染"))
AQClass = (str("六级"))
AQIGirl = 6
Effect = (str("健康人群运动耐受力降低,有明显强烈症状,提前出现某些疾病"))
TravelAdvice = (str("儿童、老年人和病人应当留在室内,避免体力消耗,一般人群应避免户外运动"))
siot.publish_save(topic="siot/TravelAdvice", data=TravelAdvice)
siot.publish_save(topic="siot/Effect", data=Effect)
siot.publish_save(topic="siot/PollutionLevel", data=PollutionLevel)
siot.publish_save(topic="siot/AQClass", data=AQClass)
siot.publish_save(topic="siot/AQI", data=AQI)
siot.publish_save(topic="siot/AQIGirl", data=encode_image((str("aqi/rw") + str((str(AQIGirl) + str(".png"))))))
def DingYue():
siot.getsubscribe(topic="siot/AQI")
siot.getsubscribe(topic="siot/TVOC")
siot.getsubscribe(topic="siot/ECO2")
siot.getsubscribe(topic="siot/PM1.0")
siot.getsubscribe(topic="siot/PM2.5")
siot.getsubscribe(topic="siot/PM10")
siot.getsubscribe(topic="siot/Speed")
siot.getsubscribe(topic="siot/Dir")
siot.getsubscribe(topic="siot/Pressure")
siot.getsubscribe(topic="siot/Temp&Humi")
def FaBu():
siot.publish_save(topic="siot/AQI", data=SCI1.get_value1(SCI1.eALL,"AQI"))
AQI = SCI1.get_value1(SCI1.eALL,"AQI")
siot.publish_save(topic="siot/TVOC", data=SCI1.get_value1(SCI1.eALL,"TVOC"))
siot.publish_save(topic="siot/ECO2", data=SCI1.get_value1(SCI1.eALL,"ECO2"))
siot.publish_save(topic="siot/PM1.0", data=SCI1.get_value1(SCI1.eALL,"PM1.0"))
siot.publish_save(topic="siot/PM2.5", data=SCI1.get_value1(SCI1.eALL,"PM2.5"))
siot.publish_save(topic="siot/PM10", data=SCI1.get_value1(SCI1.eALL,"PM10"))
siot.publish_save(topic="siot/Speed", data=(yunque_i2c.get_value("speed")))
siot.publish_save(topic="siot/Dir", data=(yunque_i2c.get_value("dir")))
siot.publish_save(topic="siot/Pressure", data=(yunque_i2c.get_value("Pressure")))
siot.publish_save(topic="siot/Temp&Humi", data=(str((yunque_i2c.get_value("Temp"))) + str((str(",") + str((yunque_i2c.get_value("Humi")))))))
def DaYin():
print(SCI1.get_value1(SCI1.eALL,"AQI"))
print(SCI1.get_value1(SCI1.eALL,"TVOC"))
print(SCI1.get_value1(SCI1.eALL,"ECO2"))
print(SCI1.get_value1(SCI1.eALL,"PM1.0"))
print(SCI1.get_value1(SCI1.eALL,"PM2.5"))
print(SCI1.get_value1(SCI1.eALL,"PM10"))
print((yunque_i2c.get_value("speed")))
print((yunque_i2c.get_value("dir")))
print((yunque_i2c.get_value("Pressure")))
print((str((yunque_i2c.get_value("Temp"))) + str((str(",") + str((yunque_i2c.get_value("Humi")))))))
print("=========================")
Board().begin()
siot.init(client_id="742703378615508",server="127.0.0.1",port=1883,user="siot",password="dfrobot")
siot.connect()
siot.loop()
SCI1 = DFRobot_RP2040_SCI_IIC(addr=0x21)
while SCI1.begin() != 0:
print("Initialization Sensor Universal Adapter Board failed.")
time.sleep(1)
print("Initialization Sensor Universal Adapter Board done.")
yunque_i2c = DFRobot_Atmospherlum_I2C(0x42)
while (yunque_i2c.begin() != 0):
print("yunque_i2c initialize failed!!")
time.sleep(1)
print("Sensor initialize success!!")
yunque_i2c.set_local_time()
time.sleep(1)
def encode_image(filename):
ext = filename.split(".")[-1]
with open(filename, "rb") as f:
img = f.read()
data = base64.b64encode(img).decode()
src = "data:image/{ext};base64,{data}".format(ext=ext, data=data)
return src
air = AIR()
DingYue()
JinYiZhouAQI()
AQITuXiang()
while True:
ShiShiTianQiYuBao()
KongQiZhiLiangFenJiTianShu()
AQITiXing()
time.sleep(3)
1、可视化平台界面:
2、实时天气预报:
通过气象网站获取实时天气预报信息,包括:温度、湿度、最高最低温度、风向、风力、天气、气压、空气质量指数、气象图片等信息,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板同步显示。
3、实时气象数据
云雀气象仪、Gravity: PM2.5空气质量传感器、Gravity: ENS160 空气质量传感器实时采集现场PM10、PM2.5、PM1.0、ECO2、TVOC、AQI、气压、风向、风速数据,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板同步显示。
4、空气质量指数AQI:
实时读取的空气质量指数AQI,通过opencv动态生产 AQI图像文件,base64转码后,通过MQTT发送到SIOT并保存到数据库,可视化面板同步显示。
根据上图表2,计算空气质量指数级、类别,动态显示 AQI精灵表情、空气质量等级类别、对健康的影响,以及建议采取的措施(如下图所示),通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板同步显示。
5、实时AQI曲线:
Gravity: ENS160 空气质量传感器实时采集现场空气质量指数AQI,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板折线图同步显示。
6、近一周AQI预报:
采集气象网站近一周的空气质量指数AQI预报信息,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板柱状图同步显示。
7、空气质量AQI分级天数:
采集气象网站近气质量指数AQI分级天数,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板饼图同步显示。
8、实时天二氧化碳曲线:
Gravity: ENS160 空气质量传感器实时采集现场二氧化碳数据,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板折线图同步显示。
9、实时温湿度曲线:
Gravity: ENS160 空气质量传感器实时采集现场温湿度,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板折线图同步显示。
通过本项目,对Mind+的可视化面板的各种组件,有了比较全面的掌握和了解。不过,也发现目前可视化面板的部分组件在细节方面还有很多需要完善的地方,比如组件颜色的定义,字体字号的调整,组件的对齐方式,柱状图类别名称不能连接topic动态更新等,也都一一进行了反馈。期待可视化面板的再次升级。
项目可改进的地方:1、AQI分级天数改为通过网络获取真实数据。2、增加历史数据显示功能。目前可视化平台的数据只能看到实时数据,不能看到历史数据。3、智能终端用户UI的设计。
附件
三春牛-创客2024.04.05
赞赞赞
三春牛-创客2024.04.05
厉害
许培享2024.01.14
漂亮啊
式点2024.01.07
666
腿毛利小五郎2023.10.24
666
hacker_2023.08.18
666