Getting a "Virtual LED state" to pass to Node Red

Hi all,

I’m using gab.lau’s excellent nodes with node red (all latest versions).

I would like it so when the virtual LED on V5 goes on/off on my iOS app, it sends a corresponding payload to a debug node (for now).

This works for virtual Buttons (e.g. Pin V2 Write Event sends 1 or 0 to debug node).

But when I try it with a virtual LED, it does not send anything from either Write or Read Event nodes. I would think when the state of V5 is updated on the Blynk server, it could trigger an event.

Do I need to amend my Arduino device code to send a message to MQTT, or can this be achieved using nodes alone?

Thanks for any advice :smile:

You can do it with a Sync node, with a timer on an inject node that triggers the sync node.
This will cause the corresponding Write event to trigger.

Does this make sense?

Pete.

1 Like

Hi Pete yes it makes sense thanks, it would mean a polling time of every few seconds for it to be useful on my case.

I guess my other alternative is to do it via Arduino pubsub method.

It would certainly be cleaner to send an MQTT message from the Arduino, but polling every second or two would work without any real issues.
If you have the option to change the Arduino code then that’s how I’d do it, but polling would give you a quick fix.

Also, bear in mind that polling will give 0-255 as a result.

Pete.

1 Like

Hi,
The led widget will not trigger any event.

Which device triggers the v5 led on and off? If, when the LED is triggered, you send a value with a “bridge” direct to nodered?

This avoids using sync and polling.

The bridge is a direct communication between two devices. The message sent by the device arrives at the server which forwards it to the destination device.
In this case between arduino and nodered.

Best regards
Gabriele

1 Like

Thanks Pete :+1:

Hey Gabrielle,

Thanks for the reply. At present V5 is written to via digital.Write code on the Arduino. There is nothing being sent to node red via code.

I thought I might be able to “read” the LED state of V5 from the Blynk server via one of your nodes, and use the value to trigger another node red flow.

In otherwords a dodgy fix :smile:

I can easily add some client.publish lines on the Arduino which seems the best way, I was just curious if your nodes could be used.

Many thanks
877