Get Started With ESP8266 Using "AT Commands" Via Arduino

Introduction: Get Started With ESP8266 Using "AT Commands" Via Arduino

ESP8266 Wifi Module is an integrated chip designed for communicating to the world of the internet through Wifi radio signals. It is the link between a project and the internet. It has on-board processing and memory that allows it to be integrated with electronics through its GPIOs. The ESP8266 can be used to connect your Arduino projects to the internet.

In this instructable, you will get started with the basics of ESP8266 and how to program it using an AT commands.

Step 1: Parts

These parts are needed to program your ESP8266:

1 - ESP8266

2 - Arduino Uno

3 - Resistor 330 Ω

4 - Resistor 180 Ω

5 - Jumper Wires

6 - Mini Breadboard

Step 2: Connecting the ESP8266

One of the ways to programming the ESP8266 is throughout the Arduino micro-controller board. The ESP8266 is programmed using AT commands; when received, it replies with an acknowledgment. The ESP8266 is powered up using a 3.3 Volts power source, An Arduino Uno will be able to power up the ESP through its regulated 3.3 V power pin.

The ESP8266 is connected to the Arduino through TXD, RXD, GND, and the VCC pins to the RX, TX, GND and 3.3 V pins, respectively (If you are using an Arduino MEGA). The TX received from the Arduino should be connected to a voltage divider so that RXD of the ESP8266 receives a signal of 3.3 volts logic and not 5 volts. If the signal is received in 5 volts, the ESP8266 will malfunction. The voltage divider will be explained in the next step.

If you are using an Arduino Uno, then follow the steps:

Arduino --------------------------------------------------- ESP8266

Pin 10 (Software RX) -----------------------------------> TXD

Pin 11 (Software TX) -------> Voltage Divider -----> RXD

GND --------------------------------------------------------> GND

3.3 V --------------------------------------------------------> VCC

3.3 V --------------------------------------------------------> CH_PD

Step 3: The Voltage Divider

The voltage divider is used to produce an output voltage that is a fraction of the input voltage. We will use the voltage divider between the TX of the Arduino and RXD of the ESP8266 to produce an output voltage of 3.3 V.

I have used a 180 Ω resistor and a 330 Ω resister, as R1 and R2, respectively.

Use this website if you have different resistor values.

Step 4: Programming

After the connection of the pins mentioned above, the following code is uploaded to the Arduino to enable serial communication between the serial monitor and the ESP8266 through the Arduino. When a command is entered into the serial monitor on the computer the Arduino will relay it to the ESP8266. Download the Arduino code attached and upload it to the Arduino Uno board.

Step 5: AT Commands

There are many AT commands that can be used to program the ESP8266 Wifi module. Check them out here. The following AT commands should be written in the Arduino’s serial monitor (in order) to program the ESP8266:

  1. “AT” This will check if the module is connected properly and its functioning, the module will reply with an acknowledgment.
  2. “AT+RST” This will reset the wifi module. Its good practice to reset it before or after it has been programmed.
  3. “AT+GMR” This will mention the firmware version installed on the ESP8266. (Optional)
  4. “AT+CWLAP” This will detect the Access points and their signal strengths available in the area.
  5. AT+CWJAP=”SSID”,”PASSWORD” This connects the ESP8266 to the specified SSID in the AT command mentioned in the previous code.
  6. “AT+CIFSR” This will display the ESP8266’s obtained IP address.
  7. If the user wants to disconnect from any access point then use the following AT command AT+CWJAP=””,””
  8. “AT+CWMODE=1” This sets the Wifi mode. It should be always set to Mode 1 if the module is going to be used as a node (Like our mobile’s connection to the access points)
  9. After this step is done, repeat step 2 to reset the Wifi Module. “AT+RST”

Now you can connect your ESP8266 to the internet and get started with IoT.

2 People Made This Project!

Recommendations

  • Puzzles Speed Challenge

    Puzzles Speed Challenge
  • "Can't Touch This" Family Contest

    "Can't Touch This" Family Contest
  • CNC Contest 2020

    CNC Contest 2020

33 Discussions

0
baraka608
baraka608

2 months ago

am looking for someone to help me build a code that i can send sensor data to xampp's mysql from arduino with esp8266-01

0
Aravindh2
Aravindh2

Tip 6 months ago

You can make it work in this way [I have done this many times]

1) Program a blank code to the arduino
2) You make connections as told in this article EXCEPT for RX and TX pins.
connect RX to RX and TX to TX instead
3) Reset the arduino , and et the Seriall Monitor in the bottom on NL and CR and baudrate to 115200.
4) Type AT in the terminal and send ...if you get reply OK , it works and now try other AT commands

Regards

0
Nikhild50
Nikhild50

Question 10 months ago

Friends I have some doubts with this. I use 3dr radio module for my Copter. The air module has serial port connected in Pixhawk flight controller and ground module has usb port connected in my Windows 10. I tried to connect them using mission planner. Both were loaded settings in the MP but not connected each other. I accidently clicked update firmware. After that the air module is not connecting with mission planner. Receiver side went cannot access. I dont know why. May be the ground module were only updated. I dont have a ftdi or any usb to UART converter. So I searched for the solution and I got arduino can be used as usb to serial converter. I connected the air module to Arduino UNO as mentioned below
Module 5v to arduino 5v
Module GND to Arduino GND
Module Tx to Arduino Tx
Module Rx to Arduino Rx
and Reset and GND in arduino are connected.
The program used is
voil setup()
{
pinMode(0,INPUT);
pinMode(1,OUTPUT)
}
void loop()
{

}
First time the program didnt upload because I connected the whole setup in Arduino board. I removed all the jumpers and air module from the arduino. Then the program uploaded. May be this is because while connecting to Rx and Tx the program may not upload. After uploading the program I reconnected the 3dr air module. I tested AT command as shown in the internet. Also my ground module is not connected in laptop. But the AT command is going blank when clicking ENTER. The arduino is detected in the Port(in my computer COM8). I opened the Mission planner and selected 'SiK Radio' option from 'Optional Hardware' from 'Initial Setup'. Selected COM8 port and tried to 'Load Settings'. But It is showing 'Failed to enter command mode'. Same tried in SiK radio Config software but same problem. Please any one tell me how to connect the airmodule in Mission planner or SiK radio Config using arduino as usb to serial. So I can upgrade the version to match the ground module.

0
biasedturkey64
biasedturkey64

1 year ago

Thank you for that tutorial , that's exactly what I'm looking for.

0
Tech10007
Tech10007

1 year ago

This tutorial is very clear and to-the-point, so big kudos for that.

The chip I am using I am trying to program for someone else and I think it is already flashed with different firmware as it does not respond to any AT commands, and prints a list of the current found wifi networks. I don't expect you to be able to help me with that, but it also displays random characters instead of what is clearly meant to be plain text output.

A thread on the ESP8266 forum [https://www.esp8266.com/viewtopic.php?t=7625&start=4] says this is due to the difference in baud rates thus (I presume) the ESP8266's buffer is filling too fast without the Arduino's built-in serial printing it in time, does anyone know how I might resolve this?

0
SakshiH
SakshiH

2 years ago

ESP8266 is not receiving any AT command even after following every stage. What can be the reason?? Please help me out

0
satya_036
satya_036

2 years ago

connected as per the circuit but no response from the esp8266 , but esp8266 is receiving data because of the blue light blinking when AT command enter no response to serial monitor plz anyone help me

2
Juanca077
Juanca077

2 years ago

For those guys who have been trying to use AT commands this way and didn´t functioned for you; the most probably is that you are using an old arduino IDE. Upgrade to a new version. I had problems while sending AT commands through the serial monitor, it was giving me info, but weird characters instead of the "ok" response. Now it´s working properly! :) Thanks also to the autor of this post n.n You helped me a lot with this tutorial.

0
RandyH80
RandyH80

2 years ago

The lack of a graphic connection diagram for this project was a major ommission

0
RandyH80
RandyH80

2 years ago

I would recommend a 150 ohm resistor instead of 180 ohms because the ESP8266 is ok up to 3.6v and your 180ohm resistor drops the voltage to 3.245v which could result in the ESP8266 being under powered and thus not responding properly. Even with a 10% margin of resistor error you're still well within tolerances

0
RolliA
RolliA

2 years ago

Hi Guys, I have hat the same problem to connect and response.

Try to set the seriall monitor to NL and CR. Also i have connectet the RX from Arduino to TX of ESP directly and the TX fro Arduino to RX of RSP over an electronic level converter. Also set the Seriall Monitor in the bottom on NL and CR and the Baudrate to 9600.

0
Ahmer07
Ahmer07

2 years ago

I have tried as described above but I ain't getting any response from ESP8266-01 on sending AT commands. What could be the problem?

0
AliA430
AliA430

Reply 2 years ago

have you tried uploading any other code to the esp before following this guide?

esp8266-01 doesn't respond upon sending " AT " if the esp doesn't have the AT firmware in it , there are many tutorials on how to upload the AT firmware to esp follow those then try sending " AT " hopefully you will receive response from esp then

0
digitalmeth
digitalmeth

3 years ago

Guys I need some help. I follow all the steps with the connections, voltage divisor and everything, but when I type "AT" in the console I get an upside-down question mark. The question mark is not even from the module, because if I disconnect the RX and TX I still get the mark.

What happens with the GPIO0 pin, does it have to be connected (GND is to program the module)?

Previously I programmed the module with a code to blink the on-board diode and it worket perfectly, did it lost the ability to communicate with AT commands? (even though I dont think the problem is in the module).

Please help me, I am grateful in advance!

0
digitalmeth
digitalmeth

Reply 3 years ago

And one note, arent the 0 and 1 pins on Arduino UNO R3 the RX and TX pins?

0
digitalmeth
digitalmeth

Reply 3 years ago

Also, I have the GPIO15 and GPIO2 pins connected to GND.

0
KashifM8
KashifM8

4 years ago

warning: espcomm_sync failed

error: espcomm_open failed

error: espcomm_upload_mem failed

when i upload code then it gives this error???????

0
a1m918
a1m918

Reply 3 years ago

PRESS the RESET button just before the IDE says "UPLOADING" while hold down the FLSH button. See the image attached.

I am guessing that you are using Arduino IDE version 1.6.10. Try using version 1.6.9.

FG3XRLKIKMVAJKI.LARGE.jpg
0
FABLAB Dhahran
FABLAB Dhahran

Reply 4 years ago

Hey KashifM8,

Make sure that you have selected Arduino UNO under Tools --> Board.

I haven't faced this problem before! If you figured out a solution then please share it with us.

Good luck :)

0
RomaR6
RomaR6

Reply 4 years ago

can you help me please?

i do all this step and connected it to the router but now i need to controll on led with esp8266 (turn on and turn off) from computer wifi ?

what i need to do that?

help me if you can please.