This is a tutorial to show you how to connect to Blynk using an ESP8266 - 01 as an Arduino Uno wifi shield. This tutorial is very detailed to help out those who are very new to this stuff.


Hardware needed:

Arduino Uno

Male to male jumper cables

Male to female jumper cables (if you don't have a breadboard adapter)

Solderless breadboard

USB 2.0 cable type A/B to connect the Arduino Uno to your Mac


Optional, but recommended:

Breadboard adapter (not required but it does make connecting the ESP8266 to the breadboard much easier

link to purchase: https://www.tindie.com/products/rajbex/esp8266-bre...



Software needed:

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

Arduino IDE

link: https://www.arduino.cc/en/main/software

Most recent Blynk library

link: https://github.com/blynkkk/blynk-library/releases


link: http://sourceforge.net/projects/pyserial/files/py...


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

Sdk1.0.0 v0.22 ESP8266 firmware

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

Blynk app on iphone or android

Step 1: Download Arduino IDE

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

Step 2: Download Most Recent Blynk Library

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

Step 3: 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.

Step 4: 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.

Step 5: 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.

Step 6: Prepare Esptool for Flashing

Open the "esptool-master" folder and move the "AT22SDK100-2015-03-20-boot1.2.bin" file into it. Then, rename it to "AT22SDK10020150320boot12.bin". This step is very important. If you don't rename the file, you will get an error later on.

Step 7: Installing PySerial

Step1: Open your Mac Terminal (you can find Terminal in a spotlight search), then type "cd". Next, drag the "pyserial-2.7" folder into the terminal window and hit enter. The window should look something like:

~ Home$ cd /Users/Home/Desktop/pyserial-2.7
:pyserial-2.7 Home$

Step 2: Copy this text, "sudo python setup.py install" into Terminal and hit enter. It will ask you for your password. The window should now look something like:

~ Home$ cd /Users/Home/Desktop/pyserial-2.7

:pyserial-2.7 Home$ sudo python setup.py install


/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'use_2to3'


running install

running build

running build_py

running build_scripts

running install_lib

running install_scripts

changing mode of /usr/local/bin/miniterm.py to 755

running install_egg_info

Removing /Library/Python/2.7/site-packages/pyserial-2.7-py2.7.egg-info

Writing /Library/Python/2.7/site-packages/pyserial-2.7-py2.7.egg-info

:pyserial-2.7 Home$

Congrats! You just installed pySerial!

Step 8: Add the Blynk Library to Your Arduino IDE

Step 1: Open the Arduino IDE (a blank sketch will open)

Step 2: Follow the steps in the first picture to get to "Add .zip Library..."

Step 3: Click "Add .zip Library...", then double click "Desktop" (assuming that is where you saved the Blynk Library), then double click "Blynk_v0". There will be a list of five files.

Step 4: Single click the first library ("Blynk") then click "Choose" to add it to your libraries. Repeat Step 3 until you have also added "BlynkESP8266_HardSer", "SimpleTimer", and "Time".

*You should then get the message shown in Picture 2 each time you add a library.

Step 9: Prepare the Code for the Arduino

Step 1: Open a new sketch

Step 2: Replace the existing code with the code below and save. DON'T upload it yet, though. Leave this window open. We will come back to it later.

//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space #include <ESP8266_HardSer.h>

#include <BlynkSimpleShieldEsp8266_HardSer.h>

// Set ESP8266 Serial object #define EspSerial Serial

ESP8266 wifi(EspSerial);

// You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "???";

void setup() { // Set console baud rate Serial.begin(9600); delay(10); // Set ESP8266 baud rate EspSerial.begin(115200); delay(10);

Blynk.begin(auth, wifi, "???", "???"); }

void loop() { Blynk.run(); }

Step 10: Wiring the Arduino and ESP8266

The above wiring scheme shows how to wire the Arduino and ESP8266. If you do not have a breadboard adapter, then you can use male to female jumper cables to connect to pinouts from the ESP8266 shown above.

**Make sure you power the ESP8266 with 3.3V. 5V kills it, be careful!



Overview of connections:

ESP8266:____________ Arduino:

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

GP2 -------------------------- Not connected (open)

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

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

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

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

RST -------------------------- Not connected (open)

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

Step 11: Connecting Your Arduino to Your Mac

Step 1: Connect your Arduino to your Mac using your USB 2.0 cable.

Step 2: Go to the tools tab, then go to port. Next, select your device address. It should be the bottom one. Your device address will be different.

Step 12: Flashing the ESP8266

Step 1: Upload a blank sketch to your Arduino.

Step 2: Open your Mac Terminal (you can find Terminal in a spotlight search), then type "cd". Next, drag the "esptool-master" folder into the terminal window and hit enter. The window should look something like:

~ Home$ cd /Users/Home/Desktop/esptool-master

:esptool-master Home$

Step 2: Copy this text, "sudo ./esptool.py --port /dev/tty.??? write_flash 0x00000 AT22SDK10020150320boot12.bin" into Terminal. Replace the ??? with your device address you found in the previous step. You only replace the ??? with the characters after "cu." and before (Arduino Uno). For example, mine is /dev/cu.usbmodemfd121 (Arduino Uno), so I replaced the ??? with "usbmodemfd121". Make sure the device address is copied exactly. When I first did this, I was off by one letter and it took me a while to figure it out. Now, hit enter. It will ask you for your password. The window should now look something like:

~ Home$ cd /Users/Home/Desktop/esptool-master

:esptool-master Home$ sudo ./esptool.py --port /dev/tty.usbmodemfd121 write_flash 0x00000
AT22SDK10020150320boot12.bin Password: Connecting... Erasing flash... Wrote 520192 bytes at 0x00000000 in 49.8 seconds (83.5 kbit/s)... Leaving... :esptool-master Home$

Step 13: Upload Your Code to the Arduino

Step 1: Disconnect the ESP8266 GP0 pin from ground.

Step 2: Open your Blynk app on your phone.

Step 3: First, create an account, create a new project, and hit the gear button. Next, press the auth (long array of characters) and email it to yourself. Go to the "char auth[ ] = "???";" line of your code. Replace the ??? with your new auth characters.

Step 4: Go to the "Blynk.begin(auth, wifi, "???", "???");" line of your code. Replace the first ??? with your wifi name. Replace the second ??? with your wifi password.

Step 5: Click the upload button.

Step 6: Disconnect and reverse the RX and TX Arduino pins (so that the RXD pin of the ESP8266 is connected to the TX pin of the Arduino and the TXD pin of the ESP8266 is connected to the RX pin of the Arduino).

Step 14: Check Your Connection

Step 1: Open the serial monitor.

Step 2: Change the baud rate to 115200 if it is not that already (at bottom right corner of the serial monitor, there is a drop down menu to change it). You should get something similar to the response below.

[520] Connecting to ____





[7611] IP: +CIFSR:STAIP,"___.___._.___"




[7633] Connected to WiFi




[1] ________ [12901] Ready (ping: 14ms).

Now, you can go back to the Blynk app, press the dotted background, add a button, and connect it to digital pin: D13. Then, press the play button.

The LED next to pin 13 on your Arduino should turn on when you press the button.

If it does, CONGRATS! You have now connected to Blynk and can create your own projects.

Happy Blynking!!

<p>If you have a question, feel free to post it here. I will try to answer it as soon as possible.</p>
<p>what problem in my serial monitor. (wifi name and pass is correct)</p><p>[19] Blynk v0.3.0</p><p>[20] Connecting to Rozelle Thai Cuisine</p><p>ATE0</p><p>AT+CWMODE?</p><p>AT+CWJAP=&quot;Rozelle Thai Cuisine&quot;,&quot;dekthai99087&quot;</p><p>[10067] Failed to connect WiFi</p><p>AT+CIPCLOSE</p><p>AT+CIPSTART=&quot;TCP&quot;,&quot;cloud.blynk.cc&quot;,8442</p><p>AT+CIPCLOSE</p><p>AT+CIPSTART=&quot;TCP&quot;,&quot;cloud.blynk.cc&quot;,8442</p><p>AT+CIPCLOSE</p><p>AT+CIPSTART=&quot;TCP&quot;,&quot;cloud.blynk.cc&quot;,8442</p><p>AT+CIPCLOSE</p><p>AT+CIPSTART=&quot;TCP&quot;,&quot;cloud.blynk.cc&quot;,8442</p><p>AT+CIPCLOSE</p>
This could mean that you need to register the MAC address of you esp8266 with your wifi provider (my apartment is like this) or that the wifi you're trying to connect to wont let you just input a password to connect with just a password (my schools wifi requires a browser to input a password so I get this error)
<p>how can i do that?</p>
It depends on your wifi provider. If you didn't have to do that for your other devices then that is not the problem. I sometimes get that the first few times I open the serial monitor. When I reopen it a few times, eventually it works
<p>Please help me with step 13, it says fatal error: failed to connect</p>
<p>cmd comand cd </p><p>Desktop</p><p>pyserial-2.7 sudo python setup.py install but run tha software plz help me </p>
<p>I drag the file to Terminal and it complains that no such file or directory can be found. How do I solve this? Thanks!</p>
If that doesn't work then you should type the path in manually
<p>Please help :'(</p><p>(step 12)</p><p>Password:</p><p>esptool.py v2.0-beta3</p><p>Connecting........_____....._____....._____....._____....._____....._____....._____....._____....._____....._____</p><p>A fatal error occurred: Failed to connect to Espressif device: Timed out waiting for packet header</p><p>Thisuns-MacBook-Pro:esptool-master thisunsudaraka$ </p>
update video<br>
<p>Hi, does blynk library works at more recent ESP8266-01 version? I got AT version: 29 2016 15:10:17) SDK version:1.5.2. Thanks</p>
I would suggest using the version I used. I'm not sure if the newer one works or not
<p>while trying step 12,.. i got this error .....</p><p>Subramanians-MacBook-Air:esptool-master skiyer$ sudo ./esptool.py --port /dev/tty.usbmodem1411 write_flash 0x00000 AT22SDK10020150320boot12.bin</p><p>esptool.py v1.2-dev</p><p>Connecting...</p><p>A fatal error occurred: Failed to connect to ESP8266</p><p>what should i do?</p>
<p>while trying step 12,.. i got this error .....</p><p>Subramanians-MacBook-Air:esptool-master skiyer$ sudo ./esptool.py --port /dev/tty.usbmodem1411 write_flash 0x00000 AT22SDK10020150320boot12.bin</p><p>esptool.py v1.2-dev</p><p>Connecting...</p><p>A fatal error occurred: Failed to connect to ESP8266</p><p>what should i do?</p>
<em>i'm getting this error how can i fix this</em><p> sudo ./esptool.py --port /dev/tty.usbserial-A50285BI write_flash 0x00000 AT22SDK10020150320boot12.bin</p><p>esptool.py v1.2-dev</p><p>Connecting...</p><p>A fatal error occurred: Failed to connect to ESP8266</p>
<p>I am using the correct serial port name ass shown in step 12. But still I'm getting an error of invalid syntax.</p>
That should have worked. Maybe try reinstalling esptool and pyserial
<p>Now, my ESP8266 gets enough electricity, but when I open my Blynk app, it tells me that my Arduino Mega is not in Network.</p><p>When I look at the Serial Monitor, everything is like step 14, instead of the last row, when <strong>AT+CIPSEND </strong><em><strong>=37 </strong>and when I should get the<strong> PING</strong></em></p><p><em>what my Serial Monitor says:</em></p><p>[19] Blynk v0.3.3<br>[520] Connecting to ___<br>ATE0<br>AT+CWMODE?<br>AT+CWJAP=&quot;___&quot;,&quot;___&quot;<br>AT+CIFSR<br>[3578] IP: +CIFSR:STAIP,&quot;___.___._.___&quot;<br>+CIFSR:STAMAC,&quot;--:--:--:--:--:--&quot;</p><div>OK<br>AT+CIPMUX=0<br>[3601] Connected to WiFi<br>AT+CIPCLOSE<br>AT+CIPSTART=&quot;TCP&quot;,&quot;cloud.blynk.cc&quot;,8442<br>AT+CIPCLOSE<br>AT+CIPSTART=&quot;TCP&quot;,&quot;cloud.blynk.cc&quot;,8442<br>AT+CIPCLOSE<br>AT+CIPSTART=&quot;TCP&quot;,&quot;cloud.blynk.cc&quot;,8442<br>AT+CIPCLOSE<br>AT+CIPSTART=&quot;TCP&quot;,&quot;cloud.blynk.cc&quot;,8442</div>
It looks like you are using an old library. The server should be cloud-blynk.com. The server you're trying to use is no longer supported
<p>I tryed every libary I found between v0.3.4 and v0.3.7 but they all deal with &quot;cloud.blynk.cc&quot;</p><p>And v0.3.4. is the only one wich has the &quot;ESP8266_HardSer.h&quot; Folder.</p><p>Could you give me a link for the right libary?</p>
This is the one I use https://github.com/blynkkk/blynk-library/releases/download/v0.3.4/Blynk_v0.3.4.zip. It should work. I suggest deleting all the other blank library versions as well
<p>Ok, my ArduinoIDE used an old library wich I installed weeks before I found this page in<em> _documents_...</em>, not in <em>_Programs..</em>, where my other librarys are... </p><p>Now, it works, but not reliable and stable. That means that I have to restart the Arduino a few times before the ESP8266 connects to the Internet. The times bevor, I get <strong>*Failed to connect WIFI*</strong> or <strong>*Failed to disable Echo*</strong>. </p><p>Could it be the ESP8266, if it is not booted already? But if I Interrupt the power supply of the arduino for a short moment and reconnect it, (ESP stays on), I've got the same Problem. :(</p><p>Or do you have another idea???</p><p><br></p><p>I hope to handle also <strong>this</strong> problem, but nonetheless I want to have a LED which lights, when the ESP is connectet to the Internet.</p><p>What do I have to write for *connectet* or *disconnected* ???</p><p>for example:</p><p>if(*connected*)</p><p>DigitalWrite(LED1,HIGH)</p><p>else</p><p>DigitalWrite(LED1,LOW)</p><p>Thank you for taking time :) </p>
It looks like you need a more stable power source. The 3.3V output sometimes can't handle the ESP's current draw. Try the 5V with a voltage regulator or voltage divider. As for the code to see if it is connected, I'm not sure. I know the code to light an led when it connects to blynk but not the Internet. It should be a quick Google search though. Or check the Blynk community for posts about it
thats what I ment. I want the LED to shine if the Arduino is connected to Blynk. How can I do this? Google wasn't helpful in this case :/<br>
if (Blynk.connected()) {<br>digitalWrite(LED1, HIGH);<br>}<br>else {<br>digitalWrite(LED1, LOW);<br>}<br>
<p>It works, thank you.</p><p><strong>Hopefully last question on this issue:</strong></p><p>It doesn't connect with the Internet when there is no connection between Laptop and Arduino! So if I power Arduino and ESP8266 with a battery, the blue LED of the ESP lights the whole time and the green LED (lights, if ESP is connected) stays off. Do I have to Change something with the Code if I want to run the construction Independent of a PC or similar?</p>
A battery most likely won't be able to handle the ESP's current draw. You need a solid connection. I use an Arduino power supply and it works
Please look through the comments. This has been addressed
<p>hey man nice make</p><p>i have a prob </p><p>whenever i copy the py serial folder into terminal and paste the sudo...... line and press enter it shows no such directory exists</p><p>Last login: Sat May 28 08:55:25 on console</p><p>Flying-Horse-2:~ demo$ cd</p><p>Flying-Horse-2:~ demo$ /Users/demo/Desktop/pyserial-2.7 </p><p>-bash: /Users/demo/Desktop/pyserial-2.7: is a directory</p><p>Flying-Horse-2:~ demo$ sudo python setup.py install</p><p>Password:</p><p>python: can't open file 'setup.py': [Errno 2] No such file or directory</p><p>Flying-Horse-2:~ demo$</p><p>what to do?</p>
Your first two commands should be a single command. It should look just like the example code I added on that step
<p>still no change</p><p>it shows no such directroy</p>
I'm sorry. There should be a space after cd. I will make the edit on the instructable
<p>coming to the flashing esp8266 it dint give me the result u got it terminal </p>
It should be &quot;.bin&quot; not &quot;.binr&quot;
<p>even with .bin </p><p>im not getting the same result as yours</p>
Actually, your problem is that you used dev/cu. take a look at step 2 under step 12. There should be a tty in there. The port name is also case sensitive
Ok, so did you go through and check the name of your port as it says in the tutorial? You are using the name of my port &quot;usbmodemFA131&quot; and it may not be the same
<p>This is a very interesting project but it's just kind of complicated to setup wifi shield for me. I've been searching for an Arduino compatible platform with built-in wifi for a long time and found this platform is quite interesting: http://www.amebaiot.com/. I'll try to get some and may be post some project based on this platform later.</p>
Hi guys,I try to do this at Win10 too...<br>but I have a Problem! When I try to verify the Sketch I get this error...<p><em>C:\Users\Marten\AppData\Local\Temp\arduino_modified_sketch_628403\sketch_may19a.ino:3:29: fatal error: ESP8266_HardSer.h: No such file or directory</em></p><p><em> #include &lt;ESP8266_HardSer.h&gt;</em></p><p><em> ^</em></p><p><em>compilation terminated.</em></p>I hope you can help me and it won't be that complicated to fix it.please excuse my bad englishand thanks for every answer, Marten
Go back to step 8 and make sure you added those blynk libraries. That should fix the problem
<p>I took 0.3.6. instead of 0.3.4.</p><p>that was my mistake! Thank you for your help!</p><p>Now, I was able to upload the Sketch, but there came another Problem :'-(</p><p>When I open the Serial Monitor, I get this ...</p><p><em>[19] Blynk v0.3.3<br>Failed to disable Echo<br>[19] Blynk v0.3.3<br>[520] Connecting to HunteLTE<br>ATE0<br>[1530] Failed to disable Echo<br>AT+CIPCLOSE<br>AT+CIPSTART=&quot;TCP&quot;,&quot;cloud.blynk.cc&quot;,8442</em></p><p><em><br></em></p><p>What's wrong this time ???</p>
<p>NEW INFORMATIONS:</p><p>I changed RX and TX and then it worked, but only about 2 minutes...</p><p>Then, I got the same error message. <strong>just WHY D-':</strong></p><strong>???any idea???</strong>
It looks like you need a more stable power source or one of your wires got disconnected. I would suggest using the 5V with a voltage regulator. That's what I use and it works great. You could also use a voltage divided. Just make sure you use the 5V. The 3.3V was just to get the initial connection
<p>It works great :) Nice tutorial. I made it work on windows 10 </p>
<p>I made it on windows and it works 100%, but I have one question, if I want to read from an analog pin and write to a virtual should I upload the script to the arduino with all the serial and Blynk.begin() declarations or just the variables that I'm going to use?</p>
Glad it worked! You need everything in the code I provided as well as any code you need for your project. I hope I understood your question correctly
<p>are you able to update this tutorial with the new information? like blynk libraries etc</p>
Yes, I've been meaning to do so but have been really busy with school

About This Instructable



Bio: Mechanical Engineering student at the University of Michigan
More by nolmath:Connect to Blynk using ESP8266 as Arduino Uno wifi shield (Mac only) 
Add instructable to: