Line: 1 to 1 | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Added: | |||||||||||||||||||||||||
> > |
![]() Lecture 4: DHT11 Temperature and Humidity SensorCSC 321: Embedded SysytemFirst Semester 2020/2021Slide 1: The DHT11
The DHT11 is a basic, low-cost digital temperature and humidity sensor.
It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and
spits out a digital signal on the data pin (no analog input pins needed).
Its fairly simple to use, but requires careful timing to grab data.
The only real downside of this sensor is you can only get new data from it once every 2 seconds.
Slide 2: A single GPIO pinWe have seen how we can drive an LED from a single GPIO pin programmed as output pin or how we can read its state through another GPIO pin, programmed as input pin.Can one do more with a single pin? Slide 3: Serial ProtocolHow can we, with a single pin
and the DHT11 implements its own serial protocol Slide 4: Reading and understanding the data sheetLet’s have a look at the DHT11 data sheet: Most of the following information is just a copy from the data sheet.Slide 5: How does a resistive humidity measurement work?![]() Slide 6: Resistive Humidity Measurement(2)
Slide 7: The NTC Thermistor![]() Slide 8: A processor on chipIn order to convert these measurements into numeric values and send them to the end user through a serial protocol, a preprogrammed micro-controller must be implemented on the chip. In the case of the DHT11 this is an 8 bit micro-controller, which does the conversion into binary and which creates the serial protocolSlide 9: Text from the data sheetThis sensor includes a resistive-type humidity measurement component and an NTC temperature measurement component, and connects to a high-performance 8-bit microcontroller, offering excellent quality, fast response, anti-interference ability and cost-effectiveness. Each DHT11 element is strictly calibrated in the laboratory that is extremely accurate on humidity calibration. The calibration coefficients are stored as programmes in the OTP memory, which are used by the sensor’s internal signal detecting process. The single-wire serial interface makes system integration quick and easy. Its small size, low power consumption and up-to-20 meter signal transmission making it the best choice for various applications, including those most demanding ones. The component is 4-pin single row pin package.Slide 10: Measurement Precision![]() Slide 11: How to connect the device![]() Slide 12: Powering the deviceAs we can see from the specs below, the DHT11 power line can be directly connected to the cobbler 3.3V (or the 5V) line![]() Slide 13: Single Wire two way interface![]() Slide 14: Overall Communication ProcessCommunication Format can be seperated into three stages 1) Request2) Response 3) Data Reading Slide 15: Request Reading![]() Slide 16: What does this mean for our program?We must:
Slide 17: Response from DHT11![]() Slide 18: Data Reading![]() Slide 19: Logic Analyzer![]() Slide 20: What the user of the device wantsThe user of the device would like to have a library which hides all these details. He wants functions to
Slide 21: Reading the final dataThe dht11 library uses a custom 1-wire protocol to get the measurements from the sensor. The payload consists of a humidity value, a temperature value and a checksum. Then measure and read their values with:
Slide 22: Starting the measurementThe data pin has to be programmed as outputd = dht.DHT11(machine.Pin(16))And read data as d.measure() d.temperature() # eg. 23.6 (°C) d.humidity() # eg. 41.3 (% RH) -- ![]() Comments
|