B4R Question DHT22sensor.Read22 not return 0 if failure

jcohedman

Member
Licensed User
Longtime 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?

B4X:
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
 

vali khandangoll

Active Member
Hi Jcohedman.
when measure pin was sisconnected you must see -999 in hum1,temp1

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

Attachments

  • upload_2019-6-11_23-13-39.jpeg
    upload_2019-6-11_23-13-39.jpeg
    197.8 KB · Views: 274
Upvote 0
Top