Connect to Blynk Using ESP8266 As Arduino Uno Wifi Shield (Mac Only)

127,800

106

115

About: Mechanical Engineering student at the University of Michigan

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

ESP8266-01

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

pySerial

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

esptool

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

Password:

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

warnings.warn(msg)

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 ____

ATE0

AT+CWMODE?

AT+CWJAP="____","_____"

AT+CIFSR

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

+CIFSR:STAMAC,"__:__:__:__:__"

OK

AT+CIPMUX=0

[7633] Connected to WiFi

AT+CIPCLOSE

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

AT+CIPSEND=37

[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!!

9 People Made This Project!

Recommendations

  • Make it Glow Contest 2018

    Make it Glow Contest 2018
  • First Time Author

    First Time Author
  • Big and Small Contest

    Big and Small Contest

115 Discussions

0
None
nolmath

3 years ago on Introduction

If you have a question, feel free to post it here. I will try to answer it as soon as possible.

8 replies

what problem in my serial monitor. (wifi name and pass is correct)

[19] Blynk v0.3.0

[20] Connecting to Rozelle Thai Cuisine

ATE0

AT+CWMODE?

AT+CWJAP="Rozelle Thai Cuisine","dekthai99087"

[10067] Failed to connect WiFi

AT+CIPCLOSE

AT+CIPSTART="TCP","cloud.blynk.cc",8442

AT+CIPCLOSE

AT+CIPSTART="TCP","cloud.blynk.cc",8442

AT+CIPCLOSE

AT+CIPSTART="TCP","cloud.blynk.cc",8442

AT+CIPCLOSE

AT+CIPSTART="TCP","cloud.blynk.cc",8442

AT+CIPCLOSE

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)

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

0
None
IsabelM13nolmath

Reply 3 years ago

Please help me with step 13, it says fatal error: failed to connect

0
None
TeenuJIsabelM13

Reply 2 years ago

cmd comand cd

Desktop

pyserial-2.7 sudo python setup.py install but run tha software plz help me

0
None
AcrimoniousMirthnolmath

Reply 2 years ago

I drag the file to Terminal and it complains that no such file or directory can be found. How do I solve this? Thanks!

0
None
nolmathAcrimoniousMirth

Reply 2 years ago

If that doesn't work then you should type the path in manually

0
None
ThisunS

1 year ago

Please help :'(

(step 12)

Password:

esptool.py v2.0-beta3

Connecting........_____....._____....._____....._____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to Espressif device: Timed out waiting for packet header

Thisuns-MacBook-Pro:esptool-master thisunsudaraka$

0
None
DanielT211

2 years ago

Hi, does blynk library works at more recent ESP8266-01 version? I got AT version:0.60.0.0(Jan 29 2016 15:10:17) SDK version:1.5.2. Thanks

1 reply
0
None
nolmathDanielT211

Reply 2 years ago

I would suggest using the version I used. I'm not sure if the newer one works or not

0
None
skiyer

2 years ago

while trying step 12,.. i got this error .....

Subramanians-MacBook-Air:esptool-master skiyer$ sudo ./esptool.py --port /dev/tty.usbmodem1411 write_flash 0x00000 AT22SDK10020150320boot12.bin

esptool.py v1.2-dev

Connecting...

A fatal error occurred: Failed to connect to ESP8266

what should i do?

0
None
skiyer

2 years ago

while trying step 12,.. i got this error .....

Subramanians-MacBook-Air:esptool-master skiyer$ sudo ./esptool.py --port /dev/tty.usbmodem1411 write_flash 0x00000 AT22SDK10020150320boot12.bin

esptool.py v1.2-dev

Connecting...

A fatal error occurred: Failed to connect to ESP8266

what should i do?

0
None
SemV1

2 years ago

i'm getting this error how can i fix this

sudo ./esptool.py --port /dev/tty.usbserial-A50285BI write_flash 0x00000 AT22SDK10020150320boot12.bin

esptool.py v1.2-dev

Connecting...

A fatal error occurred: Failed to connect to ESP8266

0
None
SunmeetC

2 years ago

I am using the correct serial port name ass shown in step 12. But still I'm getting an error of invalid syntax.

Screen Shot 2016-06-13 at 3.56.24 AM.png
1 reply
0
None
nolmathSunmeetC

Reply 2 years ago

That should have worked. Maybe try reinstalling esptool and pyserial

0
None
spetyo

2 years ago

https://www.youtube.com/watch?v=_A8iyLPsGAw

0
None
marten99

2 years ago

Now, my ESP8266 gets enough electricity, but when I open my Blynk app, it tells me that my Arduino Mega is not in Network.

When I look at the Serial Monitor, everything is like step 14, instead of the last row, when AT+CIPSEND =37 and when I should get the PING

what my Serial Monitor says:

[19] Blynk v0.3.3
[520] Connecting to ___
ATE0
AT+CWMODE?
AT+CWJAP="___","___"
AT+CIFSR
[3578] IP: +CIFSR:STAIP,"___.___._.___"
+CIFSR:STAMAC,"--:--:--:--:--:--"

OK
AT+CIPMUX=0
[3601] Connected to WiFi
AT+CIPCLOSE
AT+CIPSTART="TCP","cloud.blynk.cc",8442
AT+CIPCLOSE
AT+CIPSTART="TCP","cloud.blynk.cc",8442
AT+CIPCLOSE
AT+CIPSTART="TCP","cloud.blynk.cc",8442
AT+CIPCLOSE
AT+CIPSTART="TCP","cloud.blynk.cc",8442