Relay 1 channel not working with same code but work normally on 4 channel

I use this standard code

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "token";
 
char ssid[] = "PULPSTONE";
char pass[] = "internet";
 
void setup()
{
  Serial.begin(115200);
 
  Blynk.begin(auth, ssid, pass);
}
 
void loop()
{
  Serial.println();
  Blynk.run();
}

and it runs smoothly to control 4 channel relay with NodemCu…but why not run on 1 channel relay because it can only on and can not off…relay 1 channel running normally when i test manual …i have same problem with 2pcs 1channel relays
video test https://twitter.com/erickfloors/status/929708946532605952

relay manual test https://twitter.com/erickfloors/status/933579066124279809

any solutions?
Thanks

You need to use virtual pins and some custom coding. Not much we can help with until you have some code to fix.

can you give sample please?

Search this forum for key words like relay… there are many examples, discussions, printouts, etc. already available.

1 Like

so to control 4 ch relays and 1 ch its different code?why it not work using the same code on 4ch relays? because blynk apps will be automatic control on cloud server

You should be aware that you’re not using ANY code to control your relays, as code you provided is only connecting your board to Blynk server. Direct control of GPIO pins will work, of course.

However, I think your 1-channel relay board is faulty. I had similar experience, those relay boards without optocoupling isolation are really bad, so try to avoid them.

i think relay is work normally… im tested with manual methode…you can check my video https://twitter.com/erickfloors/status/933579066124279809

but why 2 pcs 1ch relay have same problem?

Just use virtual pins and it will be ok.

hi @Jamin why there is 2 different token on the each tab?
I always fail to use 1 channel relay, but work perfect with 4 ch relay … how to put virtual pin on 1 ch relay…
thx

Imalways fail to use 1 channel relay, but work perfect with 4 ch relay plus virtual pin… how to put virtual pin on 1 ch relay?
thx

In the code you posted there are no virtual pins defined. Please read this:

http://docs.blynk.cc/#blynk-main-operations-virtual-pins

some of code with virtual pins I include but it always fails…this is one of the last one I tried …


#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "token";

char ssid[] = "PULPSTONE";
char pass[] = "internet";
BLYNK_WRITE(V1) //Button Widget is writing to pin V1
{
  int pinData = param.asInt(); 
}
void setup()
{
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);
}

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

This partial code you added does nothing :wink:


There are sooo many examples of this simple use of virtual pins all over this forum. Please just do some searching and reading… you don’t even need to focus on relays, just LOOK at the code. and try it.

  • Set a Button Widget with virtual pin 1

  • Then whenever that button is pressed or released, the part of the code you did have (called a Blynk Function) will get called (runs) and the integer pinData will take on the value you have set in the widget (typically 0 or 1)

  • You then need to do something with that value in order that make something work… for example triggering GPIO5 (Pin 15 in Arduino) to go LOW on 0 or HIGH on 1

  • … Like this…

BLYNK_WRITE(V1) //Button Widget is writing to pin V1
{
  int pinData = param.asInt(); // This integer takes on the value or state of the button
  digitalWrite(15, pinData); // This command outputs the pinData value or state to a physical pin - in this case GPIO5 or Arduino pin 15
}

As for your relays working or not… not all GPIO pins are created equal… some have built in pull-up resistors, some are used for special purposes and cannot be pulled LOW when booting, all tend to use a different numbering layout on the board then is used in the Arduino code, etc.

Some relays are triggered on a LOW others on a HIGH signal

Some relays require additional pull up or pull down resistors in order to properly trigger

Some relays require the full 5v to trigger or at least more current the some ESP’s seem to produce.

All you can to is experiment…we cannot tell you exactly what will or will not work… or why. We can only guess based on what you tell us.

1 Like