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

  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. Josh Rawls
    Josh Rawls Member St. Louis, MO
    This code isn't working for me. I believe it has something to do with the DHT library. Here's the errors I'm getting. I used the libraries linked above and also the latest version from GIThub (https://github.com/RobTillaart/Arduino/blob/master/libraries/DHTlib/dht.h).

    Arduino: 1.8.5 (Mac OS X), Board: "Arduino Nano, ATmega328P"

    /Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/joshrawls/Documents/Arduino/libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10805 -build-path /var/folders/x4/k8fqjwfs42j9l_3_9qh1d9gw0000gp/T/arduino_build_862793 -warnings=none -build-cache /var/folders/x4/k8fqjwfs42j9l_3_9qh1d9gw0000gp/T/arduino_cache_207134 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -verbose /Users/joshrawls/Documents/Arduino/Lesson_7_-_Weather_Station_-_2/Lesson_7_-_Weather_Station_-_2.ino
    /Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/joshrawls/Documents/Arduino/libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10805 -build-path /var/folders/x4/k8fqjwfs42j9l_3_9qh1d9gw0000gp/T/arduino_build_862793 -warnings=none -build-cache /var/folders/x4/k8fqjwfs42j9l_3_9qh1d9gw0000gp/T/arduino_cache_207134 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -verbose /Users/joshrawls/Documents/Arduino/Lesson_7_-_Weather_Station_-_2/Lesson_7_-_Weather_Station_-_2.ino
    Using board 'nano' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr
    Using core 'arduino' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr
    Detecting libraries used...
    "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/eightanaloginputs" "/var/folders/x4/k8fqjwfs42j9l_3_9qh1d9gw0000gp/T/arduino_build_862793/sketch/Lesson_7_-_Weather_Station_-_2.ino.cpp" -o "/dev/null"
    "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/eightanaloginputs" "-I/Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal/src" "/var/folders/x4/k8fqjwfs42j9l_3_9qh1d9gw0000gp/T/arduino_build_862793/sketch/Lesson_7_-_Weather_Station_-_2.ino.cpp" -o "/dev/null"
    "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/eightanaloginputs" "-I/Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal/src" "-I/Users/joshrawls/Documents/Arduino/libraries/DHTLib" "/var/folders/x4/k8fqjwfs42j9l_3_9qh1d9gw0000gp/T/arduino_build_862793/sketch/Lesson_7_-_Weather_Station_-_2.ino.cpp" -o "/dev/null"
    "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/eightanaloginputs" "-I/Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal/src" "-I/Users/joshrawls/Documents/Arduino/libraries/DHTLib" "/Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal/src/LiquidCrystal.cpp" -o "/dev/null"
    "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/eightanaloginputs" "-I/Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal/src" "-I/Users/joshrawls/Documents/Arduino/libraries/DHTLib" "/Users/joshrawls/Documents/Arduino/libraries/DHTLib/dht.cpp" -o "/dev/null"
    Generating function prototypes...
    "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/eightanaloginputs" "-I/Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal/src" "-I/Users/joshrawls/Documents/Arduino/libraries/DHTLib" "/var/folders/x4/k8fqjwfs42j9l_3_9qh1d9gw0000gp/T/arduino_build_862793/sketch/Lesson_7_-_Weather_Station_-_2.ino.cpp" -o "/var/folders/x4/k8fqjwfs42j9l_3_9qh1d9gw0000gp/T/arduino_build_862793/preproc/ctags_target_for_gcc_minus_e.cpp"
    "/Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/var/folders/x4/k8fqjwfs42j9l_3_9qh1d9gw0000gp/T/arduino_build_862793/preproc/ctags_target_for_gcc_minus_e.cpp"
    Compiling sketch...
    "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/eightanaloginputs" "-I/Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal/src" "-I/Users/joshrawls/Documents/Arduino/libraries/DHTLib" "/var/folders/x4/k8fqjwfs42j9l_3_9qh1d9gw0000gp/T/arduino_build_862793/sketch/Lesson_7_-_Weather_Station_-_2.ino.cpp" -o "/var/folders/x4/k8fqjwfs42j9l_3_9qh1d9gw0000gp/T/arduino_build_862793/sketch/Lesson_7_-_Weather_Station_-_2.ino.cpp.o"
    Lesson_7_-_Weather_Station_-_2:9: error: 'DHT' does not name a type
    DHT dht(DHTPIN, DHTTYPE);
    ^
    /Users/joshrawls/Documents/Arduino/Lesson_7_-_Weather_Station_-_2/Lesson_7_-_Weather_Station_-_2.ino: In function 'void setup()':
    Lesson_7_-_Weather_Station_-_2:12: error: expected unqualified-id before '.' token
    dht.begin();
    ^
    /Users/joshrawls/Documents/Arduino/Lesson_7_-_Weather_Station_-_2/Lesson_7_-_Weather_Station_-_2.ino: In function 'void loop()':
    Lesson_7_-_Weather_Station_-_2:17: error: expected primary-expression before '.' token
    float h = dht.readHumidity();
    ^
    Lesson_7_-_Weather_Station_-_2:18: error: expected primary-expression before '.' token
    float t = dht.readTemperature();
    ^
    Using library LiquidCrystal at version 1.0.7 in folder: /Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal
    Using library DHTLib in folder: /Users/joshrawls/Documents/Arduino/libraries/DHTLib (legacy)
    exit status 1
    'DHT' does not name a type
    Josh Rawls, 2018-08-01 01:31:42 -04:00
  3. Isaac Allen
    Isaac Allen Member
    I recently used the download link above and it worked fine.  (See post below)

    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.

    It does appear to be a probelm with DHT libary.  I'll look into it and see if there were changed made.  MACs often have other permissions or groups.  I've not used them but I'll see if I can find somehting.




    Isaac Allen, 2018-08-01 08:24:31 -04:00
  4. Josh Rawls
    Josh Rawls Member St. Louis, MO
    Thanks for looking into it. I copied and pasted everything and installed the library from that link and followed the instructions to install. Those are the errors I recieved. I am just learining programming so I'm not sure how to troubleshoot this very far. Thanks again!
    Josh Rawls, 2018-08-01 08:44:44 -04:00
  5. Isaac Allen
    Isaac Allen Member
    Look at your code (Line 9?).  remove the (DHTPIN, DHTTYPE) and info after the DHT setting.   

    dht DHT;

    This seems to be the line casuign the issues in your code.  saw it done this wany in a similar project listed here.

    http://duinokit.com/store/showandtell/topic/2-data-logger-temperature-humidity-and-light-level.html
    Isaac Allen, 2018-08-01 09:58:50 -04:00
  6. Josh Rawls
    Josh Rawls Member St. Louis, MO
    OK, it needed more than just that one change, which makes me suspect that maybe the library in your donwload link has changed from what you used to code with originally.

    Anyways, I got it all working as far as the code goes. However I'm getting a timeout error trying to read the DHT11 chip. The display shows 0.00% humidity and 32º for temperature and it never changes. Do I possibly have a defective chip?
    Josh Rawls, 2018-08-02 18:35:13 -04:00
  7. (You must log in or sign up to post here)

Report Post

Write your reason

Log in | Sign up
Terms & Conditions!
Help!