Action on a function of two of the (i2c) readings?

adafruit.io wippersnapper BETA support, discussions, and more!

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Locked
User avatar
sketchy
 
Posts: 285
Joined: Thu Jun 28, 2012 11:37 pm

Action on a function of two of the (i2c) readings?

Post by sketchy »

Hello,
I wish to send my cp app an mqtt message from Wippersnapper when a calculation based on the temperature and humidity of the scd40 is a certain amount. That is, an action based on a function which includes two of the properties of a component (like the scd40).

Is that possible?

If not, could I do something like write an i2c mock driver that can get the two readings?

Thank you.

User avatar
brubell
Learn User Page
 
Posts: 2010
Joined: Fri Jul 17, 2015 10:33 pm

Re: Action on a function of two of the (i2c) readings?

Post by brubell »

Adafruit IO does not support actions comparing values on more than one feed (ie: humidity AND temperature from the SCD40).

As a workaround (and if you do not need a strict "AND" comparison) - you could create two actions, one to monitor the temperature feed, and one for humidity. Both would publish out to a feed (or feeds) subscribed to by the cp app.


I can add an issue to our internal tracker for this feature if this is not what you're looking for.

User avatar
sketchy
 
Posts: 285
Joined: Thu Jun 28, 2012 11:37 pm

Re: Action on a function of two of the (i2c) readings?

Post by sketchy »

Thank you. What you advise does not meet my needs. Also, another challenge is I need a reading from another sensor to finish the function.

What I am looking for are similar to Tasmota rules: https://tasmota.github.io/docs/Rules/

All the best.

User avatar
brubell
Learn User Page
 
Posts: 2010
Joined: Fri Jul 17, 2015 10:33 pm

Re: Action on a function of two of the (i2c) readings?

Post by brubell »

What does the function look like exactly? It'll give me a better idea of what we're working with here (and if its even possible)

User avatar
sketchy
 
Posts: 285
Joined: Thu Jun 28, 2012 11:37 pm

Re: Action on a function of two of the (i2c) readings?

Post by sketchy »

Thank you for your reply!
This is the code I wrote in node-red:
```
var air_T = global.get("temperature");
/* Assume leaf temp is 2 degrees F less */
var leaf_T = air_T - 2;
var RH = global.get("humidity");

/* see https://www.questclimate.com/vapor-pres ... tages-vpd/ */
leaf_vpd = 3.386*(Math.exp(17.863-9621/(leaf_T+460))-((RH/100)*Math.exp(17.863-9621/(air_T+460))));
msg.payload = Number(leaf_vpd.toFixed(2));
msg.topic = "vpd"
flow.set("vpd",msg.payload)
return msg;
```

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Adafruit IO Wippersnapper Beta”