Smoothing a value and check for extrems

Hello friends.

Today i am testing a current HAt to measure my 4-20 mA signal. For this i am using the waveshare current HAt and my ROCKPI E, where my Node-red instance is running.

To read the current hat i am using this node: node-red-contrib-easybotics-ina219-sensor

Sadly the signal is not very accurate. When i am using the HAT with my ESP32 i get clean values. Cant figure out what the problem is. Anyway:

I try to live with it, since i am depning on my ROCKPI E (until now), i try to smooth the value. I know that there is a smooth-node.

Problem 1: I could live with the 4-20 mA signal, if there wouldnt be every 7 sec. a very bad signal.
Problem 2: If i create a function, where, lets say for example, every value should be ignored, that is +- 20% from a average away, i face the problem, that if my signal is changing, this "new" values will also be ignored, because this "true" new values are also to much away from my average value.

Has someone an idea how to get this to work?

Thank you

Have you tried the range node to limit bad readings.

[{"id":"dc1e8f6e7786190a","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":150,"y":120,"wires":[["0af72d14e65f4525"]]},{"id":"0af72d14e65f4525","type":"range","z":"65617ffeb779f51c","minin":"4","maxin":"20","minout":"4","maxout":"20","action":"clamp","round":false,"property":"payload","name":"","x":370,"y":120,"wires":[["fa62bcc9fa190dcf"]]},{"id":"882508cffe9e1877","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4","payloadType":"num","x":130,"y":180,"wires":[["0af72d14e65f4525"]]},{"id":"34899b1448d439bd","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20","payloadType":"num","x":130,"y":240,"wires":[["0af72d14e65f4525"]]},{"id":"a113aa9f10e2d4e8","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"21","payloadType":"num","x":130,"y":300,"wires":[["0af72d14e65f4525"]]},{"id":"fa62bcc9fa190dcf","type":"debug","z":"65617ffeb779f51c","name":"debug 337","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":120,"wires":[]}]

A post was split to a new topic: Prevent outlier reading going to Influx

Thank you for the answer

The problem is, that the outliners are in the 4-20 range. I should get the value, lets say 5.5. I will get:

This seven is a outliner. like i meantioned above. the problem is, that the input can change realy fast. So i am kinda now in a wired situation, how to kill this outliners.

thank you

How about the filter node then.

[{"id":"fdf121a121fc1e30","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[5.5, 5.4, 5.5, 5.4, 5.4, 7.0, 5.5, 5.4, 5.5, 5.4, 5.4]","payloadType":"json","x":270,"y":60,"wires":[["713a1aa8038d0978"]]},{"id":"713a1aa8038d0978","type":"split","z":"b9860b4b9de8c8da","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":410,"y":60,"wires":[["3faba304ebecd18c"]]},{"id":"3faba304ebecd18c","type":"rbe","z":"b9860b4b9de8c8da","name":"","func":"narrowband","gap":"5%","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":530,"y":100,"wires":[["825b1902aba22bc3"]]},{"id":"825b1902aba22bc3","type":"debug","z":"b9860b4b9de8c8da","name":"debug 338","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":100,"wires":[]}]

How do you know, in that example, that 7 is an outlier?

1 Like


@colin0031 Because i can control the input for testing.

I can send a 4-20 mA signal, where i know that it is a 5.5 mA signal. I am 100% sure that the input
isnt causing this outliners. It is a receiver thing.

My guess is, that it is a I2C range setting thing.
A littile bachground: I am using a WAVESHARE current loop, that is connected with my RockpiE to measure my 4-20 mA signal. On my ROCKpiE runs NODE-RED to measure the signal. For this i am usining the node-red-contrib-easybotics-ina219-sensor (node) - Node-RED node
There i get this outliners.

Strange is. When i use an ESP32 instead of RockpiE and use Ardunio code, the signal is very constant. Since i can set ranges in my ardunio code, to increase the accuracy of my WAVESHRE, i think that the NODE from easybotics just uses a very roughe range by default. Unfortunly i cant manipulate the range with this node. For this project i depend on my RockpiE. And since i have no idea how else to read the signal of my WAVESHARE 4-20- current module with node-red, i have to live with that.

@E1cid thank you
Thank you. But the problem remains. What if my input signal is changing? Then this "true" value would be ignored

The small data set you supplied the signal is changing.

So please better explain the input signal how it changes. It is impossible to help with out all the info, drip feeding us relevant information is not helpful. We need to work out how to identify an outlier, until we can do that we can not remove it. Maybe show a real data (fairly large) set and then identify the outliers and then we may be able to suggest a strategy.

I meant how would you know that it is spurious if you saw that sequence come in?

I suggest using a receiver that works.

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