Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DHT.h"
- #define DHTPIN 2
- #define DHTTYPE DHT11
- #include <Wire.h>
- #include "rgb_lcd.h"
- int NTC = A0;//NTC SKAL BRUKES I HONNINGLAGERET
- // DHT BRUKER D2
- const int B = 3975;
- rgb_lcd lcd;
- const int colorR = 50;
- const int colorG = 50;
- const int colorB = 50;
- DHT dht(DHTPIN, DHTTYPE);
- void setup() {
- Serial.begin(9600);
- dht.begin();
- pinMode(4, OUTPUT); // RØD
- pinMode(5, OUTPUT); // GRØNN
- pinMode(6, OUTPUT); // BLÅ
- lcd.begin(16, 4);
- lcd.setRGB(colorR, colorG, colorB);
- }
- void loop() {
- // NTC
- int maalinger = 0;
- maalinger = analogRead(NTC);
- Serial.print("Verdi: ");
- Serial.println(maalinger);
- float resistance = (float)(1023-maalinger)*10000/maalinger;
- float temp = 1/(log(resistance/10000)/B+1/298.15)-273.15;
- Serial.print("C :");
- Serial.println(temp, 1);
- // DHT
- int h = dht.readHumidity();
- // Read temperature as Celsius (the )
- float t = dht.readTemperature();
- // Read temperature as Fahrenheit (isFahrenheit = true)
- float f = dht.readTemperature(true);
- // Check if any reads failed and exit early (to try again).
- if (isnan(h) || isnan(t) || isnan(f)) {
- Serial.println(F("Failed to read from DHT sensor!"));
- return;}
- // Compute heat index in Fahrenheit (the default)
- float hif = dht.computeHeatIndex(f, h);
- // Compute heat index in Celsius (isFahreheit = false)
- float hic = dht.computeHeatIndex(t, h, false);
- Serial.print(F("fuktighet slyngerom: "));
- Serial.print(h);
- Serial.println(" %");
- Serial.print(F("Temperatur slyngerom: "));
- Serial.print("C: ");
- Serial.println(t, 0);
- Serial.println(" ");
- lcd.setCursor(0, 0);
- lcd.print((char)223); // dotten
- lcd.print("C:");
- lcd.print(temp, 1);
- lcd.setCursor(1, 1);
- lcd.print("fukt:");
- lcd.print(h);
- lcd.print("%");
- lcd.print(" ");
- lcd.print("C:");
- lcd.print(t, 0);
- /* diode delen
- *
- * NTC variaber honning rom
- * temperatur variabel = temp
- *
- * DHT variabler slynge rom
- * fuktighet variabel = h
- * temperature variabel = t
- *
- * slyngerom krav
- * temperature mellom 22-30 grader
- * fuktighet under 60 %
- *
- * honningrom krav
- * under 20 grader
- */
- if(temp > 20){ // temperatur honningrom
- digitalWrite(4, HIGH); //rød
- }
- else {
- digitalWrite(5, HIGH); // grønn
- }
- if(h < 60){ // fuktighet slyngerom
- digitalWrite(4, HIGH); //rød
- }
- else {
- digitalWrite(5, HIGH); // grønn
- }
- if(t < 22){ // temperatur slynge rom
- digitalWrite(6, HIGH); //blå
- }
- else if(t > 22 && t < 30){
- digitalWrite(5, HIGH); // grønn
- }
- else{
- digitalWrite(4, HIGH); // rød
- }
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement