『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 131134|回复: 60

[进阶教程] 万能遥控器IR码转发到MQTT--固件

  [复制链接]

18

主题

267

帖子

2666

积分

论坛技术达人

积分
2666
金钱
2359
HASS币
190
发表于 2020-2-25 14:19:22 | 显示全部楼层 |阅读模式
本帖最后由 magic900321 于 2020-7-17 20:03 编辑

接上一个帖子
传送门:ESP8266获取小米万能遥控红外码,并MQTT转发到node-redhttps://bbs.hassbian.com/thread-9302-1-1.html
传送门:2020年7月更新的,三合一固件:https://bbs.hassbian.com/thread-10406-1-1.html

为了可移植,把这个开发成一个小小的固件,
现在朋友们可以通过COM口来配置WIFI 和MQTT了,感兴趣的朋友们可以试试。
作为一个业余的码农,第一次写了 这种超长的代码,希望没有Bug。
1.用云盘下载的工具,把固件上传到ESP8266,再打开COM口波特率115200,设置就好了。
2.连线按下图接,也可以把万能遥控器自带红外接收器的Out接到D4,但是NodeMcu有点大啊,得试下其它小一点的ESP8266了。(PS:如果急着试ESP01S,可以把WIFI及密码,还有MQTT的User和密码发给我,可以直接写进固件,把固件下载到ESP01S可以用了)

(抱歉,NodeMcu可以用,ESP8266-01S还 是不行,那个自带的文件系统SPIFFS读不成功,硬件问题)

屏幕捕获_2020_02_25_20_09_01_562.png
屏幕捕获_2020_02_25_13_56_17_290.png
附上node-red的Flow
[{"id":"29b9eb2a.aee554","type":"tab","label":"IRMQTT","disabled":false,"info":""},{"id":"187a4b87.a8bfe4","type":"mqtt in","z":"29b9eb2a.aee554","name":"小米遥控器ESP_IR_MQTT","topic":"IR_MQTT","qos":"2","datatype":"auto","broker":"9c9e7391.fe294","x":190,"y":260,"wires":[["64b99394.7b575c","3bb8881.8570478","509dba40.066934","950eef5b.5477b"]]},{"id":"64b99394.7b575c","type":"debug","z":"29b9eb2a.aee554","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":470,"y":220,"wires":[]},{"id":"3bb8881.8570478","type":"switch","z":"29b9eb2a.aee554","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"},{"t":"eq","v":"3","vt":"str"},{"t":"eq","v":"4","vt":"str"},{"t":"eq","v":"5","vt":"str"},{"t":"eq","v":"1FE48B7","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":450,"y":360,"wires":[["8c9aa303.5d5"],["482d0a15.2a2a24"],[],[],[],["f47293e9.e5f13"]]},{"id":"11b10820.3dffd8","type":"rpi-gpio out","z":"29b9eb2a.aee554","name":"test-RPI-GPIO21","pin":"40","set":true,"level":"0","freq":"","out":"out","x":870,"y":300,"wires":[]},{"id":"8c9aa303.5d5","type":"function","z":"29b9eb2a.aee554","name":"Toggle 0/1 on input","func":"\ncontext.state = context.state || 0;\n\n(context.state == 0) ? context.state = 1 : context.state = 0;\nmsg.payload = context.state;\n\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":300,"wires":[["11b10820.3dffd8"]]},{"id":"66c55622.cb4968","type":"rpi-gpio out","z":"29b9eb2a.aee554","name":"test-RPI-GPIO16","pin":"36","set":true,"level":"0","freq":"","out":"out","x":870,"y":420,"wires":[]},{"id":"f47293e9.e5f13","type":"function","z":"29b9eb2a.aee554","name":"Toggle 0/1 on input","func":"\ncontext.state = context.state || 0;\n\n(context.state == 0) ? context.state = 1 : context.state = 0;\nmsg.payload = context.state;\n\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":420,"wires":[["66c55622.cb4968"]]},{"id":"326c6f39.d5e7f","type":"rpi-gpio out","z":"29b9eb2a.aee554","name":"test-RPI-GPIO20","pin":"38","set":true,"level":"0","freq":"","out":"out","x":870,"y":360,"wires":[]},{"id":"482d0a15.2a2a24","type":"function","z":"29b9eb2a.aee554","name":"Toggle 0/1 on input","func":"\ncontext.state = context.state || 0;\n\n(context.state == 0) ? context.state = 1 : context.state = 0;\nmsg.payload = context.state;\n\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":360,"wires":[["326c6f39.d5e7f"]]},{"id":"2231ff3f.5ced6","type":"file in","z":"29b9eb2a.aee554","name":"","filename":"/home/pi/IRMQTT.log","format":"lines","chunk":false,"sendError":false,"encoding":"utf8","x":840,"y":240,"wires":[[]]},{"id":"5388c6e6.811618","type":"file","z":"29b9eb2a.aee554","name":"","filename":"/home/pi/IRMQTT.log","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"utf8","x":700,"y":160,"wires":[[]]},{"id":"509dba40.066934","type":"function","z":"29b9eb2a.aee554","name":"time to readable","func":"msg.payload=Date(msg.payload).toString();\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":100,"wires":[["18b1e651.9241da"]]},{"id":"950eef5b.5477b","type":"delay","z":"29b9eb2a.aee554","name":"","pauseType":"delay","timeout":"0.01","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":470,"y":160,"wires":[["5388c6e6.811618"]]},{"id":"18b1e651.9241da","type":"file","z":"29b9eb2a.aee554","name":"","filename":"/home/pi/IRMQTT.log","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"utf8","x":700,"y":100,"wires":[[]]},{"id":"9c9e7391.fe294","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]

游客,如果您要查看本帖隐藏内容请回复
















评分

参与人数 1金钱 +20 HASS币 +20 收起 理由
+ 20 + 20 厉害了word楼主!

查看全部评分

回复

使用道具 举报

0

主题

29

帖子

121

积分

注册会员

Rank: 2

积分
121
金钱
92
HASS币
0
发表于 2020-2-25 14:24:58 来自手机 | 显示全部楼层
l看看帖子
回复

使用道具 举报

3

主题

196

帖子

1135

积分

金牌会员

Rank: 6Rank: 6

积分
1135
金钱
939
HASS币
0
发表于 2020-2-25 16:07:34 | 显示全部楼层
看看先
回复

使用道具 举报

8

主题

382

帖子

1779

积分

金牌会员

Rank: 6Rank: 6

积分
1779
金钱
1397
HASS币
0
发表于 2020-2-25 16:38:44 | 显示全部楼层
来学习下,谢谢分享
回复

使用道具 举报

8

主题

382

帖子

1779

积分

金牌会员

Rank: 6Rank: 6

积分
1779
金钱
1397
HASS币
0
发表于 2020-2-25 17:50:28 | 显示全部楼层
请问esp-01接收管接第几脚呢?谢谢!!
回复

使用道具 举报

0

主题

204

帖子

1165

积分

金牌会员

Rank: 6Rank: 6

积分
1165
金钱
961
HASS币
0
发表于 2020-2-25 17:51:41 | 显示全部楼层
谢谢分享  
回复

使用道具 举报

1

主题

237

帖子

962

积分

论坛积极会员

积分
962
金钱
725
HASS币
0
发表于 2020-2-25 18:32:35 | 显示全部楼层
具体的看一看是什么,硬件家里有
回复

使用道具 举报

1

主题

18

帖子

155

积分

注册会员

Rank: 2

积分
155
金钱
137
HASS币
0
发表于 2020-2-25 18:38:39 | 显示全部楼层
都是高手
回复

使用道具 举报

18

主题

267

帖子

2666

积分

论坛技术达人

积分
2666
金钱
2359
HASS币
190
 楼主| 发表于 2020-2-25 18:51:35 | 显示全部楼层
peter5858 发表于 2020-2-25 17:50
请问esp-01接收管接第几脚呢?谢谢!!

ESP01还用不了,本来设计是GPIO2,但是ESP01S的内存太小,那个配置文件读写有错误,还得弄一下。
回复

使用道具 举报

8

主题

382

帖子

1779

积分

金牌会员

Rank: 6Rank: 6

积分
1779
金钱
1397
HASS币
0
发表于 2020-2-25 19:13:32 | 显示全部楼层
magic900321 发表于 2020-2-25 18:51
ESP01还用不了,本来设计是GPIO2,但是ESP01S的内存太小,那个配置文件读写有错误,还得弄一下。 ...

好的,谢谢回复,期待新成果
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-26 00:53 , Processed in 0.257591 second(s), 35 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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