Node-Red

Install Node-Red in Win10

Posted on Updated on

  • Install node.js – I am using version 5.4.0. Download

Once installed in command window

npm install -g --unsafe-perm node-red

then install dashboard

npm install node-red-dashboard

 

Done

Nextion Raspberry Pi UI

Posted on Updated on

A quick project to connect a Nextion HMI to Raspberry Pi and get some text displayed. (Or whatever goes through your mind)

nextion_hmi_320x240

I am using a Chinese version (I am in China!) of 2.8″ 320×240 device.

  • The Nextion project

I made a simple screen with 4 text field to receive data form the RPI.

The text field are named: t0, t1, t2, t3.

nextion_project

Here is the project file (download and rename it as rpi_hmi.HMI)

downlod rpi_hmi.HMI

pi3_gpio

Connect + 5 VDC to pin 2

Connect GND to pin 6

Connect Rx to pin 8

Connect Tx to pin 10

  • To send data to the screen I am using my favorite application: Node-Red.

From Node-Red it is possible to run commands and send them to the serial port.

Before that we should make sure that the serial port is available.

If RPI 2, read this post.

If RPI 3, read this post.

In PRI 3 , to use ttyAMA0 it is necessary to stop the bluetooth.

To send data to the Nextion, we should format them like:

t0.txt=, 0x22, text to send, 0x22, 0xFF, 0xFF, 0xFF

Here is the Node-Red flow.

[{"id":"244f48cf.81b92","type":"inject","z":"7a00aa0e.a9b7d4","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":128.5,"y":136,"wires":[["e0180d8.3c9047"]]},{"id":"e0180d8.3c9047","type":"function","z":"7a00aa0e.a9b7d4","name":"","func":"s_object = \"t0.txt=\";\ns_text = \"Hello\";\nvar arr = [];\nfor (var i = 0, l = s_object.length; i < l; i ++) {\n    var ascii = s_object.charCodeAt(i);\n    arr.push(ascii);\n}\narr.push(0x22);\nfor (var i = 0, l = s_text.length; i < l; i ++) {\n    var ascii = s_text.charCodeAt(i);\n    arr.push(ascii);\n}\narr.push(0x22);\narr.push(0xFF);\narr.push(0xFF);\narr.push(0xFF);\nmsg.payload = new Buffer(arr);\nreturn msg;","outputs":1,"noerr":0,"x":288.5,"y":135,"wires":[["858c79ee.44437"]]},{"id":"858c79ee.44437","type":"serial out","z":"7a00aa0e.a9b7d4","name":"","serial":"2466d4ba.b7759c","x":502.5,"y":134,"wires":[]},{"id":"2466d4ba.b7759c","type":"serial-port","z":"7a00aa0e.a9b7d4","serialport":"/dev/ttyAMA0","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"100","bin":"bin","out":"time","addchar":false}]

Another flow to display the CPU temperature

[{"id":"244f48cf.81b92","type":"inject","z":"7a00aa0e.a9b7d4","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":128.5,"y":136,"wires":[["e0180d8.3c9047","3c8c3ccb.ea114c","ef39e89d.a084d"]]},{"id":"e0180d8.3c9047","type":"function","z":"7a00aa0e.a9b7d4","name":"","func":"s_object = \"t0.txt=\";\ns_text = \"Hello World\";\nvar arr = [];\nfor (var i = 0, l = s_object.length; i < l; i ++) {\n    var ascii = s_object.charCodeAt(i);\n    arr.push(ascii);\n}\narr.push(0x22);\nfor (var i = 0, l = s_text.length; i < l; i ++) {\n    var ascii = s_text.charCodeAt(i);\n    arr.push(ascii);\n}\narr.push(0x22);\narr.push(0xFF);\narr.push(0xFF);\narr.push(0xFF);\nmsg.payload = new Buffer(arr);\nreturn msg;","outputs":1,"noerr":0,"x":288.5,"y":135,"wires":[["858c79ee.44437"]]},{"id":"858c79ee.44437","type":"serial out","z":"7a00aa0e.a9b7d4","name":"","serial":"2466d4ba.b7759c","x":636.5,"y":138,"wires":[]},{"id":"8d36ba49.d16358","type":"serial in","z":"7a00aa0e.a9b7d4","name":"","serial":"2466d4ba.b7759c","x":112.5,"y":414,"wires":[["9057e978.8b3c"]]},{"id":"9057e978.8b3c","type":"debug","z":"7a00aa0e.a9b7d4","name":"","active":true,"console":"false","complete":"false","x":398.5,"y":417,"wires":[]},{"id":"3c8c3ccb.ea114c","type":"function","z":"7a00aa0e.a9b7d4","name":"","func":"s_object = \"t1.txt=\";\ns_text = \"Line 2\";\nvar arr = [];\nfor (var i = 0, l = s_object.length; i < l; i ++) {\n    var ascii = s_object.charCodeAt(i);\n    arr.push(ascii);\n}\narr.push(0x22);\nfor (var i = 0, l = s_text.length; i < l; i ++) {\n    var ascii = s_text.charCodeAt(i);\n    arr.push(ascii);\n}\narr.push(0x22);\narr.push(0xFF);\narr.push(0xFF);\narr.push(0xFF);\nmsg.payload = new Buffer(arr);\nreturn msg;","outputs":1,"noerr":0,"x":289,"y":199,"wires":[["858c79ee.44437"]]},{"id":"ef39e89d.a084d","type":"exec","z":"7a00aa0e.a9b7d4","command":"vcgencmd measure_temp","addpay":false,"append":"","useSpawn":false,"timer":"","name":"measure temp","x":347,"y":295,"wires":[["b985e249.4f6ff8"],[],[]]},{"id":"b985e249.4f6ff8","type":"function","z":"7a00aa0e.a9b7d4","name":"","func":"s_object = \"t2.txt=\";\ns_text = msg.payload;\nvar arr = [];\nfor (var i = 0, l = s_object.length; i < l; i ++) {\n    var ascii = s_object.charCodeAt(i);\n    arr.push(ascii);\n}\narr.push(0x22);\nfor (var i = 0, l = s_text.length; i < l; i ++) {\n    var ascii = s_text.charCodeAt(i);\n    arr.push(ascii);\n}\narr.push(0x22);\narr.push(0xFF);\narr.push(0xFF);\narr.push(0xFF);\nmsg.payload = new Buffer(arr);\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":286,"wires":[["858c79ee.44437"]]},{"id":"2466d4ba.b7759c","type":"serial-port","z":"7a00aa0e.a9b7d4","serialport":"/dev/ttyAMA0","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"500","bin":"bin","out":"time","addchar":false}]

Enjoy.

Another Jinx Led Matrix Control Remote

Posted on Updated on

Since I had the dashboard node installed, I wanted to test a UI remote for Jinx.

    1. In Jinx, enable the remote
    2. Select Device Type: Art-Net
    3. Addressing: Set Net to: 2
    4. Other option unchanged
    5. In Node-Red (need version0.14 or newer and node-red-dashboard installed)
    6. Copy the flow


[{"id":"f264ee64.0c53c8","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":2,"width":"2","height":"2","label":"2","color":"","icon":"","payload":"2","payloadType":"num","topic":"","x":57,"y":156.25,"wires":[["cd532d39.cf3778"]]},{"id":"b3f22389.2b6a18","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":1,"width":"2","height":"2","label":"Black","color":"","icon":"","payload":"1","payloadType":"num","topic":"","x":82,"y":92.25,"wires":[["cd532d39.cf3778"]]},{"id":"a155b275.37d848","type":"ui_slider","z":"d8e38fe3.54c4a","group":"f2202e5b.62751","order":17,"width":"8","height":"1","name":"","label":"","topic":"master","min":0,"max":"255","x":87,"y":718.75,"wires":[["ade5845c.d2f3b8"]]},{"id":"ff98fe8f.e4a4a","type":"udp out","z":"d8e38fe3.54c4a","name":"","addr":"192.168.1.108","iface":"","port":"6454","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":703.75,"y":892.75,"wires":[]},{"id":"fa673c45.a29b28","type":"inject","z":"d8e38fe3.54c4a","name":"reset","topic":"","payload":"Reset","payloadType":"str","repeat":"","crontab":"","once":true,"x":97.25,"y":779.75,"wires":[["fa95cbd.1a7c938"]]},{"id":"30659925.52ad2e","type":"debug","z":"d8e38fe3.54c4a","name":"Debug","active":true,"console":"false","complete":"payload","x":533.25,"y":777.25,"wires":[]},{"id":"fa95cbd.1a7c938","type":"function","z":"d8e38fe3.54c4a","name":"Rest General Variable","func":"// initialise data\nflow.set('scener',0);\nflow.set('scenel',0);\nflow.set('chase',0);\nflow.set('mode',0);\nflow.set('cross',0);\nflow.set('stobe',0);\nflow.set('master',0);\nreturn msg;\n","outputs":1,"noerr":0,"x":300.75,"y":778.25,"wires":[["30659925.52ad2e"]]},{"id":"694bee14.421ba8","type":"function","z":"d8e38fe3.54c4a","name":"","func":"msg.payload = new Buffer([65, 114, 116, 45, 78, 101, 116, 0, 0, 80, 0, 14, 1, 0, 0, 2, 7,0,\nflow.get('scenel'), //scene left\nflow.get('scener'), //scene right\nflow.get('chase'), //chase select\nflow.get('mode'), //crossfade mode\nflow.get('cross'), //crossfade\nflow.get('strobe'), //strobe\nflow.get('master')]); //master\nreturn msg;","outputs":1,"noerr":0,"x":475.75,"y":890.75,"wires":[["ff98fe8f.e4a4a","e8f04232.d92818"]]},{"id":"ade5845c.d2f3b8","type":"function","z":"d8e38fe3.54c4a","name":"","func":"flow.set('master',msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":271,"y":718.5,"wires":[[]]},{"id":"5efedb9a.aa4824","type":"link in","z":"d8e38fe3.54c4a","name":"send","links":["fb1b4.29fa264d","f37e9b71.b9971","5241bb21.4d20dc","ccb4bc0c.b05fc8","cbf08263.553e"],"x":109,"y":899.25,"wires":[["98493a85.c2a5a8"]]},{"id":"cd532d39.cf3778","type":"function","z":"d8e38fe3.54c4a","name":"","func":"flow.set('scenel',msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":482,"y":86.5,"wires":[["f37e9b71.b9971"]]},{"id":"f37e9b71.b9971","type":"link out","z":"d8e38fe3.54c4a","name":"","links":["5efedb9a.aa4824"],"x":602,"y":87.5,"wires":[]},{"id":"98493a85.c2a5a8","type":"delay","z":"d8e38fe3.54c4a","name":"","pauseType":"timed","timeout":"5","timeoutUnits":"seconds","rate":"11","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":307.75,"y":889.5,"wires":[["694bee14.421ba8"]]},{"id":"b3585d74.89d69","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":18,"width":"8","height":"2","label":"Set","color":"","icon":"","payload":"1","payloadType":"num","topic":"","x":150.75,"y":1046.25,"wires":[["ccb4bc0c.b05fc8"]]},{"id":"ccb4bc0c.b05fc8","type":"link out","z":"d8e38fe3.54c4a","name":"","links":["5efedb9a.aa4824"],"x":321.75,"y":1050.25,"wires":[]},{"id":"dc513104.f3d9e8","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":3,"width":"2","height":"2","label":"3","color":"","icon":"","payload":"3","payloadType":"num","topic":"","x":58.75,"y":223.75,"wires":[["cd532d39.cf3778"]]},{"id":"44e8bf8a.9d8d38","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":4,"width":"2","height":"2","label":"4","color":"","icon":"","payload":"4","payloadType":"num","topic":"","x":58.75,"y":302.75,"wires":[["cd532d39.cf3778"]]},{"id":"e47bccae.aec548","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":5,"width":"2","height":"2","label":"5","color":"","icon":"","payload":"5","payloadType":"num","topic":"","x":55,"y":381.75,"wires":[["cd532d39.cf3778"]]},{"id":"61a6eb08.247934","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":6,"width":"2","height":"2","label":"6","color":"","icon":"","payload":"6","payloadType":"num","topic":"","x":59.75,"y":451.75,"wires":[["cd532d39.cf3778"]]},{"id":"e8f04232.d92818","type":"function","z":"d8e38fe3.54c4a","name":"Rest General Variable","func":"// initialise data\nflow.set('scener',0);\nflow.set('scenel',0);\nflow.set('chase',0);\nflow.set('mode',0);\nflow.set('cross',0);\nflow.set('stobe',0);\nreturn msg;\n","outputs":1,"noerr":0,"x":700,"y":972.5,"wires":[[]]},{"id":"6ff7f13e.ed2288","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":7,"width":"2","height":"2","label":"7","color":"","icon":"","payload":"7","payloadType":"num","topic":"","x":55.75,"y":506.75,"wires":[["cd532d39.cf3778"]]},{"id":"65706999.795398","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":8,"width":"2","height":"2","label":"8","color":"","icon":"","payload":"8","payloadType":"num","topic":"","x":55,"y":558.75,"wires":[["cd532d39.cf3778"]]},{"id":"9471f773.0461a","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":9,"width":"2","height":"2","label":"9","color":"","icon":"","payload":"9","payloadType":"num","topic":"","x":55.75,"y":608.75,"wires":[["cd532d39.cf3778"]]},{"id":"6dbdf78f.8ec2a8","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":10,"width":"2","height":"2","label":"10","color":"","icon":"","payload":"10","payloadType":"num","topic":"","x":462.75,"y":199.75,"wires":[["cd532d39.cf3778"]]},{"id":"8fc02d80.773ed","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":11,"width":"2","height":"2","label":"11","color":"","icon":"","payload":"11","payloadType":"num","topic":"","x":463.75,"y":251.75,"wires":[["cd532d39.cf3778"]]},{"id":"59cfb183.f4bc5","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":12,"width":"2","height":"2","label":"12","color":"","icon":"","payload":"12","payloadType":"num","topic":"","x":462.75,"y":316.75,"wires":[["cd532d39.cf3778"]]},{"id":"cd2dccb.78414b","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":13,"width":"2","height":"2","label":"13","color":"","icon":"","payload":"13","payloadType":"num","topic":"","x":463.75,"y":384.75,"wires":[["cd532d39.cf3778"]]},{"id":"71222766.c451d8","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":14,"width":"2","height":"2","label":"14","color":"","icon":"","payload":"14","payloadType":"num","topic":"","x":463.75,"y":453.75,"wires":[["cd532d39.cf3778"]]},{"id":"fe97a913.adf248","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":15,"width":"2","height":"2","label":"15","color":"","icon":"","payload":"15","payloadType":"num","topic":"","x":460.75,"y":513.75,"wires":[["cd532d39.cf3778"]]},{"id":"59323177.facad8","type":"ui_button","z":"d8e38fe3.54c4a","name":"","group":"f2202e5b.62751","order":15,"width":"2","height":"2","label":"16","color":"","icon":"","payload":"16","payloadType":"num","topic":"","x":460.75,"y":582.5,"wires":[["cd532d39.cf3778"]]},{"id":"f2202e5b.62751","type":"ui_group","z":"","name":"Main","tab":"24e26b6f.f52bd4","order":2,"disp":false,"width":"8"},{"id":"24e26b6f.f52bd4","type":"ui_tab","z":"","name":"Remote","icon":"dashboard","order":4}]

Jinx_Remote

Node-Red Dashboard (Raspberry Pi)

Posted on Updated on

To setup Node-Red Dashboard, I started from a fresh install of Raspbian (Raspbian Jessie, May 2016)

  1. Once Raspbian is loaded, expend file system
  2. Open terminal and do an update
    sudo apt-get update
  3. reinstall Node-Red
    sudo apt-get install nodered
  4. install npm
    sudo apt-get install npm
    sudo npm i -g npm@2.x
    
  5. install dashboard node
    cd ~/.node-red
    sudo npm install node-red-dashboard
  6. Done

Node-Red

Posted on Updated on

How to install Node-Red on Ubuntu 15.10

Follow this instructions:

In terminal, run following commands

	sudo apt-get update
	sudo apt-get install nodejs
	sudo apt-get install npm
	sudo ln -s /usr/bin/nodejs /usr/bin/node
	sudo npm install -g --unsafe-perm node-red
	cd $HOME/.node-red
	sudo npm install node-red-node-serialport@0.0.5

To install other nodes, do it from the same directory /.node-red and using the command 7.

To run node-red, in terminal, launch it with the command

	sudo node-red

I am using sudo because I need the root access to serial port.