回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页
best-icon

#新物联网挑战二#气象及大气质量监测可视化平台 简单

头像 豆爸 2023.06.26 910 6

1688857635490_4F2CAE38-1CA7-4605-90EE-D6DB14DA924D.png

 

        大气污染对人类健康和生态环境产生着广泛而深远的影响。随着工业化进程的加速和城市化的快速发展,大气污染问题日益严重。

        

        大气污染不仅会导致水源、土壤污染,还会在一定程度上增加人类患呼吸系统等疾病的风险,更会破坏生态系统平衡,威胁到生物多样性。而气象因素在大气污染的产生、扩散传播以及清除过程中起着至关重要的作用。

 

        本项目旨在研究气象与大气污染之间的关联性,探究大气污染治理的技术与方法,提高大气污染监测、预报与治理能力。

 

 

 

 

系统功能.jpg

 

思维导图.png

 

1688857716375_4744E28A-2452-46fa-AEAA-F18FE5DF1837.png

 

 

        ”气象及大气质量监测可视化平台“中,使用主控器结合多种传感器模块、数据采集模块,实现项目功能。

 

 

主控器:为行空板。

 

 

传感器包括:Gravity: PM2.5空气质量传感器、Gravity: ENS160 空气质量传感器、云雀气象仪。

 

 

数据采集模块为:Gravity: SCI采集模块。

 

硬件.png

 

 

 

1688857732316_77026C2E-B69A-4265-A567-930D8CD1CB9D.png

 

        “气象及大气质量监测可视化平台“系统接线原理图如下:

 

 

 

接线图.jpg

 

 

 

 

 

 

        “气象及大气质量监测可视化平台“系统实物接线图如下:

 

实物接线图.jpg

 

 

D1B7DC40-F081-4190-ABB1-6BB28E6D40C8.jpg

 

1689101193405_007E1344-8BCC-47e4-9BC6-895EF191C205.png

 

1689101213457_8E2761B9-9BF4-4e01-B495-B663FA5A70DE.png

 

 

1689101246474_AAB05173-F9C9-4b55-9719-C9DB8F2F737B.png

 

 

1689101262239_DBB5A873-0A8B-4cca-A76D-5991EEBBE018.png

 

 

 

 

1688857775270_57AE20B7-6F04-4889-B5F3-C250C0204775.png

 

程序一:实时天气信息

 

实时天气预报.png

 

 

 

程序二:一周AQI

 

一周AQI.png

 

程序三:AQI提醒

 

AQI提醒.png

 

程序四:AQI分级天数

 

AQI分级天数.png

 

程序五:主程序

 

主程序.png

代码
#  -*- 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)

 

875582de10ad4f0eeaff02a54ff63bd2.jpg

 

 

1、可视化平台界面:

 

       

截图.jpg

 

 

2、实时天气预报:

 

        通过气象网站获取实时天气预报信息,包括:温度、湿度、最高最低温度、风向、风力、天气、气压、空气质量指数、气象图片等信息,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板同步显示。

 

 

 

1689213785712_8EF43A59-E2E4-4a1c-A26E-D369D2FDA2BB.png

 

 

 

3、实时气象数据

 

        云雀气象仪、Gravity: PM2.5空气质量传感器、Gravity: ENS160 空气质量传感器实时采集现场PM10、PM2.5、PM1.0、ECO2、TVOC、AQI、气压、风向、风速数据,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板同步显示。

 

 

 

 

1689253082544_9C2D6CF6-84E8-4b9d-82D0-3E09AFDD4F7B.png

 

 

 

 

4、空气质量指数AQI:

 

 

       1689213871218_DF28D81E-E032-4f5a-8754-8248AAB88FBF.png

 

 

 

        实时读取的空气质量指数AQI,通过opencv动态生产 AQI图像文件,base64转码后,通过MQTT发送到SIOT并保存到数据库,可视化面板同步显示。

        

e53327019ac697d54cd76ebd62d2b2a.png

 

        根据上图表2,计算空气质量指数级、类别,动态显示 AQI精灵表情、空气质量等级类别、对健康的影响,以及建议采取的措施(如下图所示),通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板同步显示。

 

AQI.gif

 

 

 

 

5、实时AQI曲线:

 

        Gravity: ENS160 空气质量传感器实时采集现场空气质量指数AQI,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板折线图同步显示。

 

 

 

1689213894368_46AAEBB4-AC0C-448c-A2D3-6F587BDDF5CA.png

 

 

6、近一周AQI预报:

 

        采集气象网站近一周的空气质量指数AQI预报信息,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板柱状图同步显示。

 

 

 

1689213906820_44B16719-4E18-40fb-A3CA-67711C339930.png

 

 

 

7、空气质量AQI分级天数:

 

        采集气象网站近气质量指数AQI分级天数,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板饼图同步显示。

 

 

1689213922047_EA994979-45DA-4d32-8893-6DA5A5C058FD.png

 

 

 

8、实时天二氧化碳曲线:

 

        Gravity: ENS160 空气质量传感器实时采集现场二氧化碳数据,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板折线图同步显示。

 

 

1689213938698_74412A6B-1708-4fdd-AB32-A4E3B02E0087.png

 

 

9、实时温湿度曲线:

 

        Gravity: ENS160 空气质量传感器实时采集现场温湿度,通过 MQTT发送到 SIOT服务器,并保存到数据库,可视化面板折线图同步显示。

 

 

 

1689213950721_D8649043-7590-4dd8-BE6F-366238A9D125.png

 

 

2222.jpg

 

        通过本项目,对Mind+的可视化面板的各种组件,有了比较全面的掌握和了解。不过,也发现目前可视化面板的部分组件在细节方面还有很多需要完善的地方,比如组件颜色的定义,字体字号的调整,组件的对齐方式,柱状图类别名称不能连接topic动态更新等,也都一一进行了反馈。期待可视化面板的再次升级。

 

        项目可改进的地方:1、AQI分级天数改为通过网络获取真实数据。2、增加历史数据显示功能。目前可视化平台的数据只能看到实时数据,不能看到历史数据。3、智能终端用户UI的设计。

1688857795623_E9C37207-6D63-4c47-A0D7-B50982E95488.png

 

评论

user-avatar
  • 三春牛-创客

    三春牛-创客2024.04.05

    赞赞赞

    0
    • 三春牛-创客

      三春牛-创客2024.04.05

      厉害

      0
      • 许培享

        许培享2024.01.14

        漂亮啊

        0
        • 式点

          式点2024.01.07

          666

          0
          • 腿毛利小五郎

            腿毛利小五郎2023.10.24

            666

            0
            • hacker_

              hacker_2023.08.18

              666

              0