Feb 22, 2016

ESP8266 Serial Wifi Module

Let's move on, from bluetooth to wifi.
In my previous posts I always use bluetooth to open the door, now ESP8266 will give a breakthrough.

ESP8266 pinout is shown below.

Wire them as the following:
RX to TX of your MCU or USB/serial of PC
VCC to 3.3V
Let GPIO 0 and GPIO 2 unconnected
Let RESET unconnected
CH_PD to VCC to enable the module
TX to RX of your MCU or serial/USB
There are many warnings on the web that the module is not 5V tolerant, so use only 3.3V MCU or USB/serial 3.3V.

Serial port speed is 9600 bps (you can try 115200 if it doesn't work).
The module use AT command for communication protocol and use [CR] and [LF] for line ending.
To check the speed use command AT+CIOBAUD?[CR][LF]. [CR][LF] equivalent to \r\n in C.
I use the module in AP (Access Point) mode, meaning other PC or mobile phone can connect to it directly without wifi switch/router. The command is AT+CWMODE=2[CR][LF]
Then to enable multiple connection AT+CIPMUX=1[CR][LF]
To check the IP address of AP, use command AT+CIFSR[CR][LF] (example
To enabel listener on port 23, AT+CIPSERVER=1,23[CR][LF]
In Android mobile phone open TCP/UDP terminal application or Hercules terminal on PC, and connect to the IP above, connect and send something. It will be received by the module.
To send text from the module use command AT+CIPSEND=0,8[CR][LF]
0 is the channel and 8 is the length of the characters.
Then send 8 characters.

That's it. TCP and UDP difference in connection-oriented and connection-less
For detail sending and receiving format refer to the ESP8266 manual.

I wish I have time to create an Android Apps which can connect to a certain wifi AP programmatically and send password for open/lock something.

No comments:

Post a Comment

Samsung Smart TV Remote Control Receiver STM32F103C8T6

When you output your Samsung Smart TV audio to optical SPDIP, the volume control will not work because it wsork on fixed volume. So I build ...