2024-4-18 17:53:46 [显示全部楼层]
99浏览
查看: 99|回复: 0

[ESP8266/ESP32] FireBeetle 2 ESP32 C6 用c6学会使用mind+可视化面板

[复制链接]
本帖最后由 Duyuxuan 于 2024-4-18 17:53 编辑

这是c6测评的第二篇,今天我要来教大家用micropython使用mind+可视化面板,学会使用物联网

准备环境

首先先去siot的github下载siot的micropython库
https://github.com/vvlink/SIoT/tree/master
然后去mind+官网下载siotv2的服务端,并升级mind+版本
https://mindplus.dfrobot.com.cn/dashboard

micropython代码编写

  1. 准备一个wifi热点
  2. 打开siot服务端
    FireBeetle 2 ESP32 C6 用c6学会使用mind+可视化面板图4
    具体siotv2使用方法可以看这里:https://mindplus.dfrobot.com.cn/dashboard
  3. 获取ip地址填入代码中
from machine import Pin
import time
import network
from siot import iot

ssid="wifi热点名称"
password="wifi密码"

#WiFi连接函数
def wifi_connect():
    wlan=network.WLAN(network.STA_IF)
    wlan.active(False)
    wlan.active(True)
    start_time=time.time()
    if not wlan.isconnected():
        print("connecting to network…")
        wlan.connect(ssid,password)
        while not wlan.isconnected():
            if time.time()-start_time>30:
                print("WiFi Connect TimeOut!")
                break
    if wlan.isconnected():
        print("network information:",wlan.ifconfig())

def sub_cb(topic, msg):# 回调函数
   print(topic,msg)

wifi_connect()
IOT_UserName = "siot" # 默认账号
IOT_PassWord = "dfrobot" # 默认密码
SERVER = ""  # SIoT服务器地址
CLIENT_ID = ""# 设置客户端ID   
siot = iot(CLIENT_ID, SERVER,user=IOT_UserName, password=IOT_PassWord)
siot.connect()
print('siot connected')  
siot.set_callback(sub_cb)
siot.getsubscribe("siot/button")  # 订阅主题
siot.loop()
while True:
    siot.check_msg()
    for i in range(10):
        siot.publish("siot/number",str(i*i))
        time.sleep(0.5)
    time.sleep(2)

编辑可视化面板与siot的topic

创建siot的topic

FireBeetle 2 ESP32 C6 用c6学会使用mind+可视化面板图1

编辑可视化面板

具体教程看这里:https://mindplus.dfrobot.com.cn/dashboard
FireBeetle 2 ESP32 C6 用c6学会使用mind+可视化面板图3

运行试试吧

FireBeetle 2 ESP32 C6 用c6学会使用mind+可视化面板图2



PixPin_2024-03-24_17-02-56.gif
PixPin_2024-03-24_17-02-56.gif
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail