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

  1. Daniel Alich
    Daniel Alich Member Staff Member
    252_1511880916_Mission 7 – Weather Sta
    You will need to install the DTH11 library for this program to compile and upload correctly.  It seems these files keep moving and there are several avilable, however I'll place a download link here for the .ZIP file.

    DHT11.Zip Download Link
     
    The install the .zip file library
    In the top menu select:  Sketch => Include Library => Add .ZIP Library
    Navigate to your "Downloads" folder and select the DHTLib.zip file that was downloaded using the link above.


    #include <LiquidCrystal.h>
    #include <DHT.h> // Sometimes you will see quotes "DHT.h" instead of braces.
    // Quotes will tell the software to include from the same program folder
    // while <> will indicate to use the "library" folder in your software
    #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
    Raul Lara likes this.
  2. (You must log in or sign up to post here)

Report Post

Write your reason

Log in | Sign up
Terms & Conditions!
Help!