# Up For Review: DHT11 Temperature Sensor Interface with Arduino

Status
Not open for further replies.

#### #12

Joined Nov 30, 2010
18,223
Under Arduino, library
add a statement that the link marked, "here" (Arduino Playground) includes information about where to get the unique sensor for this project.

#### OBW0549

Joined Mar 2, 2015
3,566
Two comments: first, for readability the list of steps at the end of the article should appear much earlier, probably just before the circuit diagram.

Second, I'm only starting to learn C programming (after 40 years working in assembly language!), but something looks fishy to me: in the code, the two lines in the loop() procedure that say,

// two float type variables to read temperature and humidity
float humidity = dht.getHumidity();
float temperature = dht.getTemperature();

appear to be declaring the two variables and assigning them a value. Is this kosher? I would think it would at least make the code more readable if

// two float type variables to read temperature and humidity
float humidity;
float temperature;

were written above the Setup() procedure, right after

DHT dht;

and then, in the loop() procedure, replace the existing two lines with

humidity = dht.getHumidity();
temperature = dht.getTemperature();

In my view, that would make the code easier to read. If I'm all wet on this, feel free to ignore...

#### nerdegutta

Joined Dec 15, 2009
2,684
Nit-picking...

Hardware
• 1 x Arduino Uno
• 1 x DHT11 temperature sensor
• 1 x 1k Ohm resistor
• Jumper Wires
You'd also need a solderless breadboard...

I do not like when you must download libraries from an external site. What if the site goes down? What if Mark Ruys deletes his account at github.

Some time ago ACC encourage members to host pictures locally, I think libraries also should be stored locally.

#### djsfantasi

Joined Apr 11, 2010
8,396
The use of the pronoun it (whose definition could be argued, since the object is undefined except in the title) in the bullet points is redundant and distracts from the list.

Don't use "it" repearedly; simply list the features. All the points should be worded in the style of the second bullet or more succintly. E.g., "Factory calibrated", " -40 to +85°C operating range", "Accuracy to ±1ºC" are clearer.

On this last one, the wording of "maximum accuracy is about" is troublesome. About what? Does ±1ºC really mean ±5ºC? And "typical accuracy"? What does that mean? Then, the two statements are contradictory. If the maximum accuracy is ±1ºC, how can its "typical" accuracy be greater than that maximum at ±0.5ºC?

Let's be specific and in the hardware list, specify "Male to Male Jumper Wires".

Once you get beyond your introductory material, the content gets light.

There are assumptions made in the instructions. They say to download the file and then states where to place the extracted files. Some people will miss the point that an internediate step is required to extract the files. Instead of "Download the library and place the extracted library folder in your /libraries/ folder", I'd like to see it worded as "Download the library and extract the 'library' folder into your /libraries/ folder.". Or something similar...

