ESP8266 — Arduino Connection and First Setup

Ali Camdal
6 min readApr 2, 2020

--

The ESP8266 is a low-cost WiFi microchip, with a full TCP/IP stack and microcontroller capability, produced by Espressif Systems. We can use ESP8266 in many projects for communication. It has 3 different using modes. In this article we will connect ESP8266 to Arduino Uno R3 and then we will setup our microchip with AT commands.

First of all I did use ESP8266 and Arduino UNO R3. ESP8266 can be used in 2 different styles. In the first option we can use it as a receiver or transmitter which is like we will do in this article. Second option is using ESP8266 as a microcontroller. We can use first option in several different projects.

Let's wire up our system.

Pinout of ESP8266

We will use just 5 of these 8 pins. RX and TX are our transmitter and receiver pins. We'll use them for serial communication. Last 3 pins are about power system of ESP8266 which are GND, VCC, and CH_PD (CH_EN). As we know that GND and VCC pins are ground and voltage pins. We will use CH_PD (CH_EN) pin for enabling our microchip. Also, we can understand the right direction of microchip by using golden line at the right side of it.

In the Fritzing scheme we can see wire connections of ESP8266. I should say that we can add a pull-down resistor for ESP8266’s GND pin. But it is not too important unless we wouldn't give it 5V. I did use Arduino's 0 and 1 digital pins. I used them because we will setup this microchip without any codes. Also, we can use other digital pins but I want to show this option in next article.

After this step we should open an empty Arduino sketch. We don't have to write any codes. Then we will upload our empty sketch to Arduino and open the Serial Monitor.

I have to say that there are some important details about setup. First of all, we have to use serial monitor at 115200 baud rate because this rate is default option for ESP8266. Secondly, in the line options we should use Both NL & CR. If we done these steps correctly, we are ready for start to setup.

AT Commands Table for ESP8266

In the table of AT Commands we can see some commands that we can use on ESP8266 setup. As first step of setup, we should type "AT" in the serial monitor screen. Then we should get "OK" response from this screen. If you get this, congrats you have an available ESP8266. If you don't get it, don't give up and leave comment about your trouble.

Then we will type "AT+GMR" command for reach our version information.

This SS shows what we can see when we type "AT".

In that SS we can see my device's information when I typed "AT+GMR".

In the screenshots that I gave above, we can see that we all work on 115200 baud rate. This baud rate too fast for us and we might want to change it to 9600 which is optimum baud rate that used by other components. For this change we will use "AT+UART_DEF" command which can be seen on table. But we will have some changes on this command. This command changes default UART configurations of our device. So, we should give some configuration parameters. "AT+UART_DEF=9600,8,1,0,0" we will use this command for change baud rate of ESP8266. If you want or you have to change baud rate to different than 9600 you can do it with changing this command. At the below I gave response of my screen.

When we change baud rate once, we have to change baud rate option of serial monitor.

I typed "AT" command again in 9600 baud rate and I got same response. This "OK" shows that I have no trouble right now. As I said before we can use ESP8266 with 3 different mode. Also, we will scan WiFi spots too. For these stuff we have to use some commands like we did before.

AT Commands for WiFi Configuration

The last step of ESP8266 setup is about WiFi connection. In the table we can see AT commands for WiFi configuration. Usage of ESP8266 we need to know these commands for WiFi communication. The first command "AT+RST" is resetting our device. It is not changing settings just reset the device. If you get errors when you are trying some codes, that is the command which you have to use. As I said above, we can use ESP8266 with 3 different modes. "AT+CWMODE" this command is allowing us to change our device's usage mode. This command takes 1 parameter which should be integer. "AT+CWMODE=mode" mode is representing the parameters and it looks like:
mode :
1- Station mode (client)
2- AP mode (host)
3- AP and Station mode

That means if we want to use ESP8266 as a client of our system, we should use "AT+CWMODE=1" command for it.

Third command is about WiFi spots. With this command we can scan WiFi spots which located nearby. "AT+CWLAP" can list all available WiFi spots for us.

AT+CWMODE — AT+CWLAP Commands

I did type these commands and I got responses which are I gave above. The next step of setup is joining a WiFi. I did set my device's mode as station mode then I listed all available WiFi spots. Now we will join a WiFi which we know password. For this step we will use "AT+CWJAP" command. But we know that for joining a WiFi we need SSID and Password. We can see all available SSIDs when we scan WiFi. Now we should change this command to "AT+CWJAP="YOUR_SSID_NAME","YOUR_PASSWORD"".

Response of AT+CWJAP Command

When I tried to connect my WiFi spot I got this response. This means you connect your device successfully. Last but not least, we can reach our device's IP address too. We will use "AT+CIFSR" command for find our IP.

We can use this IP for communicate to our device from another system. Also, this command returns us MAC Address of ESP8266.

Here is the end of ESP8266’s setup. If you done these steps correctly, you will not get any error. But I must say that most of the errors caused by wiring problems. Sometimes jumpers cannot connect completely and this situation triggering errors. I hope this article will help you with EPS8266.

I will touch another issue about ESP8266 in next article. Hopefully it will be ESP8266 connection with Python.

--

--