Compare commits
2 Commits
ea207f727a
...
724af2a3db
Author | SHA1 | Date | |
---|---|---|---|
724af2a3db | |||
da5d42f72c |
@ -20,11 +20,11 @@
|
|||||||
#define TOPIC_ABHU TOPIC_BASE "abs_humidity"
|
#define TOPIC_ABHU TOPIC_BASE "abs_humidity"
|
||||||
#define TOPIC_AIRQ TOPIC_BASE "air_gas"
|
#define TOPIC_AIRQ TOPIC_BASE "air_gas"
|
||||||
|
|
||||||
#define DIFF_TEMP 0.3 // sensor has only 0.5°C accuracy, triggering on less is ludicrous
|
#define DIFF_TEMP 0.5 // sensor has only 0.5°C accuracy, triggering on less is ludicrous
|
||||||
#define DIFF_HMID 1.5 // humidity doesn't change that much anyways
|
#define DIFF_HMID 2.5 // humidity doesn't change that much anyways
|
||||||
#define DIFF_HEAT 0.3 // this one's actually quite active
|
#define DIFF_HEAT 0.5 // this one's actually quite active
|
||||||
#define DIFF_ABHU 0.2 // small changes mean quite something
|
#define DIFF_ABHU 0.5 // small changes mean quite something
|
||||||
#define DIFF_AIRQ 3 // this one changes in integers
|
#define DIFF_AIRQ 5 // this one changes in integers
|
||||||
|
|
||||||
float hmid = 0; // humidity
|
float hmid = 0; // humidity
|
||||||
float hmid_r = 0; // humidity
|
float hmid_r = 0; // humidity
|
||||||
@ -105,7 +105,7 @@ bool checkVariation(float newValue, float prevValue, float maxDiff) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool checkPlausibility(float newValue, float prevValue, float maxDiff) {
|
bool checkPlausibility(float newValue, float prevValue, float maxDiff) {
|
||||||
return (newValue < prevValue + (maxDiff * 10) || newValue > prevValue - (maxDiff * 10) || lastVal == 0.0);
|
return (newValue < prevValue + (maxDiff * 10) || newValue > prevValue - (maxDiff * 10) || prevValue == 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
long lastMsg = 0;
|
long lastMsg = 0;
|
||||||
@ -119,9 +119,6 @@ bool publish (String desc, char *topic, float val, float &lastVal, float diff, b
|
|||||||
if (checkVariation(val, lastVal, diff) or force) {
|
if (checkVariation(val, lastVal, diff) or force) {
|
||||||
Serial.println("Sufficient variation on " + desc + ": " + String(val).c_str());
|
Serial.println("Sufficient variation on " + desc + ": " + String(val).c_str());
|
||||||
if (checkPlausibility(val, lastVal, diff) or force) {
|
if (checkPlausibility(val, lastVal, diff) or force) {
|
||||||
if (lastVal != 0.0) {
|
|
||||||
val = (lastVal*2 + val) / 3; // slight averaging
|
|
||||||
}
|
|
||||||
Serial.println("Value " + desc + " averaged and published : " + String(val).c_str());
|
Serial.println("Value " + desc + " averaged and published : " + String(val).c_str());
|
||||||
client.publish(topic, String(val).c_str(), true);
|
client.publish(topic, String(val).c_str(), true);
|
||||||
ret = true;
|
ret = true;
|
||||||
@ -186,7 +183,7 @@ void loop() {
|
|||||||
Serial.println("ERR: Sensor could not be identified");
|
Serial.println("ERR: Sensor could not be identified");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isnan(hmid) && !isnan(temp)){
|
if (!isnan(hmid) && !isnan(temp) && hmid != 0.0 && temp != 0.0){
|
||||||
abhu = (6.112 * ( pow(2.71828, ((17.67 * temp) / (temp + 243.5))) * hmid * 2.1674)) / (273.15 + temp);
|
abhu = (6.112 * ( pow(2.71828, ((17.67 * temp) / (temp + 243.5))) * hmid * 2.1674)) / (273.15 + temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user