受宠若惊
大半年前开源出来的zigbee网关硬件, 没有想到引起论坛大家各种玩耍. 也有好多人做了类似的, 功能更丰富的网关出来. 各种zigbee的“垃圾”都捡起来了, 欣喜若狂.
问题
但是之前的项目里面, esp的固件只是简单弄了一下, 很多功能都不完善. 无法修改wifi ssid, 没有web控制, 没有固件OTA, 没有zigbee固件OTA, 等等…
罗总@qlwz 出手相助, 做了一个超级棒的网关固件, 基本上完成了所有需要的功能, 而且也移植了ccloader的代码到esp8266上, 实现了几分钟更新zigbee固件.
为啥要再做一个
这个主要是为了后续系列产品的功能.
我希望可以借助一个成熟的, 发展活跃的开源esp系统架构, 最已经接入了很多的设备的系统.
所以esphome和Tasmota成为主要考虑的对象.
在这样的系统下, 下一代网关可以设计的扩展性更强一点, 让大家自由选择搭配, 网关不再是单独的网关的形态, 也许也是一个灯, 一个面板开关, 一个插线板…
当前实现功能
- 将原生的SoftwareSerialBridge,增加TCP透传功能。
- 增加ccloader刷zigbee固件功能。感谢罗总的移植。
- 增加littlefs保存zigbee固件和script的功能,方便刷机。
- 同时包含了zigbee协调器和zigbee路由器的固件,可以在web端更新刷机。
计划将实现的功能
- [ ] 兼容Tasmota2Zigbee和zigbee2mqtt
刷机流程
资料准备
固件烧写
- 通过USB type C线, 连接设备到电脑上.
- 打开刷机工具.
- 选择ESP固件为 tasmota.bin
- 选择Filesystem为spiffs.bin(其实它是littlefs)
- 根据自己情况, 选择是否勾选erase flash.
- 点击flash all
正确的刷机log如下
Flash File system to ESP first.
Using '/dev/cu.wchusbserial1410' as serial port.
Firmware start position: 1048576
Connecting....
Chip Info:
- Chip Family: ESP8266
- Chip Model: ESP8266EX
- Chip ID: 0070CCD2
- MAC Address: 84:F3:EB:70:CC:D2
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
- Flash Size: 2MB
- Flash Mode: qio
- Flash Frequency: 40MHz
Compressed 1024000 bytes to 219540...
Writing at 0x00100000... (7 %)
Writing at 0x00104000... (14 %)
Writing at 0x00108000... (21 %)
Writing at 0x0010c000... (28 %)
Writing at 0x00110000... (35 %)
Writing at 0x00114000... (42 %)
Writing at 0x00118000... (50 %)
Writing at 0x0011c000... (57 %)
Writing at 0x00120000... (64 %)
Writing at 0x00124000... (71 %)
Writing at 0x00128000... (78 %)
Writing at 0x0012c000... (85 %)
Writing at 0x00130000... (92 %)
Writing at 0x00134000... (100 %)
Wrote 1024000 bytes (219540 compressed) at 0x00100000 in 9.0 seconds (effective 910.2 kbit/s)...
Hash of data verified.
Leaving...
Hard Resetting...
Done! Flashing is complete!
Please press reset button. Wait 5 seconds.
0 ...
1 ...
2 ...
3 ...
4 ...
Flash ESP firmware to module.
Using '/dev/cu.wchusbserial1410' as serial port.
Firmware start position: 0
Connecting....
Chip Info:
- Chip Family: ESP8266
- Chip Model: ESP8266EX
- Chip ID: 0070CCD2
- MAC Address: 84:F3:EB:70:CC:D2
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
- Flash Size: 2MB
- Flash Mode: dout
- Flash Frequency: 40MHz
Compressed 523680 bytes to 368027...
Writing at 0x00000000... (4 %)
Writing at 0x00004000... (8 %)
Writing at 0x00008000... (13 %)
Writing at 0x0000c000... (17 %)
Writing at 0x00010000... (21 %)
Writing at 0x00014000... (26 %)
Writing at 0x00018000... (30 %)
Writing at 0x0001c000... (34 %)
Writing at 0x00020000... (39 %)
Writing at 0x00024000... (43 %)
Writing at 0x00028000... (47 %)
Writing at 0x0002c000... (52 %)
Writing at 0x00030000... (56 %)
Writing at 0x00034000... (60 %)
Writing at 0x00038000... (65 %)
Writing at 0x0003c000... (69 %)
Writing at 0x00040000... (73 %)
Writing at 0x00044000... (78 %)
Writing at 0x00048000... (82 %)
Writing at 0x0004c000... (86 %)
Writing at 0x00050000... (91 %)
Writing at 0x00054000... (95 %)
Writing at 0x00058000... (100 %)
Wrote 523680 bytes (368027 compressed) at 0x00000000 in 9.2 seconds (effective 454.7 kbit/s)...
Hash of data verified.
Leaving...
Hard Resetting...
Done! Flashing is complete!
Flash Done.
配网
- 刷机上电后, 通过手机或者PC链接z2mp开头的AP. 这是Tasmota固件创建的AP
- 网页会自动弹出配网界面, 点击 扫描无限网络, 选择并配置WiFi AP
-
强烈建议, 给设备设定一个能记得住的主机名, 如下图
- 保存配置. 等待网关重启.
- 连接刚刚配置的AP, 打开网页,输入刚刚设置的主机名的mdns地址, 比如 https://z2mp_tas.local. (第一次会比较慢, 多刷新几次, 大概1min能刷出来)
Zigbee固件烧写
在控制台界面,发命令切换Zigbee固件。
固件类型 | 刷机命令 |
---|---|
协调器固件 | CCloaderUpdate cc2530_c.bin |
路由器固件 | CCloaderUpdate cc2530_r.bin |
注意输入后, 点键盘回车开始刷机, 不是点网页上的 主菜单 按钮.
刷机大概需要2分钟,控制台输出日志大致如下
16:23:51 CMD: CCloaderUpdate cc2530_c.bin
16:23:51 SRC: WebConsole from 192.168.137.1
16:23:51 CMD: 组: 0, 索引: 1, 命令: "CCLOADERUPDATE", 数据: "cc2530_c.bin"
16:23:51 ZIG: Update cc253x fw cc2530_c.bin
16:23:51 ZIG: fw size 262144
16:23:51 ZIG: Block total: 512
16:23:51 ZIG: ChipID: 0xA5
16:23:51 ZIG: ChipID: Erase done
16:23:51 ZIG: Start uploader loop handler
16:23:51 RSL: RESULT = {"CCloaderUpdate":"Done"}
16:23:51 ZIG: Start upload blk 1/512
16:23:51 ZIG: upload blk 1/512 done
16:23:51 ZIG: Start upload blk 2/512
16:23:51 ZIG: upload blk 2/512 done
16:23:51 ZIG: Start upload blk 3/512
16:23:51 ZIG: upload blk 3/512 done
16:23:52 ZIG: Start upload blk 4/512
16:23:52 ZIG: upload blk 4/512 done
16:23:52 ZIG: Start upload blk 5/512
16:23:52 ZIG: upload blk 5/512 done
16:23:52 ZIG: Start upload blk 6/512
16:23:52 ZIG: upload blk 6/512 done
16:23:52 ZIG: Start upload blk 7/512
16:23:52 ZIG: upload blk 7/512 done
16:23:52 ZIG: Start upload blk 8/512
16:23:52 ZIG: upload blk 8/512 done
16:23:52 ZIG: Start upload blk 9/512
16:23:52 ZIG: upload blk 9/512 done
16:23:53 ZIG: Start upload blk 10/512
16:23:53 ZIG: upload blk 10/512 done
......
16:25:26 ZIG: Start upload blk 512/512
16:25:26 ZIG: upload blk 512/512 done
16:25:26 ZIG: Firmware update OK
TCP桥接端口
默认情况下,TCP桥接端口是8880。如果需要修改,请在控制台输入下面的命令:(假设修改到8888)
SSer2NetPort 8888
Tasmota使用教程
教程请在官网自行学习。