Introduction: Connecting ESP8266-01 to Arduino UNO/ MEGA and BLYNK

Picture of Connecting ESP8266-01 to Arduino UNO/ MEGA and BLYNK

This is a tutorial to show you how to flash a firmware to ESP8266-01 and connect to Blynk using an ESP8266 - 01 as an Arduino wifi shield.

Hardware needed:

*Arduino Uno/Mega

*Jumper wires

*USB A to USB B cable

*ESP8266-01

Software needed:

For easy access, move or download the following software to the desktop of your Linux. It can be moved later.

*Linux or Mac for flashing firmware.

*Arduino IDE link: https://www.arduino.cc/en/main/software

*Most recent BLYNK library link: https://github.com/blynkkk/blynk-library

*Blynk_v0.3.4.zip https://github.com/blynkkk/blynk-library/releases

*pySerial link: https://sourceforge.net/projects/pyserial/files/p...

*ESP8266 blynk library: https://github.com/vshymanskyy/ITEADLIB_Arduino_W...

*esptool link: https://github.com/themadinventor/esptool

*Sdk1.0.0 v0.22 ESP8266 firmware link:

http://esp8266.ru/download/esp8266-firmware/AT22S...

*Download esp8266_flasher [For Windows]

https://github.com/Stadslab/ESP8266_example/tree/m...

*Blynk app on iphone or android.

Step 1: Download These Files

Picture of Download These Files

*Download Arduino IDE

*Download most recent Blynk library

*Download the Blynk-ESP8266 library

Click the link provided, download and install the library.

*Download pySerial

Click the link provided in the intro and click what is in the red box. Make sure you move it to your desktop. Once it's there, double click the "pyserial-2.7.tar.gz" file and it will create a pyserial-2.7 folder.

*Download esptool

Click the link provided in the intro and click what is in the red box. Make sure you move it to your desktop.

*Download Sdk1.0.0 v0.22 ESP8266 firmware

This will download just by clicking the link in the intro page. Make sure you move it to your desktop. Open the "esptool-master" folder and move the "AT22SDK100-2015-03-20-boot12.bin" file into it. Then, rename it to "AT22SDK10020150320boot12.bin".

*Download esp8266_flasher [For Windows]

Download esp8266_flasher.exe

Step 2: Using Windows:

Picture of Using Windows:

*Connect your arduino to your computer using an USB 2.0 cable.

  • *ESP8266:____________ Arduino:
  • GND -------------------------- GND
  • GP2 -------------------------- Not connected
  • GP0 -------------------------- GND
  • RXD -------------------------- RX
  • TXD -------------------------- TX
  • CHPD ------------------------ 3.3V
  • RST -------------------------- Not connected
  • VCC -------------------------- 3.3V

*Open "esp8266_flasher.exe" and click on bin.

*Select the binary file "AT22SDK100-2015-03-20-boot12.bin".

*Enter proper COM port. In this case it is COM3

*Then click on download button,

*If your connections are proper the flashing will begin after erasing flash memory.

*After completion it shows "failed to leave flash mode this is OK.

Step 3: Using Linux: Changing the Directory

Picture of Using Linux: Changing the Directory

Open your Terminal (here we are using Kali linux), then type "cd". Next, drag the "pyserial-2.7" folder into the terminal window and hit enter.

Step 4: Installing PySerial

Picture of  Installing PySerial

Enter this command “python setup.py install" into the terminal

(If your terminal doesn’t have root/administrator/Superuser privilege access use "sudo python setup.py install" and enter password when asked.)

Step 5: Connecting Arduino and ESP8266-01

*Connect your arduino to your computer using an USB 2.0 cable.

*ESP8266:____________ Arduino:

GND -------------------------- GND

GP2 -------------------------- Not connected

GP0 -------------------------- GND

RXD -------------------------- RX

TXD -------------------------- TX

CHPD ------------------------ 3.3V

RST -------------------------- Not connected

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

Step 6: Flashing the Firmware to ESP8266-01

Picture of Flashing the Firmware to ESP8266-01

*Type "cd". Next, drag the "esptool-master" folder into the terminal window and hit enter.

* Esptool-master should contain following files

[ AT22SDK10020150320boot12.bin, esptool.py, LICENCE, MANIFEST.in, README.md, setup.py ]

*Enter this command