When writing a technical document, it is useful to highlight objects such as folder names or variables. I'm unaware of any standards currently in existence, but for now, I've bolded the references for example.
The article presents the program, but does little to discuss what it does or defines the functions used in the DT library (there is only one that I personally think requires further comment and that is the get minimum sampling period.

The results section could have a little more meat on its bones. At a minimum, I'd like to see which serial monitor is being used, by explaining in a couple of words where it is? Otherwise I'd might use Putty .

#### Georacer

Joined Nov 25, 2009
5,182
Two comments: first, for readability the list of steps at the end of the article should appear much earlier, probably just before the circuit diagram.

Second, I'm only starting to learn C programming (after 40 years working in assembly language!), but something looks fishy to me: in the code, the two lines in the loop() procedure that say,

// two float type variables to read temperature and humidity
float humidity = dht.getHumidity();
float temperature = dht.getTemperature();

appear to be declaring the two variables and assigning them a value. Is this kosher? I would think it would at least make the code more readable if

// two float type variables to read temperature and humidity
float humidity;
float temperature;

were written above the Setup() procedure, right after

DHT dht;

and then, in the loop() procedure, replace the existing two lines with

humidity = dht.getHumidity();
temperature = dht.getTemperature();

In my view, that would make the code easier to read. If I'm all wet on this, feel free to ignore...
This will definitely work. The debate on whether the variables should be declared on setup or loop (which are not essentially different procedures, priviledge-wise) is one on compiler and memory access efficiency.

Nit-picking...

You'd also need a solderless breadboard...

I do not like when you must download libraries from an external site. What if the site goes down? What if Mark Ruys deletes his account at github.

Some time ago ACC encourage members to host pictures locally, I think libraries also should be stored locally.
When referring to github libraries, I think it's a good idea to fork the material to a personal repository, just to be sure that it will always be there but also refer to the original, for the sake of updates and reference.
Now, on the rest of the cases, I think the original link should always be present, but again, a local copy isn't bad either.

#### OBW0549

Joined Mar 2, 2015
3,566
Once you get beyond your introductory material, the content gets light.
IMO, "light" is an understatement: so far, none of the Project articles posted has more than a bare minimum of explanation, whether about how the hardware operates or about what's going on in the code. Many opportunities for education are missed and IMO that's a shame.

The results section could have a little more meat on its bones. At a minimum, I'd like to see which serial monitor is being used, by explaining in a couple of words where it is? Otherwise I'd might use Putty .
Users who are already familiar with the Arduino IDE would recognize this as the IDE's built-in Serial Monitor, but for those who are not it should always be identified as such.

#### nerdegutta

Joined Dec 15, 2009
2,684
... and it works!

Had to try it on a Mega2560

One question. In the comment section of the setup() function, there is a Serial.println();. Couldn't that be removed, as it has no purpose?

#### OBW0549

Joined Mar 2, 2015
3,566
This will definitely work. The debate on whether the variables should be declared on setup or loop (which are not essentially different procedures, priviledge-wise) is one on compiler and memory access efficiency.
Thanks. I figured the compiler would probably be forgiving of that form. It's just jarring (to me, anyway) to see declarations popping up in the middle of executable code, as I was taught they should always be up top.

When referring to github libraries, I think it's a good idea to fork the material to a personal repository...
As someone who is primarily a hardware jockey, except for some assembly language code developed on one-man (i.e., me) projects, I would have no idea whatsoever what that means.

I see github referred to a lot; is there any explanatory material online on how it works and how to use it, written for n00bs like me?

#### Hypatia's Protege

Joined Mar 1, 2015
3,226
That is not a 'circuit diagram' it is, rather, a pictorial WIRING diagram! Aye! aye!! aye!!!

With constructive intent
HP

Last edited:

#### Georacer

Joined Nov 25, 2009
5,182
Thanks. I figured the compiler would probably be forgiving of that form. It's just jarring (to me, anyway) to see declarations popping up in the middle of executable code, as I was taught they should always be up top.

As someone who is primarily a hardware jockey, except for some assembly language code developed on one-man (i.e., me) projects, I would have no idea whatsoever what that means.

I see github referred to a lot; is there any explanatory material online on how it works and how to use it, written for n00bs like me?
Think of this declaration as a worse case of:
Code:
for (int i; i<MAX; i++) {
do stuff...
}
The compilers know very well what do do about that.

About github. This site allows you to "copy" the work of another user and keep it in your personal page. You can also edit it there, but that's another story. The point is that you can have an independent copy, but also update it with the latest correction from the source material, when and if you want to.

#### Hypatia's Protege

Joined Mar 1, 2015
3,226
It's just jarring (to me, anyway) to see declarations popping up in the middle of executable code
Sadly, such informality (deviance?) has, increasingly, become 'the order of the day' in 'micro-controller land'

Best regards
HP

#### nerdegutta

Joined Dec 15, 2009
2,684
Thanks. I figured the compiler would probably be forgiving of that form. It's just jarring (to me, anyway) to see declarations popping up in the middle of executable code, as I was taught they should always be up top.
I think declaration in running code is a pain in the ...

#### Hypatia's Protege

Joined Mar 1, 2015
3,226
Under Arduino, library
add a statement that the link marked, "here" (Arduino Playground) includes information about where to get the unique sensor for this project.
Good call! --- To this I would add (as regards construction articles in general) that it is imperative that all 'special' hardware is expected to be readily sourcable in small quantities for the foreseeable future...

TTFN
HP

#### OBW0549

Joined Mar 2, 2015
3,566
Good call! --- To this I would add (as regards construction articles in general) that it is imperative that all 'special' hardware is expected to be readily sourcable in small quantities for the foreseeable future...
My opinion: every semiconductor component used in a project-- whether diode, or BJT, or MOSFET, or IC-- should have a link to its datasheet as well as a link to at least one hobbyist-friendly source.

#### #12

Joined Nov 30, 2010
18,223
Good call! --- To this I would add (as regards construction articles in general) that it is imperative that all 'special' hardware is expected to be readily sourcable in small quantities for the foreseeable future...

TTFN
HP
Just paying attention to what I normally do. I'm a precision analog designer. I couldn't use an Arduino to count my fingers, but I know that, "A part you can't find is every bit as good as a part you don't have."
That's one of my, "old sayings" that I invented...right after screaming at my nephew about cleaning up after work.

Last edited:

#### tracecom

Joined Apr 16, 2010
3,944
Following are my comments, some of which may have already been mentioned. I haven't read the posts in the last hour or so.

First, here's the good news. The circuit functions as described and the code runs as written. (The relative humidity and the temperature seem to be close, but I did not verify their accuracy.)

1. There is no period at the end of the first sentence.
2. I guess the article could be described as a tutorial, however tutorials do not normally use the first person plural. In this article, the writer shifts back and forth from using "we" to "you."
3. The semicolon following "elements" is misused. There is only one independent clause. In addition, the sentence is awkwardly constructed, which makes its intent unclear.
4. There should be a comma after "calibrated."
5. There is no 4mm x 4mm QFN package visible in any of the photos. Presumably, there is one inside the four-pin DHT11 module that is shown in the photos, but describing it is misleading to the reader.
6. In the bulleted list, most items are complete sentences, but have no end punctutation. Rather than start so many bullet points with "it," rewrite the bullet points to eliminate the appearance of sentences, and increase their clarity. For example, instead of "It can sense relative humidity up to +- 4.5%," write "Relative humidity accuracy: +- 4.5%", thus eliminating the need for end punctuation.
7. The first sentence under "Arduino Library" is a run-on sentence. It should be broken into its separate thoughts, and punctuated accordingly.
9. Actually, there is no need to extract the files from the zip package in the reference. The IDE will import the zip file as is, thus eliminating the need to restart the IDE.
10. Under "Experiment", the writer shifts back to first person plural pronouns.
11. Under "Hardware", the writer states the quantity required of the single items, but does not state how many jumper wires are needed.
12. In the note, the use of a "4 pin temperature sensor" is mentioned for the first time. This should have been explained in the paragraph where the QFN package was described. (See note 5 above.)
13. Likewise, the mention of "3 pin breakout boards" should have been mentioned earlier, or preferably left out altogether.
14. The sentence about not needing "to attach a resistor with them" is confusing and superfluous.
15. The Fritzing diagram and the photograph of the wired assembly are electrically identical, but physically different. This is a potential source of confusion for the novice.
16. The photograph of the wired assembly is poorly focused on the Uno, and the harsh shadows are distracting and make it difficult to see which pins on the DHT11 are bridged by the resistor.
17. I have no experience with Arduino code, and therefore cannot critique its structure; I do note that, except for the comments, the code is identical to the code included as an example at https://github.com/markruys/arduino-DHT/blob/master/examples/DHT_Test/DHT_Test.pde and presumably written by Mark Ruys. If so, it would have been more forthcoming (or at least more courteous) to point out that Mark Ruys wrote the main code (except for the comments) as well as the DHT library.
18. The bulleted list following "Steps" is poorly placed. In addition, the second bullet is not a step, and is superfluous.

Had this been submitted by a high school student, I would have graded it as follows.

Content: C (but with a deduction for not crediting the code writer)
Originality: D
Structure: D
Grammar and Syntax: D

BTW, I have no intention of going into this level of detail on future edits that I may do.

#### tracecom

Joined Apr 16, 2010
3,944
Just paying attention to what I normally do. I'm a precision analog designer. I couldn't use an Arduino to count my fingers, but I know that, "A part you can't find is every bit as good as a part you don't have."
That's one of my, "old sayings" that I invented...right after screaming at my nephew about cleaning up after work.
It's actually even worse for me if I have something and can't find it. If I don't have it, I may buy it, but if I know I already have one, I'm too tight to buy another one.

#### nerdegutta

Joined Dec 15, 2009
2,684
Tried it on a Linux running computer. Got an error when I opened the Arduino IDE:

Computer running Ubuntu 14.04.

FYI.

Status
Not open for further replies.