B4R Question DHT22sensor.Read22 not return 0 if failure

Discussion in 'B4R Questions' started by jcohedman, Jun 11, 2019.

  1. jcohedman

    jcohedman Member Licensed User

    Hellow!
    When I'm reading DHT22 sensor with an ESP8266, if it is connected, gives the values, but if desconnected, don't return 0, continues with the last values measured...
    What I'm doing wrong?

    Code:
    DHT22pin1.Initialize(5,DHT22pin1.MODE_INPUT) 
    DHT22sensor1.Read22(DHT22pin1.PinNumber)            
    'Reading the DHT22 measure
        hum1=NumberFormat (DHT22sensor1.GetHumidity,0,0)      'Get humidity from readed measure
        temp1 =NumberFormat (DHT22sensor1.GetTemperature,0,0)  'Get temperature from readed measure
     
  2. Hi Jcohedman.
    when measure pin was sisconnected you must see -999 in hum1,temp1

    upload_2019-6-11_23-14-25.jpeg
     

    Attached Files:

    jcohedman likes this.
  3. jcohedman

    jcohedman Member Licensed User

    Hi, Vali!
    thanks for your answer, but unfortunately this is the problem, it must return 0, and don´t...
    Btw, I'm using DHT22.
    Meanwhile, I'm changing the ESP8266 for a ESP32S, to see what happens.
     
  4. Hi jcohedman
    I thought about your problem.
    I think your problem will be solve if you Initialize measure breafor each read11.

    ok ?
     
    jcohedman likes this.
  5. jcohedman

    jcohedman Member Licensed User

    will try. Thanks!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice