ZlB0tWZMg设备接收到的数字命令消息

 

20.png

点赞  2020-6-17 20:40

21.gif

点赞  2020-6-17 20:43

11、使用Easy IoT平台远距离收集声光数据

 

#MicroPython动手做(31)——物联网之Easy IoT
#使用Easy IoT平台远距离收集声光数据

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

my_wifi = wifi()

my_wifi.connectWiFi("zh", "zy1567")

mqtt = MQTTClient("664fa81baa7fe777", "182.254.130.180", 1883, "qlZ0uezGR", "3_W0uezGgz", keepalive=30)

mqtt.set_last_will("TvkJXezMR", "I am offline")

try:
    mqtt.connect()
    print('Connected')
except:
    print('Disconnected')


oled.fill(0)
oled.DispChar("远距离收集声光数据", 10, 15, 1)
oled.show()
music.play('D5:1')
rgb.fill((int(0), int(102), int(0)))
rgb.write()
time.sleep_ms(1)
while True:
    rgb[1] = (int(255), int(0), int(0))
    rgb.write()
    time.sleep_ms(1)
    mqtt.publish("TvkJXezMR", (str(light.read())))
    mqtt.publish("ZlB0tWZMg", (str(sound.read())))
    time.sleep(1)
    rgb.fill( (0, 0, 0) )
    rgb.write()
    time.sleep_ms(1)

 

点赞  2020-6-19 13:11

收集到的声音数据

 

24.jpg

 

 

24-.jpg

点赞  2020-6-19 13:18

收集到的光线数据

 

25.jpg

26.jpg

点赞  2020-6-19 13:24

mPython X 实验图形编程

 

23-.jpg

点赞  2020-6-19 13:28

27.jpg

点赞  2020-6-19 13:32

12、移动端EasyIoT小程序

 

微信小程序搜索Easy IoT或打开微信扫描下方二维码,使用DFRobot用户中心账号登陆(手机号+验证码),进入“我的设备”页面。“我的设备”页面显示了在Easy IoT物联网网站中拥有的设备列表。可以看到设备中物联网数据的数据图表。

 

28.jpg

 

 

点赞  2020-6-19 14:22

移动端EasyIoT小程序

 

29.jpg

点赞  2020-6-19 14:45

移动端EasyIoT小程序

 

30.jpg

点赞  2020-6-19 14:49

#MicroPython动手做(31)——物联网之Easy IoT
#使用移动端EasyIoT小程序控制RGB灯

 

#MicroPython动手做(31)——物联网之Easy IoT
#使用移动端EasyIoT小程序控制RGB灯

from mpython import *
import network
from umqtt.simple import MQTTClient
import time
import music
from machine import Timer
import ubinascii

my_wifi = wifi()

my_wifi.connectWiFi("zh", "zy1567")

mqtt = MQTTClient("0805e3d04f3b34e7", "182.254.130.180", 1883, "qlZ0uezGR", "3_W0uezGgz", keepalive=30)

try:
    mqtt.connect()
    print('Connected')
except:
    print('Disconnected')

mqtt.set_last_will("TvkJXezMR", "Ready!")

def mqtt_topic_54766b4a58657a4d52(_msg):
    oled.DispChar((str(_msg)), 55, 24, 1)
    oled.show()
    if "on" == _msg:
        music.play('D5:1')
        rgb.fill((int(255), int(0), int(0)))
        rgb.write()
        time.sleep_ms(1)
        oled.DispChar("开灯", 52, 36, 1)
        oled.show()
    elif "off" == _msg:
        music.play('F5:1')
        rgb.fill( (0, 0, 0) )
        rgb.write()
        time.sleep_ms(1)
        oled.DispChar("关灯", 52, 36, 1)
        oled.show()

def mqtt_callback(topic, msg):
    try:
        topic = topic.decode('utf-8', 'ignore')
        _msg = msg.decode('utf-8', 'ignore')
        eval('mqtt_topic_' + bytes.decode(ubinascii.hexlify(topic)) + '("' + _msg + '")')
    except: print((topic, msg))

mqtt.set_callback(mqtt_callback)

mqtt.subscribe("TvkJXezMR")

def timer14_tick(_):
    mqtt.ping()

tim14 = Timer(14)
tim14.init(period=20000, mode=Timer.PERIODIC, callback=timer14_tick)


oled.invert(0)
oled.DispChar("移动版EasyIoT小程序", 5, 10, 1)
oled.show()
rgb[1] = (int(0), int(102), int(0))
rgb.write()
time.sleep_ms(1)
music.play('G5:1')
while True:
    mqtt.wait_msg()

 

点赞  2020-6-19 15:15

用移动端EasyIoT小程序发送指令

 

35 (1).jpg

 

34 (1).jpg

点赞  2020-6-19 15:41

mPython X 实验图形编程

 

36.jpg

点赞  2020-6-19 15:45

用移动端EasyIoT小程序发送指令

 

33.gif

点赞  2020-6-19 15:49
12
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复