三种智能灯和mqtt实验

三种智能灯和mqtt实验

光控灯

在mind+和掌控板上实现天黑自动亮灯,天亮灭灯。
当环境光照强度大于300灯灭,否则灯亮起白色。
光控灯

在这里插入图片描述

声控灯

在mind+和掌控板上实现声音强度到一定程度自动亮度,否则灭灯
当环境声音强度大于300亮起白色灯提示,否则保持熄灭状态。

声控灯
在这里插入图片描述

语音识别控制灯

在mind+和掌控板上实现语音控制灯的开关
需要用到wifi模块。当对掌控模块说“开灯”,灯亮起,说“关灯”则熄灭
在这里插入图片描述

语音识别控制灯

实现Easy IoT上mqtt消息的通讯

在mind+和掌控板上实现mind+下Easy IoT上mqtt消息的通讯
甲按A键(或触摸P)发送消息至topic1,同时监听topic0
乙监听topic1,接收到甲的消息后按A(或触摸P)回复消息给topic0甲显示
实现Easy IoT上mqtt消息的通讯

在这里插入代码片

// 主程序开始
void setup() {
mPython.begin();
myIot.setMqttCallback(msgHandles);
myIot.wifiConnect(“xiaomi”, “987654321”);
display.setCursorLine(1);
display.printLine(“正在连接网络”);
if (myIot.wifiStatus()) {
display.fillInLine(1, 0);
display.setCursorLine(1);
display.printLine(“连接成功”);
display.fillInLine(1, 0);
}
myIot.init(“iot.dfrobot.com.cn”,“Y9qNBjOMR”,"",“Yr3HfjOGRz”,topics,1883);
myIot.connect();
delay(5000);
if (myIot.connected()) {
display.setCursorLine(1);
display.printLine(“连接成功”);
delay(1000);
display.fillInLine(1, 0);
}
}
void loop() {
if ((buttonA.isPressed())) {
myIot.publish(topic_1, “hello”);
display.setCursorLine(2);
display.printLine(“发送成功”);
}
}

// 事件回调函数
void obloqMqttEventT0(String& message) {
display.setCursorLine(3);
display.printLine(message);
delay(2000);
}

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值