Pure Python library for reading DHT sensor on Pycom boards
-
@robmarkcole that one I forked from JP. I was using a 4k7 resistor and it worked well.
Do you have
print('Humidity: {:3.2f}'.format(result.humidity / 1.0))
? And
You did declare the sensor object asth = DTH(Pin('P3', mode=Pin.OPEN_DRAIN), 1)
? The last one declares it as a DHT22.Does the humidity fluctuate at all?
-
@RobTuDelft in Pure Python library for reading DHT sensor on Pycom boards:
Hi Rob, using your library (https://github.com/rbraggaar/DHT_PyCom), DHT22 on Wipy with 10 kOhm pullup, I am getting a temp of 25 deg (correct) but humidity of 99.9% (incorrect). Any ideas what could be wrong?
Cheers
-
@Jurassic-Pork
I got it working now. the problem was i was running an older firmware, after updating to latest, it seems to be working now.
Thanks to @livius for troubleshooting it with me.
and @Jurassic-Pork for the library.
This is a great forum.
-
@palmy-nz
ok it seems good for your module and you have a pull up resistor on your module.
be careful if you have powered your module with 5v may be you have the signal pin on your pycom module out of order. Try to check it without the dht11 module (input level 0 (gnd) input level 1 (pull up resistor to 3.3v)).
-
@Jurassic-Pork
I am using this DHT11 sensor...
https://pasteboard.co/e4ZITp59g.png
This image just made me realize the pull up resistor is already embedded.
I have removed the resistor i had in my circuit, but still the same problem.
-
@palmy-nz
on the photo , it seems that you have wired the dht11 in a strange manner.
it must be :
3.3v on pin 1
signal on pin 2
gnd on pin 4may be it is not the same chip.
-
@livius I was trying other pins in the code example and photo and am making sure they match. Has to be something else?
-
@palmy-nz said in Pure Python library for reading DHT sensor on Pycom boards:
Pin G11 on expansion board
G11? If is see this right
in code you have P3 which is G24 not G11.
G11 is P4.
Or did you changed it from previous post?
Image quality is not enough to say for sure.P.S. i have upvoted your posts then you can now write faster - and maybe you will be allowed to post images directly
-
Hi @Jurassic-Pork, yes I am using your dht library.
and yes I have tried pulling it up to 3.3v and 5v, and have tried other pins.
Not sure what the problem is.
Here is my main py: https://gist.github.com/tairea/3607708a403b7501de142d125b07b7b8
and photo of set up: https://pasteboard.co/1p8ETKipZ.jpg
-
hello,
@palmy-nz
what is your power supply for your DHT11 ? 5 v or 3,3 v ?
are you using my library here ?
have you a pull up resistor to 3,3v on the pin signal of your DHT11 ?
have you try another expand board pin ? for example P3Friendly, J.P
-
I am still getting
false
. Using DHT11, pins double checked and, module works on arduino.using @RobTuDelft 's main.py, but changed
th = DTH(Pin('P4', mode=Pin.OPEN_DRAIN),0)
as using GHT11 on Pin G11 on expansion boardany ideas?
Thanks guys
-
@RobTuDelft Thanks ! It works ! I made a mistake on my breadboard and had the wrong GPIO on my extension board.
Thanks for your help, I have really appreciated it !Temperature: 23.30
Humidity: 43.90And thanks to Jurassic Pork for porting the library
-
@geda Yes, I use the latest library from @Jurassic-Pork.
This example works for me, maybe that helps.
I used a 4k7 resistor between data and +.
-
@geda Which Pin are you using. Note that P13..P18 are input only and cannot be used for that purpose.
see here: https://docs.pycom.io/pycom_esp32/_downloads/lopy_pinout.pdf
-
@geda
have you a dht22 module or simply a dht22 component ?
have you a pullup resistor on the signal pin of your dht22 ?
what pin of your lopy are you using for the dht22 ?
hello robert-hh same idea :-) in the same time
-
@RobTuDelft Sorry, I cannot read values ... so exactly the same code has work for you ? May be my DHT22 is broken ...
-
@geda Yes works for me too :)
@RobTuDelft said in Pure Python library for reading DHT sensor on Pycom boards:
Great! Now working on the Lopy.
Thanks a lot @Jurassic-Pork & @robert-hh!PYB: soft reboot ==========Starting main.py========== <DTHResult object at 3ffe2ed0> <class 'DTHResult'> True Temperature: 21.70 Humidity: 57.50
-
@RobTuDelft , I can read values from the DHT22 with the lopy...
Did you use exactly the same code that @Jurassic-Pork has commited on github ?
-
@robert-hh
i have made a few changes in the dth.py code :class DTH: 'DHT sensor (dht11, dht21,dht22) reader class for Pycom' #__pin = Pin('P3', mode=Pin.OPEN_DRAIN) __dhttype = 0 def __init__(self, pin, sensor=0): self.__pin = pin self.__dhttype = sensor self.__pin(1) time.sleep(1.0) def read(self): #time.sleep(1) # send initial high #self.__send_and_sleep(1, 0.025) # pull down to low self.__send_and_sleep(0, 0.019)
1 - no more default value for the pin
2 - a sleep time of one second in the constructor (init) code.
3 - no more sleep time at the beginning of the read method
4 - a sleep time of 19 ms for the startup signal. This value seems to be OK for the specifications of DTH11 AND AM2302.no error in a program test of 10000 measures with my SiPy module and a DTH11 sensor;
-
@Jurassic-Pork the 500 ms were just found by trial. It may be more. Just ensure that the data line is high during that period. If you have a 1s delay in the init, the delay in read is not required.
About the length of the start signal: Just give it a try. I did not check for the maximum length accepted by the AM2302. Only 40 ms was too long, and previous tests with 20ms worked. You could make it dependent on the sensor type, since that is specified at init time.