Compare commits
No commits in common. "414123c87a68cdda2a6eb869a0eacd438ed500c2" and "3ab22b2e94d7f7495f2792ba27dbdbed6b7d660b" have entirely different histories.
414123c87a
...
3ab22b2e94
@ -18,18 +18,14 @@
|
|||||||
#define TOPIC_HMID TOPIC_BASE "humidity"
|
#define TOPIC_HMID TOPIC_BASE "humidity"
|
||||||
#define TOPIC_HEAT TOPIC_BASE "heat_index"
|
#define TOPIC_HEAT TOPIC_BASE "heat_index"
|
||||||
#define TOPIC_AIRQ TOPIC_BASE "air_gas"
|
#define TOPIC_AIRQ TOPIC_BASE "air_gas"
|
||||||
#define TOPIC_ABHU TOPIC_BASE "abs_humidity"
|
|
||||||
|
|
||||||
#define DIFF_TEMP 0.3 // sensor has only 0.5°C accuracy, triggering on less is ludicrous
|
#define DIFF_TEMP 0.3 // 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.2 // this one's actually quite active
|
#define DIFF_HEAT 0.2 // this one's actually quite active
|
||||||
#define DIFF_AIRQ 3 // this one hardly changes
|
#define DIFF_AIRQ 3 // this one hardly changes
|
||||||
#define DIFF_ABHU 0.1 // small changes mean quite something
|
|
||||||
|
|
||||||
float hmid = 0; // humidity
|
float hmid = 0; // humidity
|
||||||
float hmid_r = 0; // humidity
|
float hmid_r = 0; // humidity
|
||||||
float abhu = 0; // absolute humidity
|
|
||||||
float abhu_r = 0; // absolute humidity
|
|
||||||
float temp = 0; // temperature
|
float temp = 0; // temperature
|
||||||
float temp_r = 0; // temperature
|
float temp_r = 0; // temperature
|
||||||
float heat = 0; // heat index
|
float heat = 0; // heat index
|
||||||
@ -126,6 +122,8 @@ bool publish (String desc, char *topic, float val, float &lastVal, float diff, b
|
|||||||
Serial.print("** ERROR: Value out of bounds, not published. Last value :");
|
Serial.print("** ERROR: Value out of bounds, not published. Last value :");
|
||||||
Serial.println(String(lastVal).c_str());
|
Serial.println(String(lastVal).c_str());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Serial.println("Not enough variation for a publication");
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -183,10 +181,6 @@ void loop() {
|
|||||||
Serial.println("ERR: Sensor could not be identified");
|
Serial.println("ERR: Sensor could not be identified");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isnan(hmid) && !isnan(temp)){
|
|
||||||
abhu = (6.112 * ( pow(2.71828, ((17.67 * temp) / (temp + 243.5))) * hmid * 2.1674)) / (273.15 + temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
published = false;
|
published = false;
|
||||||
if (lastSent > FORCE_PERIOD) {
|
if (lastSent > FORCE_PERIOD) {
|
||||||
Serial.println(F("Forcing a publish of all values"));
|
Serial.println(F("Forcing a publish of all values"));
|
||||||
@ -198,7 +192,6 @@ void loop() {
|
|||||||
published += publish("humidity", TOPIC_HMID, hmid, hmid_r, DIFF_HMID, forcePublish);
|
published += publish("humidity", TOPIC_HMID, hmid, hmid_r, DIFF_HMID, forcePublish);
|
||||||
published += publish("heat index", TOPIC_HEAT, heat, heat_r, DIFF_HEAT, forcePublish);
|
published += publish("heat index", TOPIC_HEAT, heat, heat_r, DIFF_HEAT, forcePublish);
|
||||||
published += publish("air quality", TOPIC_AIRQ, airq, airq_r, DIFF_AIRQ, forcePublish);
|
published += publish("air quality", TOPIC_AIRQ, airq, airq_r, DIFF_AIRQ, forcePublish);
|
||||||
published += publish("absolute humidity", TOPIC_ABHU, abhu, abhu_r, DIFF_ABHU, forcePublish);
|
|
||||||
|
|
||||||
if (published == false) {
|
if (published == false) {
|
||||||
lastSent = lastSent + 1;
|
lastSent = lastSent + 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user