当前位置:网站首页>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的基本实验
● 相关图表链接:
边栏推荐
猜你喜欢

新型海上风电机组及压缩空气储能系统的建模与控制(Matlab代码实现)

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

OSPF shamlink 解决后门链路问题
![[VMWARE--Shared files]](/img/34/1f1609edc82c0a134886f9bf936f7f.png)
[VMWARE--Shared files]

LeetCode / Scala - 无重复字符最长子串 ,最长回文子串

Leetcode70. 爬楼梯

【LeetCode每日一题】——637.二叉树的层平均值

泰克Tektronix示波器软件TDS210|TDS220|TDS224上位机软件NS-Scope

Huawei's "genius boy" Zhihui Jun has made a new work, creating a "customized" smart keyboard from scratch

气路旋转连接器怎么用
随机推荐
API 接口批量测试
可惜了!规模这么大的上市公司说散就散了
Graphical LeetCode - 593. Valid Squares (Difficulty: Moderate)
短期风电预测(Matlab代码实现)
泰克Tektronix示波器软件TDS420|TDS430|TDS460上位机软件NS-Scope
OSPF shamlink 解决后门链路问题
JS开发3D建模软件
exness: U.S. GDP shrinks, yen bounces back
裁员趋势下的大厂面试:“字节跳动”
Fabric 编写案例 链码
基于蒙特卡诺的风场景模型出力(Matlab代码实现)
【C Primer Plus第九章课后编程题】
网络原理 基础知识
ufw 设置防火墙规则
初级测试人员如何快速成长
SSM整合案例
npm ERR! code ENOTSUP npm ERR! notsup Unsupported engine for [email protected]: wanted: {“n
go grpc 自定义拦截器
English语法_不定代词 -some & any
Interviews with big factories under the trend of layoffs: "ByteDance"