Arduino Uno + ESP8266 12E + Blynk + Relay

Hello everyone,

First of all this is my first post here. I started adventure with arduino and programming 2 months ago. So I am new in this topics.
Untill now I realized few projects including Blynk connected with arduino. The last one was similar to one described in topic but I used the ENC28j60 instead of ESP8266 module and then it worked fine.
The problem started with ESP module…
Short description of project:

The main idea is to control AC light with Blynk App support.
First of all I made a connection according to picture below:


As power source I used the USB phone charger connected with step by voltage converter to get in final the 3.3V source.
I additionally connected the Arduino Uno with relay module like this:
Arduino ====> Relay module
5V ====> VCC
GND ====> GND
Pin 5 ====> IN1
Everythink you can see in picture below (sorry for quality)

And for now I did almost every step (with sooooo many problems :D). Here I mean:

  1. I checked if arduino is connected with ESP module by serial port -> system report “ready” status
  2. I upload the below (tample) Arduino IDE sketch for my project:
 #define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "***";
char pass[] = "***";



void setup()
{
  // Debug console--
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);

}

void loop()
{
  Blynk.run();
   
}
  1. And finally I started the New project in Blynk. I set the Arduino uno as a hardware model and WiFi as connection type. Then I added the Button and set the Output to D5.

And now (close to the end of project) I met with a problem. After pushing the connect button (in up-right corner) I receive the information that device is connected (Online). Then when I try to push the button to Active Relay - nothing happens :frowning:
Whats more. I tried with different pins on Arduino with the same results. And I don’t know why (probably because I have still small knowladge) but when I set the Button output value to D2 - after connection when I push it then the diod on ESP module Turn OFF and Turn ON.
I tried to find solution on this forum and in many other places for last 3 days but without any results. Thats why I decided to ask You for help. Do you know what did I wrong or what should I add to project to make connection between the Blynk and relay work correct?
Write if you will need some more or detailed informations from my side.

You are using the wrong sketch. You should use rhe esp as wifi shield sketch for this setup. And your esp should run the AT firmware. :slight_smile:

Thank you so much for your feedback! I really need help here :slight_smile:
Anyway I am not sure if I good understand. Is it below sketch?

#define BLYNK_PRINT Serial


#include <SPI.h>
#include <WiFi.h>
#include <BlynkSimpleWifi.h>

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "***";
char pass[] = "***";

void setup()
{
  // Debug console
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
}

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

When I use this code it upload correctly to Arduino board aswell. Anyway right now I can not connect blynk to esp8266 (“Device is offline”)

Just to be sure:

  1. In Arduino IDE should I use above sketch?
  2. In Arduino IDE Generic ESP 8266 should be chosen right now?
  3. In Blynk I should choose Arduino Uno or Generic board as device?

And your esp should run the AT firmware. :slight_smile:

You mean I should flash it?