回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页

星途安行 - StarTrack Guardian 简单

头像 feng0539 2025.06.30 45 1

一、作品背景

这个模型主要是给老人用的,能获取经纬度显示在屏幕上,还能通过物联网传到大屏,可以实时的看到老人所在的位置,方便定位;兼具实时天气状况,实时掌握天气情况。该模型 “为老人提供定位守护、经纬度实时显示及物联网数据可视化” 的核心功能,名字为星途安行 ,寓意:“星” 呼应 GNSS 定位的 “卫星导航” 属性,象征精准指引;“途安行” 取 “旅途安全、出行无忧” 之意,突出对老人的守护;英文 “StarTrack” 直指定位轨迹追踪,“Guardian” 强化守护者形象,整体名称科技感与安全感兼具。

 

二、项目展示

 

gnss.gif
wechat_2025-06-30_155023_587.png
图片风格调整.png
wechat_2025-07-01_095910_652.png

 

材料清单

  • 行空板M10 X1 链接
  • 行空板M10扩展板组合 X1 链接
  • GNSS北斗定位模块 X1 链接
  • 两头PH2.0-4P白色硅胶绞线 X1 链接

步骤1 制作外壳

wechat_2025-06-30_172029_650.png

步骤2 组装模型

微信图片_2025-06-30_172340_752.jpg
微信图片_2025-06-30_172336_255.jpg
微信图片_2025-06-30_172330_424.jpg

步骤3 新建主题(Topic)

wechat_2025-06-30_174515_133.png

步骤4 添加用户库

非常感谢豆爸写的用户库和耐心指导,还有A-DF蘑菇云技术支持的指导。

wechat_2025-07-01_073755_458.png

步骤5 编程

screenshots-星途安行.mp-1751275488596.png

代码
#  -*- coding: UTF-8 -*-

# MindPlus
# Python
import siot
import time
from unihiker import GUI
from pinpong.board import Board
from tianqiapi_hourlyweather import TianqiApiHourlyWeather
import sys
sys.path.append("/root/mindplus/.lib/thirdExtension/liliang-gravitygnss-thirdex")
from DFRobot_GNSS import *


Board().begin()
siot.init(client_id="24838997243191252",server="192.168.1.5",port=1883,user="siot",password="dfrobot")
u_gui=GUI()
siot.connect()
siot.loop()
gnss = DFRobot_GNSS_I2C (bus=0, addr=0x20)
while (gnss.begin() == False):
    print("Sensor initialize failed!!")
    time.sleep(1)
gnss.enable_power()
gnss.set_gnss(GPS_BeiDou_GLONASS)
gnss.rgb_on()
gnss_utc = struct_utc_tim()
gnss_lat_lon = struct_lat_lon()

weather = TianqiApiHourlyWeather("37424891", "wWa1vdml","临沂")
u_gui.draw_text(text="天 气 实 况",x=50,y=0,font_size=20, color="#000000")
u_gui.draw_line(x0=0,y0=40,x1=240,y1=40,width=1,color="#CC33CC")
u_gui.draw_text(text="临沂",x=5,y=40,font_size=20, color="#FF0000")
日期=u_gui.draw_text(text="",x=80,y=42,font_size=10, color="#0000FF")
星期=u_gui.draw_text(text="",x=180,y=42,font_size=10, color="#0000FF")
天气情况=u_gui.draw_text(text="",x=80,y=55,font_size=10, color="#0000FF")
u_gui.draw_text(text="温度",x=110,y=55,font_size=10, color="#0000FF")
u_gui.draw_text(text="湿度",x=180,y=55,font_size=10, color="#0000FF")
温度=u_gui.draw_text(text="",x=150,y=55,font_size=10, color="#000000")
湿度=u_gui.draw_text(text="",x=210,y=55,font_size=10, color="#000000")
u_gui.draw_line(x0=0,y0=80,x1=240,y1=80,width=1,color="#CC33CC")
u_gui.draw_text(text="最高温度",x=5,y=80,font_size=10, color="#0000FF")
u_gui.draw_text(text="最低温度",x=140,y=80,font_size=10, color="#0000FF")
最高温度=u_gui.draw_text(text="",x=80,y=80,font_size=10, color="#000000")
最低温度=u_gui.draw_text(text="",x=210,y=80,font_size=10, color="#000000")
u_gui.draw_text(text="风向",x=5,y=100,font_size=10, color="#0000FF")
u_gui.draw_text(text="风力",x=80,y=100,font_size=10, color="#0000FF")
风向=u_gui.draw_text(text="",x=40,y=100,font_size=10, color="#000000")
风力=u_gui.draw_text(text="",x=120,y=100,font_size=10, color="#000000")
u_gui.draw_text(text="气压",x=160,y=100,font_size=10, color="#0000FF")
气压=u_gui.draw_text(text="",x=200,y=100,font_size=10, color="#000000")
u_gui.draw_line(x0=0,y0=120,x1=240,y1=120,width=1,color="#CC33CC")
u_gui.draw_text(text="能见度",x=5,y=120,font_size=10, color="#0000FF")
能见度=u_gui.draw_text(text="",x=65,y=120,font_size=10, color="#000000")
u_gui.draw_text(text="紫外线指数",x=130,y=120,font_size=10, color="#0000FF")
紫外线指数=u_gui.draw_text(text="",x=210,y=120,font_size=10, color="#000000")
u_gui.draw_text(text="紫外线强度",x=5,y=140,font_size=10, color="#0000FF")
紫外线强度=u_gui.draw_text(text="",x=80,y=140,font_size=10, color="#000000")
u_gui.draw_text(text="空气质量等级",x=130,y=140,font_size=10, color="#0000FF")
空气质量等级=u_gui.draw_text(text="",x=220,y=140,font_size=10, color="#000000")
u_gui.draw_line(x0=0,y0=160,x1=240,y1=160,width=1,color="#CC33CC")
u_gui.draw_text(text="日出时间",x=5,y=160,font_size=10, color="#0000FF")
u_gui.draw_text(text="日落时间",x=130,y=160,font_size=10, color="#0000FF")
日出时间=u_gui.draw_text(text="",x=70,y=160,font_size=10, color="#000000")
日落时间=u_gui.draw_text(text="",x=190,y=160,font_size=10, color="#000000")
u_gui.draw_text(text="白天天气",x=5,y=180,font_size=10, color="#0000FF")
u_gui.draw_text(text="夜晚天气",x=130,y=180,font_size=10, color="#0000FF")
u_gui.draw_text(text="更新时间",x=5,y=200,font_size=10, color="#0000FF")
白天天气=u_gui.draw_text(text="",x=70,y=180,font_size=10, color="#000000")
夜晚天气=u_gui.draw_text(text="",x=190,y=180,font_size=10, color="#000000")
更新时间=u_gui.draw_text(text="",x=70,y=200,font_size=10, color="#000000")
u_gui.draw_line(x0=0,y0=220,x1=240,y1=220,width=1,color="#CC33CC")
u_gui.draw_text(text="空气质量提示",x=5,y=220,font_size=15, color="#FF0000")
空气质量提示=u_gui.draw_text(text="",x=5,y=250,font_size=10, color="#000000")
if weather.fetch_data():
    日期.config(text=weather.get_value("date"))
    星期.config(text=weather.get_value("week"))
    天气情况.config(text=weather.get_value("wea"))
    温度.config(text=weather.get_value("tem"))
    湿度.config(text=weather.get_value("humidity"))
    最高温度.config(text=weather.get_value("tem1"))
    最低温度.config(text=weather.get_value("tem2"))
    风向.config(text=weather.get_value("win"))
    风力.config(text=weather.get_value("win_speed"))
    气压.config(text=weather.get_value("pressure"))
    能见度.config(text=weather.get_value("visibility"))
    紫外线指数.config(text=weather.get_value("uvIndex"))
    紫外线强度.config(text=weather.get_value("uvDescription"))
    空气质量等级.config(text=weather.get_value("air_level"))
    日出时间.config(text=weather.get_value("sunrise"))
    日落时间.config(text=weather.get_value("sunset"))
    白天天气.config(text=weather.get_value("wea_day"))
    夜晚天气.config(text=weather.get_value("wea_night"))
    更新时间.config(text=(str(weather.get_value("date")) + str((str("  ") + str(weather.get_value("update_time"))))))
    空气质量提示.config(w=240)
    空气质量提示.config(text=weather.get_value("air_tips"))
u_gui.draw_line(x0=0,y0=300,x1=240,y1=300,width=1,color="#CC33CC")
u_gui.draw_text(text="经度",x=2,y=300,font_size=10, color="#0000FF")
经度方向=u_gui.draw_text(text="",x=30,y=300,font_size=10, color="#000000")
经度=u_gui.draw_text(text="",x=40,y=300,font_size=10, color="#000000")
u_gui.draw_text(text="纬度",x=120,y=300,font_size=10, color="#0000FF")
纬度方向=u_gui.draw_text(text="",x=150,y=300,font_size=10, color="#000000")
纬度=u_gui.draw_text(text="",x=160,y=300,font_size=10, color="#000000")
while True:
    time.sleep(1)
    gnss_utc = gnss.get_date()
    gnss_utc = gnss.get_utc()
    gnss_lat_lon = gnss.get_lat()
    gnss_lat_lon = gnss.get_lon()
    gnss_alt = gnss.get_alt()
    gnss_cog = gnss.get_cog()
    gnss_sog = gnss.get_sog()
    gnss_num = gnss.get_num_sta_used()
    gnss_star = gnss.get_gnss_mode()
    if ((int(float((str(gnss_num))))) > 3):
        经度.config(text=(str(gnss_lat_lon.lonitude_degree)))
        经度方向.config(text=(str(gnss_lat_lon.lon_direction)))
        纬度.config(text=(str(gnss_lat_lon.latitude_degree)))
        纬度方向.config(text=(str(gnss_lat_lon.lat_direction)))
    siot.publish_save(topic="siot/城市", data=weather.get_value("city"))
    siot.publish_save(topic="siot/天气", data=weather.get_value("wea"))
    siot.publish_save(topic="siot/温度", data=weather.get_value("tem"))
    siot.publish_save(topic="siot/湿度", data=weather.get_value("humidity"))
    siot.publish_save(topic="siot/风向", data=weather.get_value("win"))
    siot.publish_save(topic="siot/风力", data=weather.get_value("win_speed"))
    siot.publish_save(topic="siot/气压", data=weather.get_value("pressure"))
    siot.publish_save(topic="siot/能见度", data=weather.get_value("visibility"))
    siot.publish_save(topic="siot/紫外线指数", data=weather.get_value("uvIndex"))
    siot.publish_save(topic="siot/紫外线强度", data=weather.get_value("uvDescription"))
    siot.publish_save(topic="siot/空气质量等级", data=weather.get_value("air_level"))
    siot.publish_save(topic="siot/日出时间", data=weather.get_value("sunrise"))
    siot.publish_save(topic="siot/日落时间", data=weather.get_value("sunset"))
    siot.publish_save(topic="siot/白天天气", data=weather.get_value("wea_day"))
    siot.publish_save(topic="siot/夜晚天气", data=weather.get_value("wea_night"))
    siot.publish_save(topic="siot/空气质量提示", data=weather.get_value("air_tips"))
    siot.publish_save(topic="siot/经度", data=(str((str(gnss_lat_lon.lon_direction))) + str((str(gnss_lat_lon.lonitude_degree)))))
    siot.publish_save(topic="siot/纬度", data=(str((str(gnss_lat_lon.lat_direction))) + str((str(gnss_lat_lon.latitude_degree)))))
    siot.publish_save(topic="siot/地图", data=(str((str(gnss_lat_lon.lonitude_degree))) + str((str(",") + str((str(gnss_lat_lon.latitude_degree)))))))

三、项目总结

行空板M10电机IO扩展板与M10电池扩展板的组合是专为行空板(UNIHIKER)M10在机器人控制、物联网终端、移动创客项目开发中遇到的无法移动供电、接口受限、动态难控制等难题,提供了便携式开发解决方案,本模型就是在扩展板的基础上制作的。GNSS北斗定位模块效果很好,能很清晰的记录经纬度,并根据经纬度在可视化大屏显示出动态的运动轨迹,根据地图轨迹能准确的找到人所在的位置。

由于GNSS北斗定位模块最后组装测试阶段出了故障,所以上传的模型效果不太理想。

再次感谢豆爸A-DF蘑菇云技术支持和群友来日可期的技术指导。

四、附件代码

评论

user-avatar
  • feng0539

    feng05392025.07.01

    再次感谢豆爸、A-DF蘑菇云技术支持和群友来日可期的技术指导。

    0