"sudo python esptool.py --port /dev/ttyACM0 write flash 0x00000 AT22SDK10020150320boot12.bin"

Note:The port address of your arduino may be different. You can use the command “ls /dev/tty*” to list all devices.

Step 7: Add the Blynk Library and the Blynk-ESP8266 Library to Your Arduino IDE.

*Arduino IDE >> Sketch >> Include library >> Add .zip library.

* And install "blynk-library-master" and "ITEADLIB_Arduino_WeeESP8266-master" libraries.

*Update the ESP8266 library from “Arduino IDE >> Sketch >> Include library >> manage library”.

Step 8: Uploading the Code to Arduino

Picture of Uploading the Code to Arduino
  • USING Arduino MEGA:

ESP8266:____________ Arduino:

GND -------------------------- GND

GP2 -------------------------- Not connected

GP0 -------------------------- Not connected

RXD -------------------------- TX

TXD -------------------------- RX

CHPD ------------------------ 3.3V

RST -------------------------- Not connected

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

We will be using a 1K POT connected to analog0 pin and an LED connected to D7 of arduino mega.


*Open Your “Blynk app” from android/iPhone get the “authentication token”.

  • Open the code in “Arduino IDE >> File >>examples >> blynk >> BoardsAndShields>> ESP8266_Shield_HardSer”
  • Add your authentication token to the code
  • Enter "SSID" and "PASSWORD" in respective fields.
  • Upload the code to your arduino.

Step 9: Connecting, Controlling and Monitoring Arduino Pins Using Blynk App

Picture of Connecting, Controlling and Monitoring Arduino Pins Using Blynk App

In the Serial monitor you can see that the connection has been established with blynk server.


Here’s the screenshot of the blynk app

Digital Pin 7 of Arduino mega --------->>controlled by blynk app.

Analog Pin 0 data from Pot -------- >> displayed on graph.

Step 10: USING ARDUINO UNO

Similarly you can also use arduino uno....

ESP8266:____________Arduino:

GND -------------------------- GND

GP2 -------------------------- Not connected

GP0 -------------------------- Not connected

RXD -------------------------- D3 (SoftwareSerial)

TXD -------------------------- D2 (SoftwareSerial)

CHPD ------------------------ 3.3V

RST -------------------------- Not connected

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

For Arduino UNO you can use “Arduino IDE >> File >> examples >> blynk >> BoardsAndShields>> ESP8266_Shield_SoftSer”

*The “Baud rate” of ESP8266 has to be changed to 9600 in Software Serial.

*AT command “AT+UART_DEF=9600,8,1,0,0”.

Comments

lollli (author)2017-10-21

AT+CIPSTART="TCP","blynk-cloud.com",8442

AT+CIPCLOSE

AT+CIPSTART="TCP","blynk-cloud.com",8442

AT+CIPCLOSE

AT+CIPSTART="TCP","blynk-cloud.com",8442

I get this recurring response in the serial window, please help! I am doing my final year mechatronics project and the due date is very near.

KTB4 made it! (author)2017-09-21

A.Help me, please.

EshakR (author)2017-09-21

while uploading library showinfg invalid library

EshakR (author)2017-09-21

Getting this error

GeeksTipsDotCom (author)2017-04-12

Great instruction, thanks! Also if you want to interconnect many devices using Blynk App read this Blynk Bridge Tutorial.

smitb3 (author)2017-04-03

I have connected all thing correctly but i m getting error
Connecting to esp
AT version 0.22.0/0
SDK version 1.0.0
co10
Failed to enable MUX
Failed to set STA mode
Can anyone help me

hemanth kumar reddy (author)2017-03-14

Can you plz look at this

https://www.instructables.com/community/security-s...

small help thanks

pratikjd made it! (author)2016-12-18

Hi my esp is getting connected to internet but when I play the project on Blynk app it says "Your arduino uno is not in network". Can some one help me out

Thanks in advance

YogeshC26 (author)2016-11-07

Thanks, I have successfully implemented this. It is working perfectly when I sending AT commands, and responding acccording to them.
But its not working when I am sending AT commands from code.
Please help me to get out of this.

alejandro.puglielli (author)2016-11-04

Hi , I just do all the steps and connect well to Blynk but only when the Mega is connected to my PC and the serial monitor is open , and dont connect to blynk when I use the external power supply on the Mega and the system is stand alone , can you help me to fix this ? Thank you .

