Read DHT 11 temperature sensor and hum...
-
i try to read data from DHT 11 sensor
my file dhttest.py looks likefrom machine import Pin from machine import UART import DHT dht_pin=Pin('G4', Pin.OPEN_DRAIN) dht_pin(1) temp, hum = DHT.DHT11(dht_pin) # temp = temp * 9 // 5 + 320 # uncomment for Fahrenheit temp_str = '{}.{}'.format(temp//10,temp%10) hum_str = '{}.{}'.format(hum//10,hum%10) # Print or upload it print(temp_str, hum_str)
but when i do
execfile('dhttest.py')
result is
280.5 280.5
but second execution
execfile('dhttest.py')
cause halt exception>>> execfile('dhttest.py') 280.5 280.5 >>> execfile('dhttest.py') Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0) Register dump: PC : 400d277d PS : 00060634 A0 : 80082d94 A1 : 3ffdc2a0 A2 : 0006062f A3 : 00000245 A4 : 00000001 A5 : 00000001 A6 : 00000000 A7 : 3ffb0154 A8 : 00000001 A9 : 3ffdc280 A10 : 3ffc4bf4 A11 : 0000012c A12 : 00000122 A13 : 00000000 A14 : 00000003 A15 : 00060223 SAR : 00000004 EXCCAUSE: 00000005 EXCVADDR: 00000000 LBEG : 4000c2e0 LEND : 4000c2f6 LCOUNT : ffffffff CPU halted.
code of dht.py is here
dht postplease help with this
-
This post is deleted!
-
I got into the same issue with this DHT11 sensor.
I wonder if it still has to do with the threading issue as mentioned here.Secondly, why is the call to
dht_pin(1)
required?
If I get it right, this writes a value of 1 to the pin?*edit
Even without any sensor connected, the code still returns a fixed 28.05.
-
Hello.
I bought a grove sensor which contains DHT22 (now called AM2302) and i tried the code mentioned here and it does return 280.5 without crashing but nothing else. Does anyone know how to actually read the sensor data? or point me to the right direction?
I am using a LoPy by the way.
Thanks
-
Hi @livius,
We released a new firmware with updates in stability that i think might help you with your issue, please download it at
https://www.pycom.io/support/supportdownloads/
and follow the instructionsBest,
Roberto
-
With todays firmware it does not crash :)