第一期 项目搭建、运行
主题简介
我选的主题为---低碳环保探究。
主题要求:随着全球气候变化和环境恶化问题日益严重,低碳环保已成为全球关注的焦点。实现低碳环保的生活方式和发展模式,对于缓解环境压力、保护生态系统具有重要意义。本主题旨在鼓励大家深入探究低碳环保的理念、技术和实践,以提高人们的环保意识和行动力。请你运用所学的科技知识,结合实际生活,针对存在的环境问题,提出具有实际应用价值的低碳环保解决方案,为建设美丽、宜居的地球家园贡献智慧与力量。
免费硬件包:防水温传感器、水TDS传感器、空气温湿度传感器、氧气传感器、空气质量传感器、土壤湿度传感器、分贝传感器、环境光传感器、行空板、SCI采集模块
一、 认识硬件
代码
# -*- coding: UTF-8 -*-
# MindPlus
# Python
from dfrobot_rp2040_sci import *
from pinpong.board import Board
from unihiker import GUI
import time
Board().begin()
u_gui=GUI()
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.")
while True:
u_gui.draw_text(text="祁连山脉之龙首山",x=2,y=5,font_size=20, color="#0000FF")
u_gui.draw_text(text="低碳生态环境监测系统",x=8,y=45,font_size=15, color="#0000FF")
u_gui.draw_text(text="水的TDS值:",x=8,y=90,font_size=15, color="#000000")
u_gui.draw_text(text="O3的值:",x=8,y=120,font_size=15, color="#000000")
u_gui.draw_text(text="AQI的值:",x=8,y=150,font_size=15, color="#000000")
u_gui.draw_text(text="TVOC的值:",x=8,y=180,font_size=15, color="#000000")
u_gui.draw_text(text="ECO2的值:",x=8,y=210,font_size=15, color="#000000")
TDS=u_gui.draw_text(text="",x=130,y=90,font_size=15, color="#000000")
TDS.config(text=SCI1.get_value0("TDS"))
O3=u_gui.draw_text(text="",x=130,y=120,font_size=15, color="#000000")
O3.config(text=SCI1.get_value0("O3"))
AQI=u_gui.draw_text(text="",x=130,y=150,font_size=15, color="#000000")
AQI.config(text=SCI1.get_value0("AQI"))
TVOC=u_gui.draw_text(text="",x=130,y=180,font_size=15, color="#000000")
TVOC.config(text=SCI1.get_value0("TVOC"))
ECO2=u_gui.draw_text(text="",x=130,y=210,font_size=15, color="#000000")
ECO2.config(text=SCI1.get_value0("ECO2"))
time.sleep(10)
u_gui.clear()
time.sleep(0.1)
第二期 物联、可视化界面
代码
# -*- coding: UTF-8 -*-
# MindPlus
# Python
from dfrobot_rp2040_sci import *
from pinpong.board import Board
from unihiker import GUI
import siot
import time
Board().begin()
siot.init(client_id="8592265061910467",server="10.1.2.3",port=1883,user="siot",password="dfrobot")
u_gui=GUI()
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.")
siot.getsubscribe(topic="topic/O2")
siot.getsubscribe(topic="topic/TDS")
siot.getsubscribe(topic="topic/AQI")
siot.getsubscribe(topic="topic/TVOC")
siot.getsubscribe(topic="topic/ECO2")
while True:
u_gui.draw_text(text="祁连山脉之龙首山",x=2,y=5,font_size=20, color="#0000FF")
u_gui.draw_text(text="低碳生态环境监测系统",x=8,y=45,font_size=15, color="#0000FF")
u_gui.draw_text(text="水的TDS值:",x=8,y=90,font_size=15, color="#000000")
u_gui.draw_text(text="O3的值:",x=8,y=120,font_size=15, color="#000000")
u_gui.draw_text(text="AQI的值:",x=8,y=150,font_size=15, color="#000000")
u_gui.draw_text(text="TVOC的值:",x=8,y=180,font_size=15, color="#000000")
u_gui.draw_text(text="ECO2的值:",x=8,y=210,font_size=15, color="#000000")
TDS=u_gui.draw_text(text="",x=130,y=90,font_size=15, color="#000000")
TDS.config(text=SCI1.get_value0("TDS"))
O3=u_gui.draw_text(text="",x=130,y=120,font_size=15, color="#000000")
O3.config(text=SCI1.get_value0("O3"))
AQI=u_gui.draw_text(text="",x=130,y=150,font_size=15, color="#000000")
AQI.config(text=SCI1.get_value0("AQI"))
TVOC=u_gui.draw_text(text="",x=130,y=180,font_size=15, color="#000000")
TVOC.config(text=SCI1.get_value0("TVOC"))
ECO2=u_gui.draw_text(text="",x=130,y=210,font_size=15, color="#000000")
ECO2.config(text=SCI1.get_value0("ECO2"))
time.sleep(10)
u_gui.clear()
time.sleep(0.1)
siot.publish_save(topic="siot/TDS", data=SCI1.get_value1(SCI1.eALL,"TDS"))
siot.publish_save(topic="siot/O3", data=SCI1.get_value1(SCI1.eALL,"O3"))
siot.publish_save(topic="siot/AQI", data=SCI1.get_value1(SCI1.eALL,"AQI"))
siot.publish_save(topic="siot/ECO2", data=SCI1.get_value1(SCI1.eALL,"ECO2"))
siot.publish_save(topic="siot/TVOC", data=SCI1.get_value1(SCI1.eALL,"TVOC"))
三春牛-创客2024.04.05
赞赞赞
三春牛-创客2024.04.05
厉害
tongtong203362023.10.27
666
昊盟2023.10.07
有意思
hacker_2023.08.19
666