Node-Red Input and Output

I have BLYNK running on my Android phone - and I have installed the user-contributed Node-Red nodes for Node-Red.

I can press a virtual button on the phone and the output will be seen in the relevant node-red phone - no problem.

However, and it might just be me - I cannot figure out how to get data from node-red either back to the phone (for example the LCD display) or to say an ESP8266 who’s relay is controlled by the phone (pin 0) - nothing I can do in Node-Red will turn that relay on and off - YET, clearly the Node-red stuff is working - because it is picking up a change of button state on a test V10 virtual pin on the phone.

Any ideas anyone?

@tzapulica could you please take a look???

@scargill since there s a new update for ios with a new shiny LCD widget i will try this and get back to you regarding updating data on the phone from node red.

in theory all you would need is a blynk write node in node red.

regarding making node red do something on the esp, i think this won t work without a bridge widget, the contrib i made basically makes node red an endpoint for the blynk app and server, instead of a hardware device. from then on you could control the esp however you like, through http or mqtt for instance.

@vhymanskyy i wonder, if i implemented the bridge widget in node red somehow, would that let me write and read virtual pins from another project;s hardware? or maybe i misunderstood what it does

@scargill big fan of your blog btw :slight_smile:

the lcd widget uses some other functions than the rest, so that s not implemente yet, but since it s avail in ios now as well, i can try and sort it

a button can t be set yet from the blynk device side of things, not supported by the server/library

for an led or value display, use the write node and set the proper payload

short example:

:[{“id”:“44adba8a.964b14”,“type”:“blynk-server”,“key”:“your-blynk-key”,“usessl”:true,“host”:"",“port”:""},{“id”:“3d75de3a.cc5882”,“type”:“blynk-write”,“name”:"",“server”:“44adba8a.964b14”,“pin”:“0”,“x”:599,“y”:228,“z”:“7172bcca.b38884”,“wires”:[]},{“id”:“581a506d.7733b8”,“type”:“inject”,“name”:"",“topic”:"",“payload”:"",“payloadType”:“date”,“repeat”:"",“crontab”:"",“once”:false,“x”:224,“y”:231,“z”:“7172bcca.b38884”,“wires”:[[“3d75de3a.cc5882”]]},{“id”:“5434f425.29fa14”,“type”:“inject”,“name”:"",“topic”:"",“payload”:“1”,“payloadType”:“string”,“repeat”:“1”,“crontab”:"",“once”:false,“x”:219,“y”:327,“z”:“7172bcca.b38884”,“wires”:[[“582e5f74.31575”]]},{“id”:“680346e6.eb4c18”,“type”:“blynk-write”,“name”:"",“server”:“44adba8a.964b14”,“pin”:“1”,“x”:602,“y”:321,“z”:“7172bcca.b38884”,“wires”:[]},{“id”:“582e5f74.31575”,“type”:“function”,“name”:“blink”,“func”:“context.count = context.count || 0;\ncontext.count += 1;\nmsg.payload = context.count % 2;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:407,“y”:322,“z”:“7172bcca.b38884”,“wires”:[[“680346e6.eb4c18”]]}]

@vshymanskyy no lcd widget in the js lib?

LCD working a treat from node-red - cracked that one. That lack of button control is a real pain - I’ve used a LED to tell me if someting is actually on - but without a timer on the APP to say the app is listening I’ve no solution for updating everything. Really needs the button to be updateable from the server, the App to be able to say “I’m running” and a tick timer rather than a one-off event. Once those are in place this could be REALLY very powerful. Thanks for your feedback and thanks for the comment about the blog - I work very hard on it. I put what I thought was a subtle link in my signature but it got blocked - oh, well. I intend to blog this morning more about this app as I think it has potential given the fixes/updates I’ve suggested elsewhere. Really nice visuals.

Yes, I should have updated… within the limits of what you CAN do right now, I have node-red running a treat. I have a page on the phone controlling 2 RGB devices, monitoring my 12v car battery (sadly on a button push thanks to no watchdog-type timer) and turning a light on and off - a LED tells me the actual state of the light when I press the button…

