Dht not working?
Hi, i am new to this and i can´t get the dht to work at all in microblocks. I broke my program down to trubleshoot and not even this small program is working.
I was trying to get the dht11 to mozilla things gateway but the data did not update so i broke it down to find the error.
I get the sensor to work in Arduino so the sensor is fine and correctly connected .
Comments (6)
-
-
@John Maloney , I don’t really understand why this is failing. Do you have a DHT11 module you can test this on?
I tried adding a timeout, but it’s not so simple because the whole reading depends on timed readings…
-
repo owner I can look into it. What micro:controller are you using to test?
As I recall, you need to leave a certain minimum time between data readings but I see that the test program is doing that. We should make it so that library doesn’t hang indefinitely if the DHT doesn’t respond.
I’m pretty sure I’ve got a DHT-11 somewhere to test with…
-
repo owner That was one of the first libraries I wrote for MicroBlocks and my lack of experience shows.
There are multiple issues. One issue is that it will hang if it misses a single bit transition because there’s no timeout mechanism. Another issue is that it was written for a fairly fast processor – I think I used the Adruino Primo which has a 64 MHz nRF52 processor. It’s not even totally reliable on a Primo but it flat-out doesn’t work on slower processors such as the 16 MHz micro:bit. We may need to add some low-level support to measure pulse widths accurately on the original micro:bit. The DHT-11 protocol requires being able to distinguish between pulse widths of 28 usec and 70 usecs.
I’ll work on this, but it may take a while to get something that works on 16 MHz processors. I might be able to make an interim solution that works on SAM D21 (48 MHz) and faster processors if that’s what you have @Andreas Persson .
-
This was fixed by John recently. You’ll be able to use DHT sensors in the next MicroBlocks version
-
repo owner - changed status to resolved
Fixed in version 1.0.1i
- Log in to comment
Hmm, you’re right that there’s something funny going on with the library. I tried reading first the humidity and then the temperature, and it worked. But then I tried starting over and reading the temperature first, and the reporter stayed highlighted without returning any value:
I think we should at the very least add a timeout to the reporter… let me look into it.