Mission 7 - Weather Station
 DuinoKit Essentials   Started by Daniel Alich   2017-06-27 21:39:52 -04:00   Comments: 1    Viewed: 350

  1. Daniel Alich
    Daniel Alich Member Staff Member
    #include <LiquidCrystal.h>
    #include "DHT.h"
    #define DHTPIN 8 // pin DHT is connected
    LiquidCrystal lcd(A5, A4, A3, A2, A1, A0);
    #define DHTTYPE DHT11

    DHT dht(DHTPIN, DHTTYPE);
    void setup() {
    dht.begin();
    lcd.begin(16, 2);
    }
    void loop() {
    float h = dht.readHumidity();
    float t = dht.readTemperature();
    t = t* 9/5 + 32;
    if (isnan(t) || isnan(h)) {
    lcd.setCursor(0, 0);
    lcd.print("Failed to read from DHT");
    //Serial.println("Failed to read from DHT");
    } else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Humidity: ");
    lcd.print(h);
    lcd.print("%");
    lcd.setCursor(0, 1);
    lcd.print("Temp: ");
    lcd.print(t);
    lcd.print(" f");
    delay(1000);
    // Serial.print("Humidity: ");
    // Serial.print(h);
    // Serial.print(" %t");
    // Serial.print("Temperature: ");
    // Serial.print(t);
    // Serial.println(" *C");
    }
    }
    Daniel Alich, 2017-06-27 21:39:52 -04:00
  2. (You must log in or sign up to post here)

Report Post

Write your reason

Log in | Sign up
Terms & Conditions!
Help!