No0b NR user just joining in

Hello all. I finally decided to try out Node-Red... I am so new that I can't even tell you which version, but probably whatever is current at the date of this post, as I followed the official install directions for RPi

It took me a few years, despite how many times @PeteKnight suggested it to me over on the Blynk forum.

But now with Blynk going all capitalist and me wanting to remain DIY. I have been looking at ways to interface my alternative favorite App, Virtuino, with RPi.

About a year ago I hacked up a (furball) of code that allowed bidirectional data transfer between my RPi (Python) and Virtuino SE that used a DHT-11/12, PWM LED via slider and some buttons and indicators in the app. Mostly as a test to see if I could understand the protocol used and learn me some more Python.

Then I ignored it for a year :stuck_out_tongue:

Now with the pending release of Virtuino6 and much more interfacing possibilities, I decided to follow proper scientific procedure and jump into multiple learning curves at the same time... Expect stupid questions :innocent:

1 Like

Hello Gunner.. Welcome!

1 Like

I don't know anything about Virtuino but often a good way to interface with node red is to use mqtt.

1 Like

Good to know. I have obviously heard of it (being a techie type) but never, ever, looked any further then how to spell it.

However, it is one of the interface options with Virtuino, so probably my best bet to read more about it.

And I just noticed this when grabbing the image... "Last Will and Testament"?? Programmer humor?

Hmmm... I just did a forum search of Virtuino, and apparently I am the only one to have even mentioned the App name here??... that bodes well for getting advice :laughing:

Hi @Gunner welcome to the dark side!

You need to install an MQTT broker (server) on your Pi. I use Mosquitto...

The thing to watch out for is that the default configuration for Mosquitto now prevents other devices on your network communicating with the broker.
To fix this you have to edit:

/etc/mosquitto/mosquitto.conf

and add the following two lines:

listener 1883
allow_anonymous true

I'd also recommend installing MQTT explorer on a PC to allow you to easily see what's happening with your MQTT messages...

I guess it is a strange term to use, but quite descriptive.
It tells the broker which topic to use and which message to send if it discovers that the device is MIA. It usually takes around 20 seconds for the broker to realise that the client hasn't been seen, then it triggers the LWT message.
If the client is a sensor pushing out data then It's a good way of triggering a process to alert you, much like the offline notifications in Bl**nk

Pete.

3 Likes

This is an excellent guide and will tell you pretty much all you need to know. As others have said, you can use Mosquitto as the broker (which is available in most Linux repositories) and is very easy to install and use.
https://www.hivemq.com/mqtt-essentials/

3 Likes

Installed Mosquitto easy-peasy like

After a few minutes, I now have Virtuino6 displaying messages from and toggling an LED on the RPi (my ESPs are next... particularly my ESP32CAMs as I found a great topic here about using them :+1:)

I can now have a fully customizable App, a less so customizable PC desktop (but functional) and all away from $$ subscriptions and cloud services, but still accessible via WAN when I want it.

I wish someone had told me about NR long ago :innocent: :laughing:

3 Likes

:rofl: :rofl: :rofl:

I've posted a few example sketches over on the Blynk forum that will help you get started with MQTT on the ESPs. The biggest I used to have was that I just don't like working with character variable types and the PubSubClient library does everything with chars.
Maybe not such an issue with you, but the examples show you some neat ways to overcome this and to simplify the MQTT topic names for your sketches.

Pete.

1 Like

I made a spaghetti farm :blush: with my very first flow...

Just a button for LED and a display to show the timestamp (and a graph on the desktop for the CPU temp, but that was part of the install demo).

What I giggled a bit about was that I figured out how to have each button/switch duplicated, and synced, on both the Dashboard and Virtuino6 app.

Yup, I is amused by simple things, as long as they blink :rotating_light:

Some of the function stuff is no longer needed... I was doing number to string and back conversions due to the timestamp interfering with the on/off/button/led logic... until I realized having to two ?sub-topics? to differentiate between them was the correct way to go... :hushed:

Soon be time to harvest the crop :grinning_face_with_smiling_eyes: …

Looks like you’re having far too much fun!

The thing I struggled with when I first started with Node-Red was the concept of only having one input to a node. It wasn’t until I discovered flow and global variables that I was able to figure-out how to do some of the stuff I wanted to do in functions. Not really much different to how you’d do stuff in C++, but just needs a bit of lateral thinking.

Pete.

I am so focused on the fun that I may never return to that other forum... or app (even the old one)... now that I can interface Virtuino with every single MCU and SoC I could ever need.

You know, if you only ever used an Android device for that one app (Virtuino), you might forget it was an Android :stuck_out_tongue_winking_eye: That's how I treat my iPad and RemoteXY.

Of course, I actually like the fiddly bits of customizing a GUI, whereas you actually automate your home :smiley:

1 Like

Look at me getting smrtr :crazy_face:

Playing with importing from camera streams and image recognition.

That Amcrest was a pain, as it uses RTSP, so I had to do lots of Googling and snagging code/flows from other sources to finally get this much to work; Convert RTSP stream to .jpg file then send that to the image recognition after a short delay.

I think my RPi3 is melting... :fire:

1 Like

And now I have discovered how to use NR and RemoteXY App to control the RPi (and all the things)

In my attempts to help @PeteKnight escape the evil's of BlynkIoT :innocent: he pointed me to an old NR Contrib - GitHub - DeanCording/node-red-contrib-remote-xy: A Node Red node for interfacing with the Remote XY IoT control panel on Android.

And even though it hasn't been updated in four years, it seems to work just fine.

1 Like

And I updated everything to allow for full feedback (must use button, not switch - see below) when other MQTT clients are also interacting with the same subscriptions.

This older Node-Red contrib was made back when RemoteXY didn't allow bidirectional data flow with the elements (AKA a switch was output only, no way to tell the switch to toggle possition from code).

RemoteXY advanced, the older Node-Red contrib didn't.

But I found way to use other Node-Red nodes to allow a button to act as a switch - with visual feedback in form of a nested LED. Now the button looks like an edge lit button. with Green for ON and Red for OFF (duh :stuck_out_tongue_closed_eyes: )

And the Node-Red Flow that makes it work...

[{"id":"78ffec39.ca2794","type":"tab","label":"MQTT Test - RemoteXY","disabled":false,"info":""},{"id":"4d16de8b.8ee21","type":"remote-xy out","z":"78ffec39.ca2794","name":"text_1","dashboard":"ea8a0fa4.cc86c","index":"0","x":230,"y":420,"wires":[]},{"id":"d708fade.24d7b8","type":"remote-xy out","z":"78ffec39.ca2794","name":"led_1_g","dashboard":"ea8a0fa4.cc86c","index":"2","x":620,"y":120,"wires":[]},{"id":"dc020e44.8f118","type":"remote-xy in","z":"78ffec39.ca2794","name":"button_1","dashboard":"ea8a0fa4.cc86c","index":"0","x":80,"y":80,"wires":[["57c4e908.2b1d28"]]},{"id":"ee03c9d3.26d418","type":"range","z":"78ffec39.ca2794","minin":"0","maxin":"1","minout":"0","maxout":"127","action":"scale","round":false,"property":"payload","name":"","x":480,"y":120,"wires":[["d708fade.24d7b8"]]},{"id":"30cd4e5c.d331b2","type":"range","z":"78ffec39.ca2794","minin":"1","maxin":"0","minout":"0","maxout":"127","action":"scale","round":false,"property":"payload","name":"","x":480,"y":160,"wires":[["5d8c58dc.0f0498"]]},{"id":"5d8c58dc.0f0498","type":"remote-xy out","z":"78ffec39.ca2794","name":"led_1_r","dashboard":"ea8a0fa4.cc86c","index":"1","x":620,"y":160,"wires":[]},{"id":"f19dcce0.01774","type":"mqtt in","z":"78ffec39.ca2794","name":"","topic":"test/led","qos":"0","datatype":"auto","broker":"236d220c.514f8e","nl":false,"rap":true,"rh":0,"x":70,"y":120,"wires":[["ee03c9d3.26d418","30cd4e5c.d331b2","96c639b6.76ba98"]]},{"id":"d2b810fd.d809d","type":"remote-xy out","z":"78ffec39.ca2794","name":"led_2_g","dashboard":"ea8a0fa4.cc86c","index":"4","x":620,"y":300,"wires":[]},{"id":"3c7aeb5b.0e7194","type":"remote-xy in","z":"78ffec39.ca2794","name":"button_2","dashboard":"ea8a0fa4.cc86c","index":"1","x":80,"y":260,"wires":[["cee1471.6aaacb8"]]},{"id":"53ccf57a.c9266c","type":"range","z":"78ffec39.ca2794","minin":"0","maxin":"1","minout":"0","maxout":"127","action":"scale","round":false,"property":"payload","name":"","x":480,"y":300,"wires":[["d2b810fd.d809d"]]},{"id":"c35bc35a.1879a","type":"range","z":"78ffec39.ca2794","minin":"1","maxin":"0","minout":"0","maxout":"127","action":"scale","round":false,"property":"payload","name":"","x":480,"y":340,"wires":[["1e65c31e.c714bd"]]},{"id":"1e65c31e.c714bd","type":"remote-xy out","z":"78ffec39.ca2794","name":"led_2_r","dashboard":"ea8a0fa4.cc86c","index":"3","x":620,"y":340,"wires":[]},{"id":"e92eb668.3882a8","type":"mqtt in","z":"78ffec39.ca2794","name":"","topic":"test/relay","qos":"0","datatype":"auto","broker":"236d220c.514f8e","nl":false,"rap":true,"rh":0,"x":80,"y":300,"wires":[["53ccf57a.c9266c","c35bc35a.1879a"]]},{"id":"39e9d2a2.82ffbe","type":"mqtt out","z":"78ffec39.ca2794","name":"","topic":"test/led","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"236d220c.514f8e","x":540,"y":80,"wires":[]},{"id":"2aacdf94.d0f7a","type":"mqtt out","z":"78ffec39.ca2794","name":"","topic":"test/relay","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"236d220c.514f8e","x":540,"y":260,"wires":[]},{"id":"96c639b6.76ba98","type":"rpi-gpio out","z":"78ffec39.ca2794","name":"","pin":"12","set":true,"level":"0","freq":"","out":"out","x":220,"y":160,"wires":[]},{"id":"d9c64d70.401e88","type":"toggle","z":"78ffec39.ca2794","name":"","onOffTopic":"","onValue":"1","onType":"str","offValue":"0","offType":"str","toggleTopic":"","toggleValue":"","toggleType":"any","passOnOff":"always","x":350,"y":80,"wires":[["39e9d2a2.82ffbe","ee03c9d3.26d418","30cd4e5c.d331b2"]]},{"id":"57c4e908.2b1d28","type":"function","z":"78ffec39.ca2794","name":"","func":"if (msg.payload == 1){\n    msg.payload = \"-\"\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":220,"y":80,"wires":[["d9c64d70.401e88"]]},{"id":"cee1471.6aaacb8","type":"function","z":"78ffec39.ca2794","name":"","func":"if (msg.payload == 1){\n    msg.payload = \"-\"\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":220,"y":260,"wires":[["41c46b50.e4fe74"]]},{"id":"41c46b50.e4fe74","type":"toggle","z":"78ffec39.ca2794","name":"","onOffTopic":"","onValue":"1","onType":"str","offValue":"0","offType":"str","toggleTopic":"","toggleValue":"","toggleType":"any","passOnOff":"always","x":350,"y":260,"wires":[["2aacdf94.d0f7a","53ccf57a.c9266c","c35bc35a.1879a"]]},{"id":"6b94b56.9ce4b4c","type":"comment","z":"78ffec39.ca2794","name":"MQTT - RemoteXY","info":"","x":110,"y":20,"wires":[]},{"id":"ac97c109.228e6","type":"mqtt in","z":"78ffec39.ca2794","name":"","topic":"test/time","qos":"2","datatype":"auto","broker":"236d220c.514f8e","nl":false,"rap":true,"rh":0,"x":80,"y":420,"wires":[["4d16de8b.8ee21"]]},{"id":"ea8a0fa4.cc86c","type":"remote-xy-dashboard","name":"RemoteXY","port":"6377","config":"//////////////////////////////////////////////\n//        RemoteXY include library          //\n//////////////////////////////////////////////\n\n// RemoteXY select connection mode and include library \n#define REMOTEXY_MODE__ESP8266WIFI_LIB\n#include <ESP8266WiFi.h>\n\n#include <RemoteXY.h>\n\n// RemoteXY connection settings \n#define REMOTEXY_WIFI_SSID \"YOUR_SSID\"\n#define REMOTEXY_WIFI_PASSWORD \"YOUR_PASS\"\n#define REMOTEXY_SERVER_PORT 6377\n\n\n// RemoteXY configurate  \n#pragma pack(push, 1)\nuint8_t RemoteXY_CONF[] =\n  { 255,2,0,30,0,162,0,11,27,1,\n  67,5,9,18,46,5,16,26,26,129,\n  0,16,11,18,6,8,68,97,116,101,\n  32,38,32,84,105,109,101,0,129,0,\n  10,29,44,6,8,76,69,68,32,111,\n  110,32,71,80,73,79,49,56,0,129,\n  0,8,59,48,6,8,82,101,108,97,\n  121,32,111,110,32,87,101,109,111,115,\n  0,129,0,7,92,49,6,8,77,81,\n  84,84,32,102,111,114,32,116,104,101,\n  32,119,105,110,0,129,0,8,92,49,\n  6,177,77,81,84,84,32,102,111,114,\n  32,116,104,101,32,119,105,110,0,65,\n  22,24,36,16,16,1,0,26,38,12,\n  12,16,28,80,82,69,83,83,0,65,\n  22,24,66,16,16,1,0,26,68,12,\n  12,16,28,80,82,69,83,83,0 };\n  \n// this structure defines all the variables and events of your control interface \nstruct {\n\n    // input variables\n  uint8_t button_1; // =1 if button pressed, else =0 \n  uint8_t button_2; // =1 if button pressed, else =0 \n\n    // output variables\n  char text_1[26];  // string UTF8 end zero \n  uint8_t led_1_r; // =0..255 LED Red brightness \n  uint8_t led_1_g; // =0..255 LED Green brightness \n  uint8_t led_2_r; // =0..255 LED Red brightness \n  uint8_t led_2_g; // =0..255 LED Green brightness \n\n    // other variable\n  uint8_t connect_flag;  // =1 if wire connected, else =0 \n\n} RemoteXY;\n#pragma pack(pop)\n\n/////////////////////////////////////////////\n//           END RemoteXY include          //\n/////////////////////////////////////////////"},{"id":"236d220c.514f8e","type":"mqtt-broker","name":"RPi Mosquitto broker","broker":"10.10.3.13","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

image

1 Like

And now... just simple fun with blinky vLEDs on the dashboard :police_car:

[{"id":"af1708dc.4e6ce8","type":"tab","label":"Flasher","disabled":false,"info":""},{"id":"efde91d9.e81c1","type":"toggle","z":"af1708dc.4e6ce8","name":"","onOffTopic":"","onValue":"true","onType":"bool","offValue":"false","offType":"bool","toggleTopic":"","toggleValue":"togglenow","toggleType":"str","passOnOff":"ifChanged","x":530,"y":240,"wires":[["5e89e544.5097fc","cde43dda.d2146"]]},{"id":"435db4ed.e013bc","type":"ui_led","z":"af1708dc.4e6ce8","order":2,"group":"f781ecdb.5a18b","width":"4","height":"4","label":"","labelPlacement":"right","labelAlignment":"center","colorForValue":[{"color":"#ffffff","value":"true","valueType":"bool"},{"color":"#808080","value":"false","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"square","showGlow":true,"name":"White","x":890,"y":200,"wires":[]},{"id":"cf4fe032.d3912","type":"ui_led","z":"af1708dc.4e6ce8","order":2,"group":"85815d64.6c718","width":"4","height":"4","label":"","labelPlacement":"right","labelAlignment":"center","colorForValue":[{"color":"#ffffff","value":"true","valueType":"bool"},{"color":"#808080","value":"false","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"square","showGlow":true,"name":"White","x":710,"y":200,"wires":[]},{"id":"5e89e544.5097fc","type":"ui_led","z":"af1708dc.4e6ce8","order":1,"group":"85815d64.6c718","width":"4","height":"4","label":"","labelPlacement":"right","labelAlignment":"center","colorForValue":[{"color":"#0000ff","value":"true","valueType":"bool"},{"color":"#ff0000","value":"false","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"square","showGlow":true,"name":"Red/Blue","x":720,"y":300,"wires":[]},{"id":"cde43dda.d2146","type":"ui_led","z":"af1708dc.4e6ce8","order":1,"group":"f781ecdb.5a18b","width":"4","height":"4","label":"","labelPlacement":"right","labelAlignment":"center","colorForValue":[{"color":"#ff0000","value":"true","valueType":"bool"},{"color":"#0000ff","value":"false","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"square","showGlow":true,"name":"Red/Blue","x":880,"y":300,"wires":[]},{"id":"d34c6647.127fd8","type":"toggle","z":"af1708dc.4e6ce8","name":"","onOffTopic":"","onValue":"true","onType":"bool","offValue":"false","offType":"bool","toggleTopic":"","toggleValue":"togglenow","toggleType":"str","passOnOff":"ifChanged","x":530,"y":180,"wires":[["cf4fe032.d3912","435db4ed.e013bc"]]},{"id":"98feb8ae.221f88","type":"trigger","z":"af1708dc.4e6ce8","name":"Trigger","op1":"togglenow","op2":"false","op1type":"str","op2type":"bool","duration":"-250","extend":false,"overrideDelay":true,"units":"ms","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":140,"y":200,"wires":[["d34c6647.127fd8","482bcbee.085794","2e609062.cb313"]]},{"id":"ac1a8414.17ff98","type":"ui_led","z":"af1708dc.4e6ce8","order":3,"group":"f781ecdb.5a18b","width":"4","height":"4","label":"","labelPlacement":"right","labelAlignment":"center","colorForValue":[{"color":"#0000ff","value":"true","valueType":"bool"},{"color":"#ff0000","value":"false","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"square","showGlow":true,"name":"Red/Blue","x":880,"y":100,"wires":[]},{"id":"56a4f9fe.2c6018","type":"toggle","z":"af1708dc.4e6ce8","name":"","onOffTopic":"","onValue":"true","onType":"bool","offValue":"false","offType":"bool","toggleTopic":"","toggleValue":"togglenow","toggleType":"str","passOnOff":"ifChanged","x":530,"y":120,"wires":[["ac1a8414.17ff98","66ef7939.3c03b8"]]},{"id":"66ef7939.3c03b8","type":"ui_led","z":"af1708dc.4e6ce8","order":3,"group":"85815d64.6c718","width":"4","height":"4","label":"","labelPlacement":"right","labelAlignment":"center","colorForValue":[{"color":"#ff0000","value":"true","valueType":"bool"},{"color":"#0000ff","value":"false","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"square","showGlow":true,"name":"Red/Blue","x":720,"y":100,"wires":[]},{"id":"482bcbee.085794","type":"delay","z":"af1708dc.4e6ce8","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":370,"y":140,"wires":[["56a4f9fe.2c6018"]]},{"id":"2e609062.cb313","type":"delay","z":"af1708dc.4e6ce8","name":"","pauseType":"delay","timeout":"200","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":370,"y":220,"wires":[["efde91d9.e81c1"]]},{"id":"a4c75bed.078138","type":"ui_multistate_switch","z":"af1708dc.4e6ce8","name":"","group":"3ac11ff8.cbad6","order":2,"width":0,"height":0,"label":"Flash Rate","stateField":"payload","enableField":"","rounded":true,"useThemeColors":true,"hideSelectedLabel":false,"options":[{"label":"STOP","value":"reset","valueType":"str","color":"#009933"},{"label":"128ms","value":"128","valueType":"num","color":"#ff6666"},{"label":"256ms","value":"256","valueType":"num","color":"#009999"},{"label":"500ms","value":"500","valueType":"num","color":"#cccc00"},{"label":"1000ms","value":"1000","valueType":"num","color":"#ff33cc"}],"x":130,"y":160,"wires":[["98feb8ae.221f88"]]},{"id":"efddee27.ba21d","type":"comment","z":"af1708dc.4e6ce8","name":"Fun with Blinky LEDs","info":"","x":160,"y":60,"wires":[]},{"id":"f781ecdb.5a18b","type":"ui_group","name":"Right","tab":"bb7236c.d277cc8","order":3,"disp":true,"width":"4","collapse":false},{"id":"85815d64.6c718","type":"ui_group","name":"Left","tab":"bb7236c.d277cc8","order":1,"disp":true,"width":"4","collapse":false},{"id":"3ac11ff8.cbad6","type":"ui_group","name":"Control","tab":"bb7236c.d277cc8","order":2,"disp":true,"width":"8","collapse":false},{"id":"bb7236c.d277cc8","type":"ui_tab","name":"Flashing LED","icon":"dashboard","disabled":false,"hidden":false}]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.