ESP8266 Wifi P2P with Arduino

I am fairly new to using the ESP8266 and trying to get two of them to connect directly via the wifi generated by the server. For now, I am using two Arduino Unos, one for each wifi module. I am sending the ESP8266 AT commands from the Serial Monitor. I have one ESP8266 dedicated to being a server and the other as a client. My goal is to send a simple message from the client to the server without connecting to any external wifi. Here is the series of AT commands I am using in the Arduino Serial Monitor.

Server code:

INPUT:  AT+CWSAP="ESP SSID","ESP PASSWORD",2,3
OUTPUT: OK
INPUT:  AT+CWMODE=3
OUTPUT: OK
INPUT:  AT+CIPMUX=1
OUTPUT: OK
INPUT:  AT+CIPSERVER=1,80
OUTPUT: no change 
        OK
INPUT:  AT+CIFSR
OUTPUT: +CIFSR:APIP,"192.168.4.1"
        +CIFSR:APMAC,"2e:3a:e8:20:f9:96"
        +CIFSR:STAIP,"0.0.0.0"
        +CIFSR:STAMAC,"2c:3a:e8:20:f9:96"

Client Code:

INPUT:  AT+CWMODE=3
OUTPUT: OK
INPUT:  AT+CJAP="ESP SSID","ESP PASSWORD"
OUTPUT: WIFI CONNECTED
        WIFI GOT IP
INPUT:  AT+CIPMUX=1
OUTPUT: OK
INPUT:  AT+CIPSTART=2,"TCP","192.168.4.1",80
OUTPUT: ERROR
        2,CLOSED

I cannot figure out why I am getting this error when trying to start a connection with the server. I am aware of the thread Communication between 2 ESP8266 WiFi modules without router using AT commands but none of these solutions have fixed this error.

I have also swapped the original ESP8266s with 2 new ones, which did not solve the problem. In addition, I have been able to communicate with these wifi modules using a smartphone with a TCP client app, so I don't think any of my hardware is broken. Thank you for any suggestions and help.

1 answer

  • answered 2018-01-31 17:38 gre_gor

    You are listening on port 80

    AT+CIPSERVER=1,80
    

    but connection to port 222

    AT+CIPSTART=2,"TCP","192.168.4.1",222
    

    Use the same port for both server and client.