DHT11 on NEO

Discussion in 'UDOO NEO' started by Marina, Mar 21, 2018.

  1. Marina

    Marina New Member

    Joined:
    Mar 21, 2018
    Messages:
    3
    Likes Received:
    0
    Hello , i ve had some issues on making the meteorological station of official udoo tutorials . I followed step by step the tutorial but an error seems to show up everytime...the error is on the code ..I ve tried downloading the newest version of the Arduino IDE (1.8.5) same error occured .....the error as shown on the compiler ( its not the udoo but that seems to be happening during compiling) The code is :
    Code:
    #include <dht11.h>
    
    dht11 DHT11;
    
    #define DHT11PIN 13
    int led_hum = 12;
    int led_temp = 11;
    
    void setup() {
      // put your setup code here, to run once:
      delay(5000);
      Serial.begin(9600);
      Serial.println("UDOO & DHT11 - TEST PROGRAM By Alessandro Paghi");
      Serial.println("Humidity (%)\tTemperature (C)\tLed_Hum\t\tLed_Temp");
      pinMode(led_hum,OUTPUT);
      pinMode(led_temp,OUTPUT);
     
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
      DHT11.read(DHT11PIN);
      Serial.print(DHT11.humidity);
      Serial.print("\t\t");
      Serial.print(DHT11.temperature);
      Serial.print("\t\t");
      if(DHT11.humidity>45)
      {
        digitalWrite(led_hum,HIGH);
        Serial.print("ON\t\t");
      }
      else
      {
        digitalWrite(led_hum,LOW);
        Serial.print("OFF\t\t");
      }
      if(DHT11.temperature>23)
      {
        digitalWrite(led_temp,HIGH);
        Serial.println("ON");
      }
      else
      {
        digitalWrite(led_temp,LOW);
        Serial.println("OFF");
      }
      delay(2000);
    }
    sketch_jan16a:7: error: expected unqualified-id before 'if'
    sketch_jan16a:11: error: expected unqualified-id before 'else'
    sketch_jan16a:13: error: expected unqualified-id before numeric constant
    In file included from /usr/share/arduino/hardware/UDOO/solox/variants/udooneo/Arduino.h:41:0,
    from /home/udooer/Arduino/libraries/DHT11/dht11.h:20,
    from sketch_jan16a.ino:1:
    sketch_jan16a.ino: In function 'void setup()':
    /usr/share/arduino/hardware/UDOO/solox/variants/udooneo/wiring_constants.h:30:16: error: expected unqualified-id before numeric constant
    #define OUTPUT 0x1
    ^
    sketch_jan16a.ino:22:20: note: in expansion of macro 'OUTPUT'
    sketch_jan16a.ino: In function 'void loop()':
    sketch_jan16a:30: error: 'class dht11' has no member named 'teperature'
    In file included from /usr/share/arduino/hardware/UDOO/solox/variants/udooneo/Arduino.h:41:0,
    from /home/udooer/Arduino/libraries/DHT11/dht11.h:20,
    from sketch_jan16a.ino:1:
    /usr/share/arduino/hardware/UDOO/solox/variants/udooneo/wiring_constants.h:26:14: error: expected unqualified-id before numeric constant
    #define HIGH 0x1
    ^
    sketch_jan16a.ino:34:26: note: in expansion of macro 'HIGH'
    /usr/share/arduino/hardware/UDOO/solox/variants/udooneo/wiring_constants.h:27:14: error: expected unqualified-id before numeric constant
    #define LOW 0x0
    ^
    sketch_jan16a.ino:37:28: note: in expansion of macro 'LOW'
    /usr/share/arduino/hardware/UDOO/solox/variants/udooneo/wiring_constants.h:26:14: error: expected unqualified-id before numeric constant
    #define HIGH 0x1
    ^
    sketch_jan16a.ino:41:27: note: in expansion of macro 'HIGH'
    /usr/share/arduino/hardware/UDOO/solox/variants/udooneo/wiring_constants.h:27:14: error: expected unqualified-id before numeric constant
    #define LOW 0x0
    ^
    sketch_jan16a.ino:44:29: note: in expansion of macro 'LOW'
    expected unqualified-id before 'if'


    This report would have more information with
    "Show verbose output during compilation"
    enabled in File > Preferences.



    please help!!!
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    I believe there is a Neo library for the dht11. You have to use that one instead of some library found on the internet.
     
  3. Marina

    Marina New Member

    Joined:
    Mar 21, 2018
    Messages:
    3
    Likes Received:
    0
    I used the library for dht11 provided by arduino (cubit used this in their tutorial too )...
     
  4. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    The Arduino part of the Neo is not fully compatible with a normal Arduino as it has a completely different hardware architecture.
    Therefor a lot of libraries are not working as they address hardware memory for example or do gpio bitbanging instead of using the normal digitalwrite subroutines.
    In the Arduino IDE on the Neo there is a special Neo section in the examples and libraries. Use those. You have to delete the ones you dowmnloaded yourself as they are now overruling the ones special for the Neo.
     
  5. Marina

    Marina New Member

    Joined:
    Mar 21, 2018
    Messages:
    3
    Likes Received:
    0
    Thanks for the reply I tried compiling and running an example with DHT11 with the library of Neo ,everything is okay now ( at least it shows that it compiles okay Success on uploading) ... but it timesout ......I am compiling and running the example for the dht11 sensor :
    Code:
    //
    //    FILE: dht11_test.ino
    //  AUTHOR: Rob Tillaart
    // VERSION: 0.1.01
    // PURPOSE: DHT library test sketch for DHT11 && Arduino
    //     URL:
    //
    // Released to the public domain
    //
    
    #include <dht.h>
    
    dht DHT;
    
    #define DHT11_PIN 5
    
    void setup()
    {
      Serial.begin(115200);
      Serial.println("DHT TEST PROGRAM ");
      Serial.print("LIBRARY VERSION: ");
      Serial.println(DHT_LIB_VERSION);
      Serial.println();
      Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
    }
    
    void loop()
    {
      // READ DATA
      Serial.print("DHT11, \t");
      int chk = DHT.read11(DHT11_PIN);
      switch (chk)
      {
        case DHTLIB_OK: 
            Serial.print("OK,\t");
            break;
        case DHTLIB_ERROR_CHECKSUM:
            Serial.print("Checksum error,\t");
            break;
        case DHTLIB_ERROR_TIMEOUT:
            Serial.print("Time out error,\t");
            break;
        default:
            Serial.print("Unknown error,\t");
            break;
      }
      // DISPLAY DATA
      Serial.print(DHT.humidity, 1);
      Serial.print(",\t");
      Serial.println(DHT.temperature, 1);
    
      delay(2000);
    }
    //
    // END OF FILE
    //
    It runs with timeout!! I have connected everything okay ....still.....it outputs

    DHT11, Time out error, -999.0, -999.0

    DHT11, Time out error, -999.0, -999.0

    DHT11, Time out error, -999.0, -999.0

    DHT11, Time out error, -999.0, -999.0

    DHT11, Time out error, -999.0, -999.0
     
  6. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    You could try to increase the timeout check value in dht.h to a value that works.
    Below are the default values (65).

    #define DHTLIB_TIMEOUT (65) // 100usec
     

Share This Page