GabrielC115 (author)2016-08-31

Download Sdk1.0.0 v0.22 ESP8266 firmware

This will download just by clicking the link in the intro page. Make sure you move it to your desktop. Open the "esptool-master" folder and move the "AT22SDK100-2015-03-20-boot12.bin" file into it. Then, rename it to "AT22SDK10020150320boot12.bin".

cannot find the filel

GabrielC115 (author)2016-08-31

nothing came out

GabrielC115 (author)2016-08-31

helpl, Click the link provided in the intro and click what is in the red box. Make sure you move it to your desktop. Once it's there, double click the "pyserial-2.7.tar.gz" file and it will create a pyserial-2.7 folder.

GabrielC115 (author)2016-08-31

some files do not exist

Nguyễn Thị ThuH (author)2016-03-12

I follow the step 2 but I can not upload AT22SDK100-2015-03-20-boot1.2.bin to the ESP8266. The message from the flashe downloader program is:

connecting ....

Erasing flash...

Invalid head of packet

Please help me to explain how to solve this problem

skg1 (author)Nguyễn Thị ThuH2016-06-25

first upload a blank sketch to your arduino and later flash your esp

nolmath (author)2016-06-10

Looks a lot like mine ;) Thank you for adding a Windows tutorial. Lots of people have been asking me for it and I haven't gotten the chance to do it yet

ThibautL2 (author)2016-04-07

Hi,

i've an error :
after be connected and ready my serial says : Login timeout
in the blynk apps : arduino uno was disconnected

someone have an idea ?

Amith MP (author)ThibautL22016-04-07

are you getting the connection status in serial monitor?
connected to SSID wifi...
.....
ready
Ping...?

ThibautL2 (author)Amith MP2016-04-07

it was exactly my problem! thanks you !

ThibautL2 (author)ThibautL22016-04-07

i found my error. my network doesn't allow this connection even if it said "connected to WiFi" i tried With an other network and it Works ! thanks for this tutorial !

Amith MP (author)ThibautL22016-04-07

can you try it on a local server

MarcinF (author)2016-04-04

New and working AT Firmware:

http://iot-playground.com/swdownload/ESPfirmware/v0.9.5.2%20AT%20Firmware.bin

diy_bloke (author)2016-03-03

why are you flashing the firmware? as far as i know if you just want to use it as a wifi shield the standard firmware suffices, at least id did when i used it. Or am i missing something? :-)

Amith MP (author)diy_bloke2016-03-03

I guess the standard firmware works(haven't tried though)... I had uploaded some lua code to ESP8266-01, it wasn't responding properly to AT commands... that is why I flashed a new firmware. :)

MarcinF (author)Amith MP2016-04-04

Lua scripts, thats NodeMCU firmware for esp8266 , it will not respond for AT commands because its using different commands

diy_bloke (author)Amith MP2016-03-04

ah ok, i get it

jamesbaker232 (author)2016-03-29

I'm having problems with the last step...

*The “Baud rate” of ESP8266 has to be changed to 9600 in Software Serial.

*AT command “AT+UART_DEF=9600,8,1,0,0”.

How are where do you enter the AT commands? I've tried in the serial monitor but nothing shows up. I have to be able to change the esp8266 baud rate while it's connected to the pc through the arduino uno as I currently have no way to directly connect it to my pc.

I'd like to help. Make sure you know the difference between the Baud rate that your Arduino uses and the Baud rate that the ESP module uses.. I used an UNO, and it's baud rate is 9600, so your serial monitor should be set up to that rate if using an UNO.

Now, after the "AT+UART_DEF=9600,8,1,0,0" command, you need to alter the sketch you have loaded into the arduino, specifically the part that tells the arduino at the speed you are trying to communicate at.. for me, I had to go from 115200, to 9600 after the command.. after that, all my commands come back free of garbage.

I hope this helps, I am a newbie to this and was stuck on something similar for quite a while!

Amith MP (author)jamesbaker2322016-03-29

*Upload a blank code(bare minimum) to arduino

For AT command mode connections between arduino and esp8266 are as follows-

TXD to TX

RXD to RX

Serial monitor in "NL and CR" mode.

Then type "AT" in serial monitor, it responds with an "OK".

if you get a garbage value change the baudrate and try again :)

jamesbaker232 (author)Amith MP2016-03-29

I've tried this, but still getting nothing to show up after typing AT commands.

Amith MP (author)jamesbaker2322016-03-29

flash the firmware ...

Even then if nothing shows up, assume

either connections are wrong or the ESP isn't working

jamesbaker232 (author)Amith MP2016-03-29

I've tried 2 different esp8266, after I flash them, does that set to 9600 baud rate?

Amith MP (author)jamesbaker2322016-03-29

it depends the firmware you flash... if you flash the firmware given in this instructables... baudrate will be at 115200..

JessicaP71 (author)2016-03-23

Hello, I can't compile the "ESP8266_Shield_SoftSer" this is the message error that I've been receiving:

Arduino:1.6.8 (Windows 10), Tarjeta:"Arduino/Genuino Uno"

Opciones de compilación cambiadas, reconstruyendo todo

sketch\ESP8266_Shield_SoftSer.ino.cpp.o: In function `__static_initialization_and_destruction_0':

C:\Users\Hector\Documents\Arduino\libraries\blynk-library-master\examples\BoardsAndShields\ESP8266_Shield_SoftSer/ESP8266_Shield_SoftSer.ino:40: undefined reference to `ESP8266::ESP8266(SoftwareSerial&)'

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compilación en tarjeta Arduino/Genuino Uno.

Is a library missing? I've downloaded all the libraries that you suggested. If you have any idea It would help me a lot.

Thanks. C:

JessicaP71 (author)Amith MP2016-03-24

Thanks!!

Now I'm playing with a led!!

shreyas7676 (author)2016-03-13

again error ?

[19] Blynk v0.3.3

[520] Connecting to PATIL

[1536] Failed to disable Echo

I use Arduino Mega 2560.

I do as follow and it done: I changed connection from TX1 and RX1 to RX0 and TX0 (TXD - RX0 and RXD - TX0) and change code from serial1 to serial, baudrate of esp to 9600.

if you are using Arduino mega
use serial1
RXD to TX1
TXD to RX1
Don't change baud rate after flashing....
hardware serial works fine at 115200

The same with me.

Amith MP (author)shreyas76762016-03-13

I guess connections aren't proper..... Or the baud rate.
If you are using UNO you should use software serial and initially change the baud rate of esp8266-01 to 9600 using AT commands

shreyas7676 (author)Amith MP2016-03-13

i use software serial program...
and connection is also proper...
esp8266 - arduino
RXD - PORT 2
TXD - PORT 3

Amith MP (author)shreyas76762016-03-13

It should be
Esp. arduino
RXD. tx (D pin 3)
TXD. rx(D pin 2)

shreyas7676 (author)Amith MP2016-03-14

bro connections proper kr bhi vhi error arha h? :(

[19] Blynk v0.3.3

[520] Connecting to PATIL

[1536] Failed to disable Echo

Amith MP (author)shreyas76762016-03-14

check
* if esp8266-01 has proper firmware
* if the ESP8266-01 is responding to AT commands. It(esp) should be at 9600 baud rate.
* esp. Arduino
RXD to software serial TX
TXD to software serial RX
* proper wifi with Ssid, password & Internet.

If everything is correctly done it will work!

Amith MP (author)2016-03-13

You cannot upload "AT22SDK100-2015-03-20-boot1.2.bin",...
You should rename the file as AT22SDK10020150320boot1.2.bin

Thanks

shreyas7676 (author)2016-03-13

help me pls? program error? what i do?

C:\Users\Shreyas\Documents\Arduino\libraries\blynk-library-master\examples\BoardsAndShields\ESP8266_Shield_HardSer\ESP8266_Shield_HardSer.ino:31:29: fatal error: ESP8266_HardSer.h: No such file or directory

#include <ESP8266_HardSer.h>

^

compilation terminated.

exit status 1

Error compiling.

Amith MP (author)shreyas76762016-03-13

You haven't installed proper libraries... Try to install blynk library from the given link. :)

About This Instructable

76,630views

295favorites

License:

Bio: An Electronics and communication engineer !!!
More by Amith MP:Home Automation Using Arduino With Wifi, Bluetooth and IR Remote ControlConnecting ESP8266-01 to Arduino UNO/ MEGA and BLYNK
Add instructable to: