Show state of light in Blynk IOT App whith Node Red


I can switch on and off a light with my Node Red flow connected to the server (node-red-contrib-blynk-iot v.1.0.0) using a button in the Blynk IOT App. How i can view the state of light in the Blynk App? Have used the Blynk write node (doc: This node will write the value in msg.payload to the specified pin number) but no Led or “Value Display” show the state of light

With a led widget you must write a msg.payload of 255 for on and 0 for off to a virtual pin.

That’s not true with Blynk IoT.
With LED widgets the range is no longer PWM style of brightness from 0-255. It is now controlled by the min/max values of the datastream that the LED is attached to.
If define a min/max range of 0-255 then ten an LED widget attached to that datastream will function exactly as it did in Legach, with 127 representing half brightness and 255 maximum brightness.
If the datastream is an integer and min/max values are 0-1 then it stops being a PWM device and starts to act in a binary way, with 0 being off and 1 being on.
If you define a range of 0-1 million then sending half a million to teg datastream will light the LED at half brightness.


The Write Event node is triggered when a datastream value changes (unless it’s changed by a Write to that datastream from within Node-Red).

When you toggle a switch widget attached to virtual pin/datastream 1 then a Write Event node attached to pin 1 will be triggered and the message payload will be the value of the datastream (usually a 1 or a 0 for a switch).

If you want to know the current state of the pin when you restart/deploy Node-Red then you can trigger a Sync node for that virtual pin, which will force the Blynk server to send the current value, triggering the Write Event node for that pin.

You can use an Inject node to trigger the Sync node once on startup if you wish.


Of course PeteKnight is right… :blush:

Hi Pete,

thanks a lot!
I have successfully showed the status of light with a led, but I don’t know how sync current status when restart or deploy.


Which parts of my description of how to do this didn’t you understand?

Maybe posting some screenshots of your flow would help.


This is the flow for display status of light:

If the light is up when the flow starts the led in Blynk App is off.
After I cycle the light on/off or off/on the status in the App sync well.

I don’t understand any of this. Where is your Write Event node for pin V4?

Did you understand that you also need to add a Blynk Sync node, and a standard Node-Red Inject node set to trigger once at startup?


Q1 is the output of a relè status and change node set 0 or 1 when the output of Q1 is false or true.
I have used a inject with a trigger but the status of led don’t sync.
You can write a code for sync?
Sorry, I’m just starting programming with node red and Blynk

That’s because you don’t have a Blynk Write Event node which can be triggered by the sync process.

Are you controlling the relay directly from the GPIO pins of whatever device you’re running Node-Red on?

I don’t understand the question.


Ok, i have write event connected at the virtual pin V1, when click a button in Blynk App the light cycle of/off. The widget led in the App is connected to virtual pin V4.
I use a Raspberry and control a Siemens Logo PLC.

You’ll need to explain what the rest of these nodes do, because I’m not familiar with the NI1 node type, or the one labelled “Luce cucina” and don’t understand why you are using the trigger node.

Understanding what the other input to the change node labelled “true” would also help.

It would also help if you answered this question…

I realise you’ve said…

but it doesn’t really answer my question.


True search for true and send “1”
Trigger send true for 250 ms for the Logo

I have a old running flow for Blynk Legacy that has written another person.
I want to update the flow for Blynk IOT

Once again, you’ve not answered my questions. Your Switch node called “true” has three inputs. in your latest screenshot I can only see what one of them is.
You’ve not told me what the “Luce cucina” node does, or what the other input to the Switch node called “true” is.

You’ve not told me if yout relay device is connected to a GPIO pin on the Pi, or what node type the “NL1” node is or what function it performs.

Going back to basics with Blynk and Node-Red, here’s an example flow that will control your V4 LED widget based on the value of a switch widget attached to pin V1.

It will also force the Blynk server to send the current value of the switch widget on startup/deployment…

The Inject node is set to inject node is configured like this…

This means at startup/deployment the sync node will send a synchronisation request to the Blynk server for Pin V1. The Blynk server will push-=out the current V1 value, triggering the Write Event node called “Switch widget on pin V1” in the same way that it will trigger when the switch widget is pressed.

Maybe it’s time to go back to that person and ask them for assistance, as you don’t seem able to answer simple questions about the functionality of your flows, so it’s extremely difficult to provide any meaningful assistance.