Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
![]() Slide 1: DHT11 Temperature and Humidity Sensor | ||||||||
Line: 29 to 29 | ||||||||
Reading and understanding the data sheet | ||||||||
Changed: | ||||||||
< < | Let’s have a look at the DHT11 data sheet![]() | |||||||
> > | Let’s have a look at the DHT11 data sheet![]() | |||||||
Most of the following information is just a copy from the data sheet. | ||||||||
Line: 112 to 112 | ||||||||
| ||||||||
Changed: | ||||||||
< < | Response from DHT11 | |||||||
> > | Response from the DHT11![]() | |||||||
A zero bit | ||||||||
Line: 132 to 134 | ||||||||
Let's start slowly:
| ||||||||
Changed: | ||||||||
< < | The zeros and ones do not look too convincing. Let’s save those onto a file and look at it with gnuplot ---++ | |||||||
> > | The zeros and ones do not look too convincing. | |||||||
What the user of the device wantsThe user of the device would like to have a library which hides | ||||||||
Line: 251 to 253 | ||||||||
It creates html of latex doc | ||||||||
Changed: | ||||||||
< < | %SLIDESHOWEND% | |||||||
> > | %SLIDESHOWEND% | |||||||
-- ![]() Comments | ||||||||
Changed: | ||||||||
< < | ||||||||
> > | ||||||||
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
![]() Slide 1: DHT11 Temperature and Humidity Sensor | ||||||||
Line: 274 to 274 | ||||||||
| ||||||||
Deleted: | ||||||||
< < |
| |||||||
| ||||||||
Added: | ||||||||
> > |
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
![]() Slide 1: DHT11 Temperature and Humidity Sensor | ||||||||
Line: 16 to 16 | ||||||||
DHT11 pinout | ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
Serial Protocol | ||||||||
Line: 215 to 215 | ||||||||
![]() | ||||||||
Added: | ||||||||
> > | Where is the include file, where the binary of the shared lib?I installed the include file in /opt/ucc/include and the library in /opt/ucc/lib. These are non-standard directories and must be declared in the Makefile -I /opt/ucc/include for the include file in CFLAGS -L /opt/ucc/lib for the library path Since the shared library is loaded separately when running the main program, it must be found by the system: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/ucc/lib | |||||||
DocumentationWhen writing a library that is supposed to be used by other people, |
Line: 1 to 1 | |||||||||
---|---|---|---|---|---|---|---|---|---|
![]() Slide 1: DHT11 Temperature and Humidity Sensor | |||||||||
Line: 132 to 132 | |||||||||
Let's start slowly:
| |||||||||
Changed: | |||||||||
< < | The zeros and ones do not look too convincing. Let’s save those onto a file and look at it with gnuplot | ||||||||
> > | The zeros and ones do not look too convincing. Let’s save those onto a file and look at it with gnuplot ---++ 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
The libraryHow do we write a library?A library consist of min. 2 files:
The include file of the dht11 library![]() dht11.h (2)![]() The library code
Reading the final data
Starting the measurementThe data pin has been programmed as output earlier![]() Analyzing the dataThis is the tricky bit and you are invited to give it a try. I have written a routine reading a single bit, which is called 40 times for all the 40 bits in the data. Please note one nasty problem:Linux is a multi-tasking system and permanently receives interrupts. While these interrupts are treated the DHT11 data are continuing to flow but are not taking into account, leading to corrupt data. Since the duration of the protocol takes ~ 4 ms the probability is non negligible and the checksum test in obligatory to make sure the data are consistent. In case of a checksum error you must repeat the measurement Creating a shared libraryThe Makefile says it all![]() | ||||||||
| |||||||||
Added: | |||||||||
> > | DocumentationWhen writing a library that is supposed to be used by other people, documentation is of utmost importance Of course the function prototypes in the include file give some indication but this normally not enough. I use the doxygen in code documentation system which allows to generate documentation from the source layout and comments in the code with special tags. It creates html of latex doc | ||||||||
%SLIDESHOWEND% | |||||||||
Line: 158 to 255 | |||||||||
| |||||||||
Added: | |||||||||
> > |
|
Line: 1 to 1 | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() Slide 1: DHT11 Temperature and Humidity Sensor | |||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||
> > | Lecture 8Uli RaichUCC semester 2017/2018A 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? DHT11 pinout
Serial ProtocolHow can we, with a single pin
and the DHT11 implements its own serial protocol Reading and understanding the data sheetLet’s have a look at the DHT11 data sheet![]() ![]() How does a resistive humidity measurement work?![]() Resistive Humidity Measurement(2)
The NTC Thermistor![]() 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 protocolText from the data sheet![]() Measurement Precision![]() How to connect the device![]() 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![]() Single Wire two way interface![]() Overall Communication Process![]() How to initiate a Measurement?![]() What does this mean for our program?We must:
Response from DHT11
A zero bit![]() A one bit![]() Complicated?Wow, this looks complicated. How can we write a program to do all this? Let's start slowly:
Let’s save those onto a file and look at it with gnuplot | ||||||||||||||||||||||||||||
%SLIDESHOWEND% | |||||||||||||||||||||||||||||
Line: 10 to 143 | |||||||||||||||||||||||||||||
Comments\ No newline at end of file | |||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||
> > |
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Added: | ||||||||
> > |
![]() Slide 1: DHT11 Temperature and Humidity Sensor--![]() Comments |