使用AT命令在2个ESP8266 WiFi模块之间进行无路由器通信 [英] Communication between 2 ESP8266 WiFi modules without router using AT commands

查看:139
本文介绍了使用AT命令在2个ESP8266 WiFi模块之间进行无路由器通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试进行基于 TCP 的通信,以使用

I'm trying to make a TCP based communication to send a simple message "Hello" from one ESP8266 module to another using this document. I'm using 2 USB to TTL as hardware and Realterm as serial terminal. I could do it when ESP8266 modules are connected to a router, sending AT commands as below,

设置服务器:

AT+CWJAP="AccessPointName","Password"//Join to your WiFi network
AT+CIPMUX=1//0 for single connection 1 for multiple connection.
AT+CIPSERVER=1,1336//Set as Server. 1 to open Server mode(0 to close). 1336 is port.
AT+CIFSR//Get IP address (STAIP 192.168.43.151)

设置客户端:

AT+CWJAP="AccessPointName","Password"
AT+CIPMUX=1
AT+CIPSTART=1,"TCP","192.168.43.151",1336//Set up TCP or UDP connection, the 4 parameters are id, type, adress and port.     
AT+CIPSEND=1,7// Channel and number of bytes to send
//After issuing all previous command you will receive "OK". But afterAT+CIPSENDyou will receive a ">" as response.

Hello//send your Data

我想在没有路由器的情况下将两个 ESP8266 相互连接. 所以我用了这些AT命令:

I want to connect both ESP8266 to each other without a router. So I used these AT commands:

服务器命令:

AT+CIPMUX=1
AT+CWMODE=3//set the module as a client and also an access point.
AT+CIPSERVER=1,1336
AT+CIFSR //Getting 2 ip address (APIP 192.168.4.1 and STAIP 0.0.0.0).

客户端命令:

AT+CIPMUX=1
AT+CWMODE=3
AT+CWJAP="ESP1 SSID", "ESP1 PWD" //Connect to server
AT+CIPSTART=1,"TCP","0.0.0.0",1336 // I also tried APIP 192.168.4.1. 

但是,当我发送CIPSTART命令时,会收到ERROR消息. 怎么了我该怎么办?

But when I send CIPSTART command I get ERROR message. What's going wrong? What should I do?

推荐答案

在路由条目的上下文中,0.0.0.0表示默认路由.在服务器的上下文中,0.0.0.0表示本地计算机上的所有IPv4地址.如果主机有两个IP地址192.168.1.1和10.1.2.1,并且主机上运行的服务器侦听0.0.0.0,则在这两个IP上都可以访问它.这种通信方式也称为WiFi P2P或Wifi Direct.它应该与您的命令一起正常工作!如果问题仍然存在,请尝试使用其他模块.

In the context of a route entry, the 0.0.0.0 means the default route. In the context of servers, 0.0.0.0 means all IPv4 addresses on the local machine. If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs. This type of communication is also known as WiFi P2P or Wifi direct. It should work properly with your commands! If problem persists try with different modules.

这篇关于使用AT命令在2个ESP8266 WiFi模块之间进行无路由器通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