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.
Action on a function of two of the (i2c) readings?
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.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
- sketchy
- Posts: 285
- Joined: Thu Jun 28, 2012 11:37 pm
- brubell
- Learn User Page
- Posts: 2011
- Joined: Fri Jul 17, 2015 10:33 pm
Re: Action on a function of two of the (i2c) readings?
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.
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.
- sketchy
- Posts: 285
- Joined: Thu Jun 28, 2012 11:37 pm
Re: Action on a function of two of the (i2c) readings?
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.
What I am looking for are similar to Tasmota rules: https://tasmota.github.io/docs/Rules/
All the best.
- brubell
- Learn User Page
- Posts: 2011
- Joined: Fri Jul 17, 2015 10:33 pm
Re: Action on a function of two of the (i2c) readings?
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)
- sketchy
- Posts: 285
- Joined: Thu Jun 28, 2012 11:37 pm
Re: Action on a function of two of the (i2c) readings?
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;
```
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;
```
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.