Remove noise spikes from an event data stream - v2

See the other flow of the same title for background information

http://flows.nodered.org/flow/8c31d95e0ce9b9c1c13a8a75221bd9f5

This version doesn't require the "off" signal to be exactly "0". It can wobble about up to some threshold (as it does in real life).

Sample data in this case is: 0,1,2,100,3,0,1,100,100,100,100,100

The "off" signal varies from 0-3, and the "on" signal is 100.

Uses the reset function of the trigger node to filter out short spikes above the threshold, and a switch node to differentiate noise from signal.

[{"id":"cc0ee793.910238","type":"inject","z":"dab4790.2f8c008","name":"go","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":110,"y":60,"wires":[["d3fd1b78.24af88"]]},{"id":"d3fd1b78.24af88","type":"function","z":"dab4790.2f8c008","name":"signal","func":"var signal = [0,1,2,100,3,0,1,100,100,100,100,100];\n\nfor (var i in signal)\n{\n    node.send({payload:signal[i]})\n}\n","outputs":1,"noerr":0,"x":250,"y":60,"wires":[["54adc2e9.0bd9cc"]]},{"id":"54adc2e9.0bd9cc","type":"delay","z":"dab4790.2f8c008","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":410,"y":60,"wires":[["dabce2f0.d09c18"]]},{"id":"dabce2f0.d09c18","type":"switch","z":"dab4790.2f8c008","name":"noise?","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"10","vt":"num"},{"t":"else"}],"checkall":"true","outputs":2,"x":570,"y":60,"wires":[["762ec11.b63cc4"],["c943b697.902628"]]},{"id":"c943b697.902628","type":"change","z":"dab4790.2f8c008","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":98,"wires":[["762ec11.b63cc4"]]},{"id":"762ec11.b63cc4","type":"trigger","z":"dab4790.2f8c008","op1":"1","op2":"0","op1type":"nul","op2type":"pay","duration":"2","extend":false,"units":"s","reset":"","name":"","x":854,"y":52,"wires":[["b9678c91.7aef18"]]},{"id":"b9678c91.7aef18","type":"debug","z":"dab4790.2f8c008","name":"","active":true,"console":"false","complete":"false","x":1028,"y":52,"wires":[]}]
andysc

Flow Info

created 1 year, 6 months ago

Node Types

Core
  • change (x1)
  • debug (x1)
  • delay (x1)
  • function (x1)
  • inject (x1)
  • switch (x1)
  • trigger (x1)

Tags

  • #IoT
  • #CurrentCost
  • signal
  • filter
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option