Connecting ESP8266-01 to Arduino UNO/ MEGA and BLYNK

91,901

302

60

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

About: An Electronics and communication engineer !!!

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

*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:

*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

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

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

*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

  • 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

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”.

3 People Made This Project!

Recommendations

  • Metalworking Contest

    Metalworking Contest
  • Water Contest

    Water Contest
  • Tiny Home Contest

    Tiny Home Contest

60 Discussions

How to open this window

Step 3: Using Linux: Changing the Directory

plz help

0
None
KuanL3

3 months ago

help i cant write flsah it show this after i type command to write flash

esptool.py v2.3.2-dev

Connecting...

Traceback (most recent call last):

File "C:\Users\User\Desktop\esptool-master\esptool.py", line 2647, in <module>

_main()

File "C:\Users\User\Desktop\esptool-master\esptool.py", line 2640, in _main

main()

File "C:\Users\User\Desktop\esptool-master\esptool.py", line 2359, in main

esp = ESPLoader.detect_chip(args.port, initial_baud, args.before, args.trace)

File "C:\Users\User\Desktop\esptool-master\esptool.py", line 223, in detect_chip

detect_port.connect(connect_mode)

File "C:\Users\User\Desktop\esptool-master\esptool.py", line 417, in connect

last_error = self._connect_attempt(mode=mode, esp32r0_delay=False)

File "C:\Users\User\Desktop\esptool-master\esptool.py", line 376, in _connect_attempt

self._setRTS(True) # EN=LOW, chip in reset

File "C:\Users\User\Desktop\esptool-master\esptool.py", line 353, in _setRTS

self._port.setDTR(self._port.dtr)

AttributeError: 'Serial' object has no attribute 'dtr'

I am getting This error

I am working on arduino mega and esp8266-01

Screen Shot 2018-04-16 at 16.23.07.png

Hi there,
I hope that I get some reply

I'am facing the following error when using a mega board and ESP8266-01 wifi module

[592] Connecting to WiFiName

[1602] ESP is not responding

The board is responding to all the AT commands when uploaded with a blank sketch.but after uploading the code this error pops up

Any suggestions/ solutions will be of great help.

Thanks

1 reply

It means, esp is not responding. It was previoisly reporting "Failed to disable echo". Search for this error as well.
Make sure it ESP is getting current and TX Rx connections are fine.

0
None
lollli

9 months ago

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.

0
None
EshakR

10 months ago

while uploading library showinfg invalid library

w.png
0
None
EshakR

10 months ago

Getting this error

w.png
0
None
smitb3

1 year ago

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

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.

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 .

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

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.

some files do not exist

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

1 reply

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