# Myweather **Repository Path**: liliang9693/myweather ## Basic Information - **Project Name**: Myweather - **Description**: 物联网服务器,整理自:https://gitee.com/xiezuoru/xzrbook - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-06-25 - **Last Updated**: 2026-02-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 物联网服务器 本文档引用自 [谢作如老师gitee](https://gitee.com/xiezuoru/xzrbook/tree/master/%E6%99%AE%E9%80%9A%E9%AB%98%E4%B8%AD%E4%BF%A1%E6%81%AF%E6%8A%80%E6%9C%AF%E6%95%99%E6%9D%90%E9%85%8D%E5%A5%97%E8%B5%84%E6%BA%90/%E6%B5%99%E6%B1%9F%E6%95%99%E8%82%B2%E5%87%BA%E7%89%88%E7%A4%BE-%E5%BF%85%E4%BF%AE2/microbit%E7%89%88%E6%9C%AC),对文档进行整理说明 适用于普通高中信息技术教材配套资源/浙江教育出版社-必修2/microbit版本/第四章 # 逻辑图 开源硬件microbit读取传感器数据之后,通过obloq wifi物联网模块将数据传输到同在一个路由器局域网下 运行在一个电脑上的服务器Myweather上然后显示出来。。 ![image-20210625155552328](README.assets/image-20210625155552328.png) # 准备工具 - 软件 - BXY - python运行环境 - MyWeather - 硬件 - microbit - micro:mate扩展板 # 操作方法 ## 1.运行Myweather服务器 > Myweather采用Python代码编写,需要先安装Flask库 在当前目录下先运行: ```bash python setup.py ``` 然后运行: ```bash python webapp.py ``` 出现如下图网址即为开启成功,注意这个窗口需要保持打开状态 ![image-20210625171156045](README.assets/image-20210625171156045.png) 在浏览器输入以上操作出来的网址,即可打开数据显示页面: ![image-20210625171341504](README.assets/image-20210625171341504.png) ## 2.运行代码 BXY代码: ```py from microbit import * import Obloq IP="192.168.199.175" #修改为上一步Myweather所在的电脑ip PORT="8080" SSID="DFRobot" #wifi账号 PASSWORD="12345678" #wifi密码 uart.init(baudrate=9600, bits=8, parity=None, stop=1, tx=pin2, rx=pin1) #OBLOQ波特率9600,tx,rx接线 while Obloq.connectWifi(SSID,PASSWORD,10000) != True: display.show(".") display.scroll(Obloq.ifconfig()) Obloq.httpConfig(IP,PORT) #初始化 while True: errno,resp=Obloq.get("input?id=1&val="+str(temperature()),10000) #获取板载温度上传 if errno == 200: display.scroll(resp) else: display.scroll(str(errno)) errno,resp=Obloq.post("input?name=admin","{\"id\":\"1\",\"val\":\""+str(temperature())+"\"}",10000) if errno == 200: display.scroll(resp) else : display.scroll(str(errno)) sleep(1) ```