2 issues I see with the example:
a) I'm not a native english speaker, but to me, on top of the page, "sampling rate" of "2 times/sec" for dht-22 is wrong. From code and pdf you can see that you can't ask for data faster than at 2 seconds.
As such, I would change the top of the page to read either "0.5 times/sec" or "1 time at 2 seconds".
b) use of SENSOR_TEMP_OFFSET is wrong. Because depending on how the controller wants this sensor's data (Celsius | Fahrenheit), the offset will be different. If you happen to change the metric system value in the controller and ask for the data (after sensor restart let's say), you'll get a different value than expected).
I would do:
-
- add to the comment for SENSOR_TEMP_OFFSET that we're talking about a Celsius offset
-
- and move the statement "temperature += SENSOR_TEMP_OFFSET;" before the conversion to Fahrenheit.
Regards.