Relay 1 Button 2 Task

Hello everybody,

I have a problem with my project and I wanted to control a relay card (8) via the Blynk app. So far it works without problems. My problem is that I planned to operate 2 relays simultaneously and time-controlled (seconds) using a button in the app. I tried a lot without success. To understand the relay, 2 pumps should be connected, which should run for 3 and 5 seconds, for example. I’m really baffled because I’m a beginner in the blood. My idea would be that I have a total of 5 buttons, 3 of which send different times of switching to the two relays.

If someone could help me it would be really nice because I don’t know what to do.

8 Slot Relaycard

Sorry for my bad Englisch. Im german :slight_smile:

If you are wanting to control all 8 relays independently then the ESP8266 will be a problem because it doesn’t really have enough suitable GPIO pins.
See this for more info:

An ESP32 would be a better choice.

Without seeing your code, it’s difficult to know how you’re trying to achieve the timing, but my guess is that you’re using delay() which isn’t compatible with Blynk as it blocks all other code execution and will lead to Blynk disconnections.

You should search the forum for examples of how to use timeout timers.


Thanks for your answer, at the moment I can switch all 8 relays independently. I tried it with delay but unfortunately it didn’t go well. Is it possible to work with VPins? Since, as I said, all relays can be switched independently.

Yes you can control relays with Vpins and a sketch .
But I don’t understand the question :thinking:
I see you are using Rx & Tx to control relay, it’s not a good choice.
And some pin’s out are not safety.

I’d always recommend connecting app widgets to virtual pins to control the physical pins on your device.

I think that if you did more testing you would realise that some of those relays switch on/off in an unwanted way when you restart your device. You may be happy with that behaviour, but in many situations that isn’t acceptable.
You will also find debugging difficult when you are using your serial pins to control relays, and as a beginner you’ll find it difficult to work in this way.
Trust us when we tell you that an 8-way relay board and an ESP8266 aren’t the best match. If you ever want to add physical buttons to control your relays without Blynk then an ESP32 is certainly the best option.

As I explained, Delay() is a blocking function and it starves the Blynk library of the necessary processor time, so you’ll be disconnected from the Blynk server, and if you ise long enough delays then the ESP watchdog timer will also kick-in and reboot your device.
Did you do as I suggested and



1 Like

I tested a lot but it doesn’t work. I am very inexperienced in programming. Could someone make me a sketch that I can see how it works? I tested all sorts of timers for several hours but I can’t get it without getting a lot of errors

The forum isn’t a code factory, it’s a community where members help each other with Blynk related issues.

If you want to share the code that you’ve been working on, as well as the errors that you’ve encountered, then I’m sure community members will be prepared to help you overcome your issues, and you’ll learn valuable coding skills along the way.

What timeout timer examples have you been using for reference?
Those by GTT are probably some of the best.


1 Like