How to use feedback on Blynk app

Hi all,

I’m running the first draft of my project on nodeMCU (his purpose is to control an 8 relay board using Blynk, to switch on and off 8 lights) and I’m having some troubles to use the feedback:

my relay board controls a 220V logic relay that drives the light. The 220V logic relay is driven also by a normal push button.
If I start my blynk application with the light off, I see the feedback of my button in OFF-state. And this in ok. If I turn on the the light using the hardware button the light goes on, but i don’t get any ON-state on the Blynk app.

My question is: if I take a feedback from the 220V logic relay and i put it on input to my nodeMCU board, how to send it to the Blynk app?

Thank you in advance.


Hopefully, the buttons you’re using are just normal low voltage push buttons that are connected to pins on your NodeMCU.
If what you describe as “push buttons” are actually wall mounted light switches that provide one or two-way switching of your lights then it’s a very different scenario.

If you are using actual low voltage push buttons then it’s fairly easy to send feedback to the Blynk app so that the the button widget stays synchronised with the state of the lightbulb.
There’s actually an example in Sketch Builder called “Sync Physical Button” that should provide a good starting point.

The one thing that confuses me slightly about the post is the 8-way relay. If you have 8 relays that you want to operate independently, and plan on having 8 physical push buttons (one for each relay) then you won’t have enough useable GPIO pins on just one NodeMCU.


Hi Pete,
thank you for your answer!
Actually I would like to use only 4 lines. So I will need 4 output and 4 input for the feedback.
I’ll check the “Sync Physical Button” example and I’ll draw a schema to be able to explain my project.


You still might struggle to find enough useable pins on your NodeMCU. Take a look at this:

It might be worth you taking a look at the ESP32, as it has more pins, with some set-up to work as touch pads.
The libraries for this are still a bit immature, but for this type of application it should be fine.


@sumaqui as far as I’ve seen, if you turn on a relay in your sketch using digital write(), the app button tied to that GPIO will not show the status. However, if you do blynk.virtualWrite() on a virtual pin, the state update happens on the server and propogates to the button in the app tied to that virtual pin.

I’ve used digital write to turn a relay on and the Blynk.virtualWrite to propogates state to the app. Works well. If you post your sketch, we will know what is being done.

@PeteKnight NodeMCU exposes 5 GPIOs clean. However, if we cut out the serial monitor and programming modes, it looks like we can get 9 GPIOs.

I’ve read about I2C expansion to add more addressing pins (64 IIRC) using a chip. I’ll also be looking for about 8 output ports for my project expansion. Will help if gurus here can advise on the best route. Is ESP32 SDK stable enough to be used like ESP8266?


Not sure what you mean by “Programming Modes”.

It all depends on whether the relay being used is active low or high, if you want to avoid the relays switching on momentarily on boot/reset.

If you’re using OTA updates and don’t want the serial monitor then Rx/Tx are potentially useable, and you may get away using GPIO2 or 16. Personally, I’d explore an ESP32 or use 2 NodeMCUs. I’ve never tried the multiplexing route, so don’t know how well it would work in practice. It’s probably not for anyone that’s new to coding, and it would certainly need virtual rather than digital pins to be used.
I might take a look at what multiplexing hardware is available and order some to play with.


Hi @mohan_sundaram.
I delved into my box of bits and found one of these:

which I ordered for something a while ago and by the time it had made its way from China to the UK I no longer had a need for it.

This allows you to have 16 digital inputs or outputs by using just 5 GPIOs.
At first glance that seems like an ideal way to go - using say 8 of the I/Os for buttons and the other 8 for relays.
However, there are a couple of issues:

  1. The outputs can handle a maximum of 25mA each and a typical 5V mult-channel relay requires around 15-20mA per channel. The problem is that an 8 channel relay requires between 120mA and 160ma and I’m not sure that the chip can handle that sort of current dissipation. Driving a transistor from each pin, which then drives the relay, is a safer option, but then the component count starts to rise.

  2. The main issue is that to register the press of a button, the 8 inputs that have buttons attached would need to be scanned all the time. Not a problem in most situations because you’d just stick the code in void loop(), but obviously an issue if you’re running Blynk code. You’d need to put the port scanning code in a function that’s being called by a timer, but that may make the buttons fairly unresponsive - requiring a longish press for the button press to be detected and registered. Thast may or may not be an issue in a real-world scenario, but it depends on the real details if the application.

For me, I still think an ESP32 is probably a better solution.


1 Like

You can use interrupts instead of the loop() / BlynkTimer.

I wondered about that, but a bit of googling seemed to show that it wasn’t possible with the CD74HC4067 Multiplexer. If it’s possible then that that would be a better solution. Have you tried this?


No I only have 4 port ADS1115’s. Were the references to interrupts not working relate to Arduino’s with their limited number of interrupts of ESP8266 with an interrupt available for each pin? You could probably disable and enable interrupts to give the required number for an ESP8266.

Probably easier to test with BlynkTimer and 0.4.10 (pre -throttled Blynk) to start with.

1 Like