Arduino Uno + ESP8266 + Blynk

Hi,

I’ve been trying to get Blynk working on an ESP8266 through an Arduino Uno.

I assume I’ve set everything up correctly, but for some reason it get’s stuck on connected to the WiFi and I’m out of ideas why… No error is being reported.

This is the output of the serial monitor:
[9]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.5.0 on Arduino Uno

[9] Connecting to Example123

And that’s pretty much all it does, stuck on that message… (Example is a mobile hotspot to check whether it connects at all, since it didn’t want to connect to a router either).

The code I’m running is the following:

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest
 
  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.
 
    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app
 
  Blynk library is licensed under MIT license
  This example code is in public domain.
 
 *************************************************************
 
  This example shows how to use ESP8266 Shield (with AT commands)
  to connect your project to Blynk.
 
  WARNING!
    It's very tricky to get it working. Please read this article:
    http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware
 
  Change WiFi ssid, pass, and Blynk auth token to run :)
  Feel free to apply it to any other example. It's simple!
 *************************************************************/
 
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
 
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
 
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "8133fxxxxxxxxxxxxx305f12b5";
 
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Example123";
char pass[] = "xxxxxxxx";
 
// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
 
// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
 
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
 
ESP8266 wifi(&EspSerial);
 
void setup()
{
  // Debug console
  Serial.begin(9600);
 
  delay(10);
 
  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
 
  Blynk.begin(auth, wifi, ssid, pass);
}
 
void loop()
{
  Blynk.run();
}

I’m hoping someone around here could be of help. I’m guessing I miss something obvious…

Thanks in advance!

@Xrizler this is a bit of a trick question but which ESP8266 are you using?

Don’t use external sites to post your code, post it here with backtick formatting.

2 Likes

You could make things much simpler by using an ESP8266 directly?
http://help.blynk.cc/how-to-connect-different-hardware-with-blynk/arduino/esp8266-with-at-firmware

1 Like

@Costas I’m sorry. I will do so in the future, thanks for your edit. I am using ESP8266 ESP-01.

@Shadeyman I am able to program the ESP8266 directly, I’ve uploaded a default blink program to it so the wiring scheme is allright. The ESP8266 needs to communicate with the Arduino to enable/disable certain pins which are being used to power a ledstrip in this case.

I’ve also enabled verbose output in the console but everything looks allright in there, it’s just that it gets stuck on connecting for ages without any error, unfortunately.

Thanks for your help so far, I hope you are able to help me determine the issue. Have a nice day!

Reno

You don’t program the ESP with a Blynk sketch when you are using the nasty Uno with ESP WiFi adapter.

In that case I miss the point entirely I assume. Have I done something wrong beforehand what could cause this issue? I figured that everything was setup correctly because the code is uploaded succesfully. When I unplug the GPIO 0 cable the upload fails, hence I thought things were OK hardware wise.

When you’re using the Uno/ESP8266 combination, the sole purpose of the ESP8266 is to act as a Wi-Fi modem for the Uno. It’s a bit like plugging one of those horrible Ethernet shields into the Uno and connecting to the internet that way.

For the ESP8266 to function as a modem, it has to be programmed with AT Firmware. If you’ve flashed the ESP with different firmware then you’ve overwritten the AT firmware that it shipped with and you’ll need to download a fresh copy and upload it.
Once you’ve done this you’ll need to set the ESP to a baud rate of 9600 via an AT command.

You can then hook the ESP up to the UNO and upload your Blynk sketch to the UNO, not to the ESP.

Pete.

2 Likes

Thanks for your reply. I am going probably going to need to flash it with AT Firmware then. I hoped this wasn’t necessary because I am not really experienced with these chips at all. Excuse me for my ignorance…

I also figured you guys aren’t very fond of the combination Arduino Uno with ESP8266, is it? Hah.

Again, thanks for your support. It is greatly appreciated.

Reno

Not with the particular ESP you have and if you had obtained a real ESP then most projects can be done directly with the ESP.

ESP’s come pre-flashed with AT firmware but you removed it. All you normally need to do is drop the default baud of the ESP from 115200 to 9600 to use with an Arduino. But IMHO it’s a system that should be avoided at all costs. You can add more analogue and digital pins to an ESP much easier than using the ESP as a WiFi shield.

It is not a favorite, particularly for some :wink: … however there are still some of us who still use them :stuck_out_tongue_winking_eye: I have an ESP-01 on a MEGA for my test bench project. Basically learning everything I can by installed every sensor and controller I have onto the MEGA (Yay for lots-o-pins) and coding it all together.

Start with that link @Shadeyman provided above for more info. re: using the ESP as a WiFi adapter,

You can get current AT firmware (V1.6.1) here,

As well as the Flash Download program to re-flash it on with. Along with instructions on the Espressif site and forum.

1 Like

Thanks for your replies. I am unable to flash the chip properly. Nevermind what I do, I keep getting the following error:

serial port opened
Connecting...
chip sync error.
com closed

Connection scheme ESP8266
GND - GND
VCC - 3V3
TXD - TX
RXD - RX (tried TXD-RX with RXD-TX as well)
GPIO0 - GND

I’ve tried multiple baud rates, an arduino nano and an arduino uno, but I can’t get rid of the error. While trying to flash, the RX/TX LEDs blink on both the arduino’s and the ESP8266, but it fails anyway… I guess I’m out of luck and something went really wrong…

If you have any ideas, I’m looking forward to hear them. If not, I’d like to thank you for your advice and support so far!

Reno

Like from your mouth to someones ear… TXD → RX and RXD ← TX is the correct way

1 Like

Hah!

Well after several hours I was finally able to flash it. The blue LED on the ESP8266 is solid blue, which is a good sign I assume. I uploaded the Blynk program to the arduino uno again, and again it gets stuck on connecting…

[22]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
///_, /////_
/__/ v0.5.0 on Arduino Uno

[620] Connecting to Example123

And that’s all it does… When I cut the connecting from ESP to arduino it reports
[201104] ESP is not responding

Thanks thus far, I got a feeling I’m pretty close. Hope you guys are able to help out once more…

Ok look up the AT command for setting the baud to 9600 and that your sketch uses 9600.

When I open a PuTTy serial connection weird symbols appear really fast and are erased immediately after. I assume this is not how it should behave. This is with a baudrate of 115200. When I select baudrate 9600, nothing is shown.

Baud is 74880.

Facepalm I should have known… I am stupid.

Now I get this…

That means a bad flash.

See this link if you are still doing the project

Dear,

Just replace Blynk.begin(auth, wifi, ssid, pass); with the Blynk.begin(auth, wifi, ssid, pass, “blynk-cloud.com”, 8080); & it will work.

Regards,
Ravindra Prajapati