pretty much the same limitations i ran into.
i have replied about the monitoring value thing in your other topic, maybe you find it useful.

did you get LCD working from node red or value display?

all said and done, i still can t believe how easy it is now to setup a dashboard, test something, etc AND how nice it looks :smile:

@Pavlo and @vshymanskyy have been very receptive to requests so i don t doubt this will grow into something leaps and bounds better. having some iot heavyweigths like yourself involved and offering suggestions can only help :smiley:

Actually it is dead easy to have the APP and Node-Red update or get data from multiple devices - I’m doing it right now. Info comes in from node from the APP, put it through a function - to MQTT… also for example - I press a button on the APP, that causes an MQTT request from my battery monitor. Info comes in from MQTT in Node-Red on battery voltage - I send that back to the APP to a gauge - which then shows the battery voltage. With Node-Red in charge the APP can talk to just about anything! I’m blogging about this right now - later today…

using nodered and mqtt you can of course speak to anything
i was under the impression originally that you wanted to update devices through the blynk protocol as well.
much better in my opinion (and more stable for now at least) to have devices just on mqtt and have node speak to blynk. it opens so many possibilities i can t decide what to do :))

were you able to use LCD from node red?

Check the blog - I’ve just re-written it - I’m wary about putting a link in here as this response will end up in the spam box. I am controlling my gadgets and reading values over MQTT - using Node-Red to do that - and Node-Red is talking to the APP. The blog entry shows where I am, what I think needs fixing in/adding to Blinx - but LCD no problem from Node-Red, LEDs no problem - turning things on and off no problem - button updates, well that can’t be done yet… I hope that’s something that can be quickly addressed. That and page-start timer would allow me to update the App buttons as the App opens the page - to the correct state - and then, as they say, we’re COOKING. I’m currently monitoring a battery (on a button press), controlling 2 RGB lights and a straight on-off light and I’ll soon have that slider attached to a dimmable light.

This is fun…

@scargill a value display with a refresh rate of XX seconds is basically a page timer (or can be twisted to function like one). it will issue a read event ever XX seconds WHEN the page is displayed on screen. (at least in ios, don t know about android)
you can also use that to keep updating the value display ONLY WHEN you are looking at it on your mobile device

1 Like

@scargill nice post. if i may offer a suggestion that would sort part of what you mentioned:
i would replace this


with something like

both the blynk nodes reference the same virtual pin of a gauge and the gauge is set to refresh at 59 seconds

and like i said before that will only be triggered when the app is active. it would also allow you to have the value in node red at all times so you can do other stuff with it independent of blynk. depends what else you need. the whole update flow could be so when the gauge requests and update it sends a mqtt message to get the bat voltage, etc, but you wouldn t need to press a button to update anymore.

Fixing it now - I already have the voltage in a global var. I’d not twigged to this - very good - will update the blog when tested. Keep em coming.

Yes, tested that - it works - which makes me wonder - why isn’t that OPTION in the LED and button items!?? That would solve a lot of issues… going to check the page load item now - not sure how that works.

Ok, where’s the PAGE timer? I’m seeing a timer for a one off event… but not a page timer??? (Android)

hi, it s not a page timer per se, it s more of a creative use of a value display, or gauge or anything that has a refresh rate.
it will simply send a read event to node red when it starts (i think) and after the interval as long as the app and project are active on the phone

edit, but, unless you really want to know when the app on the phone is live, wiring things like the above voltage gauge will really mean you don t need to know when the phone is active, it will take care of updating itself. (although you can t update leds like that, like you mentioned).

btw, there s nothing stopping you issuing another write with the virtual pin of a led when you get a read event on the voltage. that way, you update the whole interface

@scargill

Here you go http://docs.blynk.cc/#blynk-main-operations-get-data-from-hardware

Ah, yes, the penny drops. As long as you have a gauge… well, that’s ok for my current test but an invisible version of that might be good - the gauge is a bit big. Yes, there’s no reason I can’t use the gauge timer to update other things - well spotted. Yup I’ll update my LEDS etc at the same time…

value display is a lot smaller, that s what i generally use