Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // delta max = 0.6544 wrt dewPoint()
- // 6.9 x faster than dewPoint()
- // reference: http://en.wikipedia.org/wiki/Dew_point
- double dewPointFast(double celsius, double humidity)
- {
- double a = 17.271;
- double b = 237.7;
- double temp = (a * celsius) / (b + celsius) + log(humidity * 0.01);
- double Td = (b * temp) / (a - temp);
- return Td;
- }
- int desiredCoolingIthoSpeed(float t, float h, float dp, float buitent, float buitenh, float buitendp) {
- // called if (t > 20.0 || (t > 19.0 && buitent > 24.0))
- // only on extreme humidity we run when the outside temp is higher
- if ((h > 65.0 && dp > (buitendp+2.0))
- || (h > 75.0 && dp > (buitendp+1.0))) {
- Serial.println("it's hot, but it so humid that we still want to dry..");
- return 1;
- }
- if (buitent < (t-3.0)) {
- // buiten 3 graden koeler
- if (t > 22.0 && (buitent < 18.0) && buitendp <= dp) {
- Serial.println("Extreme cooling (4 degrees) and also drying, use 2!");
- return 2;
- }
- Serial.println("Normal cooling");
- return 1;
- }
- Serial.println("Nothing to cool, default return 0");
- return 0;
- }
- int desiredDryingIthoSpeed(float t, float h, float dp, float buitent, float buitenh, float buitendp) {
- // by default we send medium
- if (dp - buitendp > 5.0) {
- // buiten veeel droger, maar droger trekken dan 45 heeft echt geen zin
- if (h > 57.0) {
- Serial.println("Much drier outside, h>57 inside, return 2");
- return 2;
- } else if (h < 45.0) {
- Serial.println("Much drier outside, but dry enough inside (h<45), return 0");
- return 0;
- } else {
- Serial.println("Much drier outside, return 1");
- return 1;
- }
- } else if (dp - buitendp > 2.0) {
- // buiten iets droger dan binnen
- if (h > 65.0) {
- Serial.println("Drier outside, h>65 return 2");
- return 2;
- } else if (h < 55.0) {
- Serial.println("Drier outside, h<52 return 0");
- return 0;
- } else {
- Serial.println("Drier outside, return 1");
- return 1;
- }
- } else if (dp - buitendp > 1.0) {
- // buiten marginaal droger dan binnen
- if (h > 75.0) {
- Serial.println("Slightly drier outside, h>75 return 2");
- return 2;
- } else if (h < 62.0) {
- Serial.println("Slightly drier outside, h<62 return 0");
- return 0;
- } else {
- Serial.println("Slightly drier outside, return 1");
- return 1;
- }
- } else if (dp - buitendp > 0.1) {
- if (h > 80.0) {
- Serial.println("Hardly drier outside, h>80 return 2");
- return 2;
- } else if (h < 70.0) {
- Serial.println("Hardly drier outside, h<70 return 0");
- return 0;
- } else {
- Serial.println("Hardly drier outside, return 1");
- return 1;
- }
- } else {
- Serial.println("Wetter or equal outside, return 0");
- // buiten gelijk of natter, dan doen we time based ventilatie
- // en dus niks op basis van de vochtigheid
- return 0;
- }
- Serial.println("default, return 1");
- return 1;
- }
- int desiredIthoSpeed(float t, float h, float dp, float buitent, float buitenh, float buitendp) {
- // it seems that this particular sesnor thinks it is pretty cool
- if (t > 20.5 || (t > 19.0 && buitent > 24.0)) {
- desiredCoolingIthoSpeed(t,h,dp,buitent,buitenh,buitendp);
- } else {
- desiredDryingIthoSpeed(t,h,dp,buitent,buitenh,buitendp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement