DHT11/22 Temp Sensor Trouble - Collin’s Lab Notes

  Переглядів 154,345

Adafruit Industries

Adafruit Industries

День тому

A look into single-wire comms of the classic DHT11 & DHT22 temp/humidity sensors #adafruit #collinslabnotes
Explore sensors at Adafruit:
www.adafruit.com/category/35
Visit the Adafruit shop online - www.adafruit.com
-----------------------------------------
LIVE CHAT IS HERE! adafru.it/discord
Adafruit on Instagram: / adafruit
Subscribe to Adafruit on UKposts: adafru.it/subscribe
New tutorials on the Adafruit Learning System: learn.adafruit.com/
-----------------------------------------

КОМЕНТАРІ: 86
@CrimsonTide001
@CrimsonTide001 2 роки тому
I don't know how Arduino does it, but there's no reason the OneWire interface can't be implemented solely through interrupts. No need to busy-wait counting cycles.
@rpavlik1
@rpavlik1 2 роки тому
This isn't "the" One Wire protocol, it's a single wire protocol that is very timing sensitive and also wiring sensitive.
@technicholy1299
@technicholy1299 2 роки тому
@@rpavlik1 The only thing that's sensitive about DHT sensors is when you poll them too fast. The datasheet tells you the fastest they can be polled and I've never had an issue with a few feet of wire or "timing" issues reading the sensors. This video is just hocking the more expensive adafruit sensors that do the same thing with the same accuracy.
@tonyfremont
@tonyfremont 2 роки тому
You're right. Just catch the rising edge in an ISR, along with a timestamp. Then reconfigure the processor to trigger on the falling edge. When that triggers, take a timestamp and calculate the difference between it and the previous capture. If it's longer than 50-60uS, then it's a one, otherwise.....
@tonyfremont
@tonyfremont 2 роки тому
@@rpavlik1 true, it's not exactly the same, but it's not that much different in this respect.
@technicholy1299
@technicholy1299 2 роки тому
@@tonyfremont I think that would be more complex than the Arduino library. I just had a look and they suspend all interrupts while reading from the sensor since the timing is rather tight. Since the max length message is 40 bits, that would be 80 interrupts total at 2 per bit plus a couple more to signal the start of a reading and then you still have to measure all of them to see what you got. If you had another interrupt fire during that time, you would be in trouble. There might be some speedy controllers that could handle it, but I'm not sure an 8-bit AVR is up to the task if you want to do anything else.
@windowsxseven
@windowsxseven 2 роки тому
You can't tell me what to do, Collin.
@Mr11Man
@Mr11Man 2 місяці тому
Yes, he can, you operating system
@Kosmonooit
@Kosmonooit 5 місяців тому
I have always found them a problem, mainly so inaccurate they can't be used
@howardbaxter2514
@howardbaxter2514 Рік тому
I’ve been using an SHT30. But bulkier, but it looks very similar to the DHT22 sensor and works through I2C.
@carlosgarcialalicata
@carlosgarcialalicata Рік тому
I use SHT40. it's actually tiny, and only requires a small cap. Maybe you are using a too -large board
@lemailpoubel6210
@lemailpoubel6210 6 місяців тому
Yes...the sht xx are the best solution...i lost my nerves too much with dht...
@rarbiart
@rarbiart 5 місяців тому
In plus the DHTs like to fail in humid conditions, above 80 percent without condensation seems to kill the within a year. BMs are so much more stable.
@ArtiZirk
@ArtiZirk 6 місяців тому
It's a bit more advanced but you can use dma and timer capture to read data from those sensors
@deang5622
@deang5622 6 місяців тому
It isn't worth it. Overly complicated solution when there are better out there. A sensor that outputs measurements in I2C format is a much better solution. Cheaper, fewer component count, greater reliability and less complex software and a shorter development time. As engineers you are trying to optimise the solution, not make it more complicated than it needs to be.
@ferrumignis
@ferrumignis 4 місяці тому
​@@deang5622Configuring a micros peripherals to offload CPU time is not making things more complex than they need to be, it's making it exactly as complex as it needs to be. Also check out the cost of these I2C parts compared to the original single wire devices.
@AureliusR
@AureliusR 4 місяці тому
@@deang5622 Setting up DMA and a timer capture is like a handful of register writes and a short ISR. That's probably just as simple, not to mention just as easy to write as a simple I2C driver.
@LAYATORS
@LAYATORS Рік тому
Yes thank you , for my project my arduino mega R3 have to take 15 sensors values do multiple calculations and send all that to a display... So yea
@edinetgrunhed6000
@edinetgrunhed6000 4 місяці тому
this library very interesting hope you can explain more of this
@ineedanewhobby3669
@ineedanewhobby3669 4 місяці тому
this is not a library
@Invatator
@Invatator Рік тому
So what is the issue with these, and thr microseconds whatever? I still don't get it.
@amyshaw893
@amyshaw893 5 місяців тому
he is saying that your micro has to keep constantly waiting for the change, counting how long between the signal edges, and as such it cant do anything else that it might need to
@alastor--radiodemon7556
@alastor--radiodemon7556 5 місяців тому
​@@amyshaw893doesn't something as basic as a RPI pico have 4 cores and an esp32 has 2? You could do a different thread
@amyshaw893
@amyshaw893 5 місяців тому
@@alastor--radiodemon7556 sure, but an Arduino doesn't, which is what a lot of people will be using. Plus he wants to advertise the expensive adafruit board
@goranjosic
@goranjosic Рік тому
Sensirion sensors are great! I2c, reliable and accurate.
@AureliusR
@AureliusR 4 місяці тому
This is EXACTLY what Timer/Counter units with input capture are for. They are literally designed to measure how long pulses are.
@ryandyc
@ryandyc 20 днів тому
How does I2C compare to the DHT11 communications?
@McTroyd
@McTroyd 2 роки тому
Ummm... "int timePassed = millis();" in an ISR at regular (edit: edge triggered) intervals, and do the checks in the main loop as it goes around? Come now, the advantage of being a hardware hacker is solving problems! Why do it the fast and smart way when you can prove you're right?? 😁
@rpavlik1
@rpavlik1 2 роки тому
Even with that, the data quality is so much worse than any modern sensor. There are plenty of libraries to talk to these, since they are popular because they used to be best performance/price in a humidity and temp sensor, but they still are cantankerous and prone to just not working. (Also there's enough variation between units that you might have code that works with one, but then you buy another and it doesn't work with that one.)
@McTroyd
@McTroyd 2 роки тому
@@rpavlik1 Interesting. Didn't know that; thanks! Granted that terrible data is terrible data, but getting the ins and outs of the signaling could be quite valuable to someone. It could be a good troubleshooting exercise too. Why does one work and another not?
@rpavlik1
@rpavlik1 2 роки тому
@@McTroyd if one wants to practice troubleshooting skills, sure. But not for practical usage 😁
@technicholy1299
@technicholy1299 2 роки тому
Notice adafruit doesn't have breakouts for DHT sensors, only the ones the "recommend". I've never had an issue with them and have had them in service for years.
@technicholy1299
@technicholy1299 2 роки тому
@@McTroyd The only way the quality is worse is that you can't constantly poll the sensor. Frankly, it doesn't matter for almost any application that fits this sensor's environmental requirements. You simply don't need to poll the temp sensor at 5hz for any practical reason. Even at .5hz you're generating way too much data for what you would likely practically use. 10-20 samples per min is plenty for almost any project and DHT sensors work fine for that. Reading the sensor is one thing, but you have to process the data and do something useful with it and on that scale, DHT11/22 are just fine.
@Kalpanapardhi1
@Kalpanapardhi1 2 роки тому
At first i thought they were some kind of connectors 💀
@user-lk9yv9im6e
@user-lk9yv9im6e 6 місяців тому
Just use a PLL which synchronises on the rising edge and a long SIPO register with a delay line :) (it's obviously a joke)
@johnadams6249
@johnadams6249 Рік тому
using PIO on a raspberry pi pico, this is easy peasy pico and uses no cpu cycles
@RogerCollectz
@RogerCollectz 4 місяці тому
The people running this channel. I’ve gotten obsessed with circuit boards, and everything that goes a long with it. How can I learn how to get into doing cool projects that use boards, capacitors, resistors, chips, soldering and all that good stuff? I’m very interested and curious. Or anyone in the comments?
@protektwar
@protektwar 2 роки тому
vintage collection :)
@my_unreasonably_long_username
@my_unreasonably_long_username Рік тому
Thank you
@CreatronixDE
@CreatronixDE 2 місяці тому
What's wrong with using the DHT sensor library?
@crashmatrix
@crashmatrix 6 місяців тому
I mean, opting for the I2C devices is fine, but you're not gonna be sitting there counting microseconds like some while(1) dopey. You're gonna have it hooked up to a rising/falling edge interrupt and just subtracting some static monotonic timer values to get to the data.
@xpeng121
@xpeng121 2 роки тому
i2c, the best
@Quietloud
@Quietloud Рік тому
Curious as to why? It seems people in the know are real fans of I2C and I'm a novice.
@link7417
@link7417 6 місяців тому
​@@Quietloudits a rather easy to implement serial buss that allows multiple devices to share the same buss by using a master slave system, so instead of the temperature sensor always sending out its information on the buss the master (usually your main controller) says hey id 123 "fromMaster" out into the buss so it doesn't matter where on the buss it is either. onse the slave device is done doing what it needs to do it can then send out a response on the buss for the master, for temperature that can be pretty much instant since it can continuously read temperature data and only send it once called but if for example you have a stepper motor connect to the I2C buss (would obviously need a interface between the two) the master controller could say move 100steps and once it done that it can respond that it have done its task, Obviously this is a rather simplistic explanation but I am happy to answer any questions you have as long as UKposts doesn't limit the notifications
@ferrumignis
@ferrumignis 4 місяці тому
If it's a choice between one wire and I2C then I'd go for the latter, but I2C in general is not as reliable as SPI.
@jerkycam
@jerkycam Рік тому
Does it come in probe form?
@that_gai_gai
@that_gai_gai 4 місяці тому
Ok but what song is in the background of this video
@mariushmedias
@mariushmedias 5 місяців тому
or get a 8 pin PIC or other micro and make a 1 wire to i2c/spi adapter chip
@mjschuelke
@mjschuelke 5 місяців тому
Temperature and Humidity are slowly-changing quantities. Even if you read them once per second (which is probably more often than you really need to), you'll still spend less than 1% of your processor time bit banging.
@ferrumignis
@ferrumignis 4 місяці тому
That is true, but you still have the problem of blocking high priority interrupts etc if you start measuring multiple 28us periods purely in software. It's not that hard to use a timer to run these under interrupt using a timer with compare/capture though, assuming you have a spare one.
@robertw1871
@robertw1871 5 місяців тому
This is why nearly all uC’s have timers and interrupts… there’s also non blocking code that doesn’t just sit around and wait, it’s called cooperative multitasking… stay in school you’ll get there…
@isaaclove1144
@isaaclove1144 6 місяців тому
You could have a really cheap microcontroller listening to the sensor and then send it over more sane serial interface to your main controller...
@BPTtech
@BPTtech 5 місяців тому
BMP280 /BME
@milescarter7803
@milescarter7803 Рік тому
Any odds the protocol could be inplemented with the special IO of the rpi2040 processor?
@jamate
@jamate Рік тому
I'm pretty sure it can be implemented on the PIO blocks. Have you tried to do it?
@fellzer
@fellzer 5 місяців тому
$10 vs 0.10 cents
@technicholy1299
@technicholy1299 2 роки тому
I've been using these for years without issue. I doubt you would be recommending anyone away from sensors that you had a breakout for.
@rpavlik1
@rpavlik1 2 роки тому
Unfortunately I have one of these caulked under a toilet in my house, so it's hard to swap that one out. However, I wised up before my next install, so the other toilet has an sht20d or something like that - so much nicer.
@bland9876
@bland9876 2 роки тому
Interesting place to put one I wonder what you're doing with it?
@guymanuel4260
@guymanuel4260 2 роки тому
@@bland9876 I guess a toilet seat warmer?
@joey.g
@joey.g 2 роки тому
Why do you have one near your toilet what does it have to do with anything
@rpavlik1
@rpavlik1 2 роки тому
@@joey.g under the toilet, to detect if it's leaking
@joey.g
@joey.g 2 роки тому
What kind of system do you have it hooked up. To your PC ...? What kind of software. Never heard of someone going to such extreme to monitor a toilet for leaks ..
@captainboing
@captainboing 5 місяців тому
... aaaand they "fog up" over time and start giving really dodgy humidity readings
@Joso997
@Joso997 2 роки тому
Why. Your patent expired so we should no longer use it? It is a perfectly functional sensor in its spec class
@Quietloud
@Quietloud Рік тому
Don't most microcontrollers have I2C protocols baked in?
@carlosgarcialalicata
@carlosgarcialalicata Рік тому
Yes they do. I2c requires two wires though
@AndrewTSq
@AndrewTSq 6 місяців тому
just use a cheap mcu to only read the value.. and send it to the other mcu :)
@RamyFal
@RamyFal 5 місяців тому
Do a Video about how the Galacy Note 3 used it's sensor to read temp n hymidity .
@AureliusR
@AureliusR 4 місяці тому
The Galacy can read hymidity? Wow!
@RamyFal
@RamyFal 4 місяці тому
@@AureliusR Yess Humidity Temperature
@thefirehawk1495
@thefirehawk1495 Рік тому
I dont understand what the issue is, it works, it's fine.
@xtremeownagedotcom
@xtremeownagedotcom 4 місяці тому
Cheap, but, inaccurate. +/- 2 degrees isn't really suitable for much. Even for taking the temp of my office- 2 degrees difference is quite a bit.
Sensors - which one to use
17:06
Electronoobs
Переглядів 1,3 млн
6 Horribly Common PCB Design Mistakes
10:40
Predictable Designs
Переглядів 159 тис.
[실시간] 전철에서 찍힌 기생생물 감염 장면 | 기생수: 더 그레이
00:15
Netflix Korea 넷플릭스 코리아
Переглядів 38 млн
Завтра в школу с... | Шоу-квиз «Вопросики»
00:28
Телеканал СОЛНЦЕ
Переглядів 1,9 млн
Ages 1 - 100 Decide Who Wins $250,000
40:02
MrBeast
Переглядів 115 млн
9 ways to drive a MOSFET, with examples
8:10
krakkus
Переглядів 19 тис.
What is the HackRF One Portapack H2+
8:21
sn0ren
Переглядів 432 тис.
Визуализация гравитации
10:00
Макар Светлый
Переглядів 13 млн
Extracting Firmware from Embedded Devices (SPI NOR Flash) ⚡
18:41
Flashback Team
Переглядів 480 тис.
Measuring Temperature with Arduino - 5 Sensors
29:55
DroneBot Workshop
Переглядів 138 тис.
Humidity Sensors // Alps Alpine
5:01
ALPS ALPINE English channel
Переглядів 12 тис.