MicroPython动手做(29)——物联网之SIoT-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

楼主: eagler8

MicroPython动手做(29)——物联网之SIoT

[复制链接]
 楼主| 发表于 2020-6-7 13:05 | 显示全部楼层
运行后出错,信息如下:

reader:  read tcp 192.168.31.248:1883->192.168.31.221:53734: wsarecv: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

读取器:读取tcp 192.168.31.24:1883->192.168.31.221:53734:wsarecv:连接尝试失败,因为一段时间后被连接方未正确响应,或者由于连接的主机未能响应而建立连接失败。
 楼主| 发表于 2020-6-7 13:11 | 显示全部楼层
在网页端,能查询到SIoT平台发出的消息,但无法控制板载LED灯

08.png
 楼主| 发表于 2020-6-10 18:22 | 显示全部楼层
本帖最后由 eagler8 于 2020-6-10 18:27 编辑

7、发布“hello”至主题“eagler8/zkb1”


[mw_shl_code=arduino,true]#MicroPython动手做(29)——物联网之SIoT
#发布“hello”至主题“eagler8/zkb1”

# MindPlus
# mpython
from umqtt.simple import MQTTClient
from mpython import *
import network
import music


brightness=9


my_wifi = wifi()
my_wifi.connectWiFi("zh","zy1567")
while not (my_wifi.sta.isconnected()):
  pass
oled.invert(0)
oled.DispChar("          Wifi连接成功", 0, (2-1)*16, 1)
mqtt = MQTTClient("", "192.168.31.248", 1883, "siot", "dfrobot")
try:
  mqtt.connect()
  print('Connected')
except:
  print('Disconnected')
rgb[1] = (0*brightness//9, 102*brightness//9, 0*brightness//9)
rgb.write()
music.pitch(392, 50)
mqtt.publish("eagler8/zkb1","hello")
oled.invert(0)
oled.DispChar("         SIoT连接成功", 0, (2-1)*16, 1)
oled.show()[/mw_shl_code]
 楼主| 发表于 2020-6-10 18:34 | 显示全部楼层
Mind+ 实验图形编程

09.png
 楼主| 发表于 2020-6-10 18:45 | 显示全部楼层
SIoT网页端收到的消息

10.jpg
 楼主| 发表于 2020-6-10 18:51 | 显示全部楼层
SIoT 初始化参数

11.png

12.jpg
 楼主| 发表于 2020-6-12 10:04 | 显示全部楼层
8、读取环境光强度发送至SIoT网页端


[mw_shl_code=arduino,true]#MicroPython动手做(29)——物联网之SIoT
#读取环境光强度发送至SIoT网页端

from umqtt.simple import MQTTClient
from mpython import *
import network
import music
import time


brightness=9

# 事件回调函数
def on_button_a_down(_):
  global g_my_variable
  time.sleep_ms(10)
  if button_a.value() == 1: return
  oled.DispChar("           采集光线值", 0, (3-1)*16, 1)
  oled.show()
  while True:
    mqtt.publish("eagler8/zkb1",(str(light.read())))
    time.sleep(2)


my_wifi = wifi()
button_a.irq(trigger=Pin.IRQ_FALLING, handler=on_button_a_down)
my_wifi.connectWiFi("zh","zy1567")
while not (my_wifi.sta.isconnected()):
  pass
mqtt = MQTTClient("", "192.168.31.248", 1883, "siot", "dfrobot")
try:
  mqtt.connect()
  print('Connected')
except:
  print('Disconnected')
rgb[1] = (0*brightness//9, 102*brightness//9, 0*brightness//9)
rgb.write()
music.pitch(392, 50)
mqtt.publish("eagler8/zkb1","hello")
oled.invert(0)
oled.DispChar("         SIoT连接成功", 0, (2-1)*16, 1)
oled.show()[/mw_shl_code]
 楼主| 发表于 2020-6-12 10:07 | 显示全部楼层
13-.jpg
 楼主| 发表于 2020-6-12 10:08 | 显示全部楼层
Mind+ 实验图形编程

12-.png
 楼主| 发表于 2020-6-12 10:15 | 显示全部楼层
SIoT网页端上读取到的光线值

13.png
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-12-27 10:33 , Processed in 0.079581 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表