Рет қаралды 5,473
Node-RED code for controlling relays is "rb.gy/ndifhp"
Node-RED code for visualising sensor output is "rb.gy/a9nm7p"
"Import" these codes from "Node-Red flow editor". To start the flow editor, after you complete installation of Node.js and Node-Red softwares, type "Node-RED" in your terminal window. Once Node-Red server is running, type "127.0.0.1:1880" in your browser, e.g. chrome, and press enter to start the 'Node-Red Flow Editor". Select the correct serial port in each of the codes. See video to know the details.
Code used in "Function" for extracting five entries from a row is
var outputMsgs = [];
var values = msg.payload.trim().split(",");
for(var v in values) {
outputMsgs.push({payload:values[v]})
}
return outputMsgs;