Blynk app disconnects when button is pressed

I’m trying to implement a home automation project as given in the following link


Instead of the 4 channel relay, I’m using 2 single channel relays.
I load the ESP8266_Standalone example with my auth code,ssid and password.
Im using D3,D4 pins of the nodemcu to control the relays, and Im powering the relays using the 5V supply from nodemcu.
When I press any of the buttons the Blynk app disconnects.
There is no change in the relays when the buttons are pressed.
Please provide me a solution to make the home automation system using blynk app and node mcu.

to help you we need to see your sketch :wink:

/*************************************************************
  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 runs directly on ESP8266 chip.

  Note: This requires ESP8266 support package:
    https://github.com/esp8266/Arduino

  Please be sure to select the right ESP8266 module
  in the Tools -> Board menu!

  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 <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

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

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

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

  Blynk.begin(auth, ssid, pass);

}

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

i think it’s caused by pin you are using.

1 Like

I don’t see any pinout declaration, no more virtual write or digital write in your sketch.

I was proceeding in accordance with the youtube video,i m newbie to Blynk.

ok , but the sketch you provide trigges nothing.
I think it’s not the sketch you are using.
what do you see on the serial monitor?

[58] Connecting to xxxx
[1062] Connected to WiFi
[1062] IP:xxxxxxxxxxxx
[1062]


/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.6.1 on NodeMCU

[1139] Connecting to blynk-cloud.com:80
[1721] Ready (ping: 262ms).

Without the triggers how is the person in the video still able to work the relays ?

he did that with Google API, not blynk.:joy:
your sketch do nothing else connect to blynk server.

How can I connect to blynk server?

as @Gunner will say, you have to learn before blynk from zero before trying to ask Google to trigger your relay. :wink:

i think , my friend @PeteKnight will be the best to teach you about IFTT :slight_smile:

I changed by code, first I need to control the relays just using the blynk app.So the changed code is as follows:

#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 = “my auth code”;

// Your WiFi credentials.
// Set password to “” for open networks.
char ssid = “wifi”;
char pass = “wifi passwd”;

const int Relay_1 = D1;
const int Relay_2 = D2;

void setup()
{
pinMode(Relay_1, OUTPUT);
pinMode(Relay_2, OUTPUT);

digitalWrite(Relay_1, HIGH);
digitalWrite(Relay_2, HIGH);

// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);

}

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

/********************** Relay 1 ON/OFF V1 *******************************/
BLYNK_WRITE(V1)
{
int pinValue = param.asInt();
if (pinValue == 1)
{
digitalWrite(Relay_1, LOW);
Serial.println(“Relay 1 On”);
}
else if (pinValue == 0)
{
digitalWrite(Relay_1, HIGH);
Serial.println(“Relay 1 Off”);
}
}

/********************** Relay 2 ON/OFF V2 *******************************/
BLYNK_WRITE(V2)
{
int pinValue = param.asInt();
if (pinValue == 1)
{
digitalWrite(Relay_2, LOW);
Serial.println(“Relay 2 On”);
}
else if (pinValue == 0)
{
digitalWrite(Relay_2, HIGH);
Serial.println(“Relay 2 Off”);
}
}

Still, the problem persists, whenever I’m clicking on the button widget, the project disconnects. But, I’m getting the serial prints but there is no change in the relays.
Heres the serial monitor output :

[57] Connecting to xxxx
[1061] Connected to WiFi
[1061] IP: xxxxxxx
[1061]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.6.1 on NodeMCU

[1138] Connecting to blynk-cloud.com:80
[1709] Ready (ping: 261ms).
Relay 2 Off
Relay 1 Off
Relay 2 On
Relay 1 On
Relay 2 Off
Relay 1 Off

Probably not the best idea.

Pete.

2 Likes

nodemcu provide 5v volts coming directly from power supply, so no worry.
I have 4 relays on my nodemcu.
they work well.
my power supply is an USB 2A adapter for phone.
Alex.

It it depends what @Sreehari is using for power, and what type of relays he’s using.

Pete.

2 Likes

Im using the following relay
relay
and my power supply is USB 2A adapter for phone.

If you power the Nodemcu trough micro-usb, you must power the relay from VU pin NOT from VIN pin…

Which pin are you referring to?
The NodeMCU doesn’t have a pin labelled VU.

Pete.