projekte:schimmelsensor
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende ÜberarbeitungNächste ÜberarbeitungBeide Seiten der Revision | ||
projekte:schimmelsensor [2017-01-16 20:55] – angelegt gamecompiler | projekte:schimmelsensor [2017-01-16 20:57] – gamecompiler | ||
---|---|---|---|
Zeile 16: | Zeile 16: | ||
==== CODE ==== | ==== CODE ==== | ||
+ | <code c> | ||
+ | //SENSOR | ||
+ | #include < | ||
+ | #include < | ||
- | <source lang="php"> | + | AM2320 th; |
- | <?php | + | |
- | | + | //DISPLAY |
- | ?> | + | # |
- | HTML-Text | + | LiquidCrystal lcd(12, 11, 5, 4, 3, 2); |
- | <? | + | |
- | echo $v; | + | // |
- | ?> | + | // |
- | </source> | + | //Vielen Dank an den Wetterochsen für seine nahezu perfekte Annäherung zu berechnung des Taupunktes. |
+ | |||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(9600); | ||
+ | Wire.begin(); | ||
+ | Serial.print("Start"); | ||
+ | | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print(" | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print(" | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print(" | ||
+ | lcd.setCursor(0, | ||
+ | lcd.print(" | ||
+ | |||
+ | } | ||
+ | |||
+ | unsigned long previousMillis = 0; | ||
+ | void loop() { | ||
+ | if (millis() - previousMillis >= 1000) { | ||
+ | | ||
+ | switch(th.Read()) { | ||
+ | case 2: | ||
+ | Serial.println("CRC failed"); | ||
+ | break; | ||
+ | case 1: | ||
+ | Serial.println(" | ||
+ | break; | ||
+ | case 0: | ||
+ | Serial.print(" | ||
+ | Serial.print(th.h); | ||
+ | lcd.setCursor(14, | ||
+ | lcd.print(th.h); | ||
+ | |||
+ | |||
+ | |||
+ | Serial.print(" | ||
+ | Serial.print(th.t); | ||
+ | Serial.println(" | ||
+ | |||
+ | if(th.t >= 0) { | ||
+ | lcd.setCursor(13, | ||
+ | lcd.print(" | ||
+ | lcd.setCursor(14, | ||
+ | lcd.print(th.t); | ||
+ | } | ||
+ | else { | ||
+ | lcd.setCursor(13, | ||
+ | lcd.print(th.t); | ||
+ | } | ||
+ | |||
+ | |||
+ | double T = th.t; | ||
+ | double r = th.h; | ||
+ | double a = 0; | ||
+ | double b = 0; | ||
+ | |||
+ | if(T >= 0) { | ||
+ | a = 7.5; | ||
+ | b = 237.3; | ||
+ | } | ||
+ | else { | ||
+ | a = 7.6; | ||
+ | b = 240.7; | ||
+ | } | ||
+ | double SDD = 6.1078 * pow(10, | ||
+ | double DD = r/100 * SDD; | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | double TK = T + 273.15; | ||
+ | double mw = 18.016; //Molekulargewicht | ||
+ | | ||
+ | double AF = pow(10,5) * mw / R * DD / TK; | ||
+ | lcd.setCursor(14, | ||
+ | lcd.print(AF); | ||
+ | |||
+ | if(AF >= 0) { | ||
+ | lcd.setCursor(13, | ||
+ | lcd.print(" | ||
+ | lcd.setCursor(14, | ||
+ | lcd.print(AF); | ||
+ | } | ||
+ | else { | ||
+ | lcd.setCursor(13, | ||
+ | lcd.print(AF); | ||
+ | } | ||
+ | |||
+ | lcd.setCursor(19, | ||
+ | lcd.print((char)223); | ||
+ | lcd.setCursor(19, | ||
+ | lcd.print((char)223); | ||
+ | lcd.setCursor(19, | ||
+ | lcd.print(" | ||
+ | lcd.setCursor(19, | ||
+ | lcd.print((char)223); | ||
+ | break; | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | } | ||
+ | </code> | ||