当前位置:网站首页>Using ESP32 construct a ZIGBEE network adapter
Using ESP32 construct a ZIGBEE network adapter
2022-07-30 01:46:00 【ZhuoQing】

简 介: 利用 ESP32The networking,构建了一个 WiFi UDP 转 Zigbee的串口模块.The module is to just UDPInstructions sent toZigbee的网络中,Then replace the original function.注意,ESP32的网络地址为: 192.168.0.114.How can you get ESP32的IP地址呢? 可以介入 192.168.0.1 WiFi网关,在DHCPCheck the list of customers to the server Espressif的IP地址.
关键词:ESP32,Zigbee
§01ZIGBEE网关
一、背景介绍
在 The third hand in laboratory:Slide rail parameters and control interface Given the slippery course of laboratory platform control parameters.These platforms are by connecting in “COM2” 上的 zigbee Communication module connected.Because now used by platform to the serial port Settings have a problem,Therefore plans to useESP32作为网桥,作为UDP转成COMOf the conversion bridge,This enables the original laboratory equipment can continue to use.
二、制作模块
1、ESP32模块
ESP32模块使用了基于ESP32The intelligent car race referee system ,This is from the high dragon company production for sale. 可以通过其中的TXD2,RXD2完成向ZIGBEE 发送信息.

▲ , ESP32The referee in the system serial port2、ZIGBEE模块
下图给出了ZIGBEE的接口,Through the quad flat cables andESP32The system module.

▲ 图1.2.2 ZIGBEE接口与ESP32之间的接口三、软件编程
1、测试串口
参考在 The 17th intelligent car race game system software to modify-The time delay was more Blog forESP32Referee system software to modify the code,Write a serial port test software.代码如下:
from machine import Pin,UART
import time
import machine
machine.freq(240000000)
uart1 = UART(2, baudrate=115200, rx=16, tx=17, timeout=10)
bz1 = Pin(21, Pin.OUT)
bz1.off
while True:
uart1.write(bytes([0x55]))
time.sleep_ms(10)
测试 TX2 Pin waveform for:

▲ 图1.3.1 发送0x55数据TX波形2、发送ZIGBEE命令
将ESP32连接到 ZIGBEE模块.

▲ 图1.3.2 连接ZIGBEE模块Through the following programs,每隔 500ms 发送一个relay click 指令,经过验证,动作正常.Demonstrating the wholeZIGBEESending process is normal.
from machine import Pin,UART
import time
import machine
machine.freq(240000000)
uart1 = UART(2, baudrate=115200, rx=16, tx=17, timeout=10)
bz1 = Pin(21, Pin.OUT)
bz1.off
while True:
uart1.write(b'solenoidrelay pulse 4 50\r')
time.sleep_ms(500)
print("SEND.")
3、连接WiFi接口
根据 ESP32模块的MicroPython的基本实验 对于ESP32Connected to the general experiment,将ESP32Access to the lab WiFi 热点,并建立UDP接口连接.
如下是完整的 ESP32程序.使用 Thonny IDE 将 The following program written toESP32内部FLASH,并启动.
from machine import Pin,UART
import machine,time, network, usocket
machine.freq(240000000)
uart1 = UART(2, baudrate=115200, rx=16, tx=17, timeout=10)
bz1 = Pin(21, Pin.OUT)
bz1.off()
wlan = network.WLAN(network.STA_IF)
wlan.active(False)
wlan.active(True)
time.sleep_ms(100)
wlan.connect('TENDA626A', 'gniqouhz')
bz1.on()
while not wlan.isconnected():
time.sleep_ms(100)
wlan.ifconfig()
bz1.off()
us = usocket.socket(usocket.AF_INET, usocket.SOCK_DGRAM)
sockaddr = usocket.getaddrinfo('0.0.0.0', 4567)[0][-1]
us.bind(sockaddr)
while True:
data,addr = us.recvfrom(1024)
if len(data) > 0:
bz1.on()
uart1.write(data)
bz1.off()
经过测试,Send a command,Can cause the labZIGBEEThe relay action.
solenoidrelay pulse 4 50
This also verified thisWiFi 转 ZigbeeThe module function of normal.
※ 总 结 ※
利用 ESP32The networking,构建了一个 WiFi UDP 转 Zigbee的串口模块.The module is to just UDPInstructions sent toZigbee的网络中,Then replace the original function.
注意,ESP32的网络地址为: 192.168.0.114.
How can you get ESP32的IP地址呢? 可以介入 192.168.0.1 WiFi网关,在DHCPCheck the list of customers to the server Espressif的IP地址.

▲ 图2.1 ESPressif IP地址■ 相关文献链接:
- The third hand in laboratory:Slide rail parameters and control interface
- 基于ESP32The intelligent car race referee system
- The 17th intelligent car race game system software to modify-The time delay was more
- ESP32模块的MicroPython的基本实验
● 相关图表链接:
边栏推荐
猜你喜欢

【内部资源】冲击年薪30W+的软件测试人员,这份资料必须领取

LABVIEW详细介绍:LABVIEW是什么软件?都可以干什么?

sqlserver 多行合并成一行

Interviews with big factories under the trend of layoffs: "ByteDance"

fluttter学习之ButtonStyle 、MaterialStateProperty

【微服务~Nacos】Nacos之配置中心

jar包解压后再打包为jar

【LeetCode每日一题】——230.二叉搜索树中第K小的元素

经济衰退时期的对比:如今更像历史上的哪段时期?

SwiftUI SQLite数据库存储使用教程大合集(2022年版)
随机推荐
flutter学习之widget的显示和隐藏
LeetCode / Scala - 无重复字符最长子串 ,最长回文子串
十一、uni-app生成弹窗及换行
English语法_不定代词 -some & any
ufw 设置防火墙规则
【微服务~Nacos】Nacos服务提供者和服务消费者
05.script_setup中的私有属性
Graphical LeetCode - 593. Valid Squares (Difficulty: Moderate)
关于 SAP Fiori 应用的离线使用
Navicat error: 1045-Access denied for user [email protected](using passwordYES)
The role of diff and key
Running a Fabric Application
综合设计一个OPPO页面--返回顶部使用--使用链接的锚点a+id
nacos的共享配置和扩展配置
手把手教你实现一个流动的渐变色边框
记笔记!电源自动测试系统测试电源纹波详细方法
Towards Better Understanding of Self-Supervised Representations / Q-Score
基于蒙特卡诺的风场景模型出力(Matlab代码实现)
js中原型链的理解,原型链解决的是什么问题?
【C Primer Plus第九章课后编程题】