Calculate a derivative (to see the variation of a sensor)

Hello,

I would like to activate my mechanical ventilation when I go to the shower.
In my bathroom I have a humidity sensor that goes up instantly when I take a shower.
How can I activate mechanical ventilation when I see a change in humidity?

I don’t want to trigger mechanical ventilation from a certain humidity level, but from a variation.

Thank you !!

I’m sure there’s some kinda calculus integration that does this, but what about a simple dT/dt? Pick a dt, say 30 seconds. Grab the temp each cycle and store the value in a helper or something. Then, before overwriting it with the new value each time, subtract it from the current value. If it is greater than some threshold, trigger. If not, store the current value in the helper and do it all over again next cycle. It’s hacky, but any port in a storm I say.

If you’re using node-red, you can do this all with the RBE node.

Hi @andynbaker and thanks for your answer !

Yes indeed it is the idea, my problem is how to do?

I’m sorry I forgot to specify my material !
I have a PiZigate that I use with ZHA integration.

I’m using node-red, so i’d do it with that one node. I have no idea how to best handle this with automations. You could set an automation up to reoccur and then just order the different tasks so that the value gets checked first, but I bet there’s a better way.

I find node-red handles these kinds of things very well.

I don’t know nodered. I juste checked on Google, it seems to be really good !

I’ll try tomorrow and i’ll tell you !

Thanks you !! :wink:

For the record, I too planned on turning on my vent when the humidity went up in my bathroom, but I found my sensors we’re just too noisy. Instead, I just wired up a motion sensor on my shower. Works much better now!

The trend binary sensor should do what you are after.

Set a minimum gradient just above the normal background variation. That way when the humidity increases rapidly the binary sensor will turn on.

1 Like

Hello @tom_l
Nice, it’s exactly what i want, thanks you !

@andynbaker
Node red seems to be a little bit complicated, but i’ll try to put all my scripts on it, i think it’s better !

Thanks !

1 Like

Hello @tom_l

When would we use trend sensor and when would we use a combination of derivative and threshold sensor. Both as per my reading gives us “trends”. Is one better than the other?
Thanks!

@Puneit_Thukral (I know your comment was a while ago).

Trend and derivative are in a way similar, but Frend can take more than 2 samples and fit a trend line, while a derivative takes only two samples a given time apart. So Trend with more than 2 samples should be more noise resistant than Derivative and smoothen harsh variations.

3 Likes