Previously, the mode was configured to INPUT and then written HIGH,
which works on AVR but isn't very portable. Instead, this uses the
INPUT_PULLUP pin mode (available since Arduino 1.0.1) which is portable.
By cleverly setting _lastreadtime in begin() to make sure that it looks
like the last read was alrady 2000 ms ago, even on startup when millis()
still returns 0, there is no longer a need to keep a separate
firstreading variable, saving a byte of memory and a bit of code.
There was some handling of millis() overflow that is not needed.
Standard unsigned subtraction and wraparound already works as expected,
so this extra check can be removed (it even hurts, since it introduces 2
seconds after a wraparound where no new data will be read, even if it
could otherwise happen).
Also, this prevents calling millis() a second time, since its value is
already known.
This allows forcing a read, even if the previous read was less than 2
seconds ago. This is useful in cases where the millis() timer is not
reliable, such as when sleeping. In this case, it is up to the caller to
ensure that at least 2 seconds elapse between calls with force set to
true.
Added constructor parameter to allow for different timing needs. It has
the a default value of 6 which is the original value, so it should be
backwards compatible
Added a basic #ifndef DHT_H to the dht.h file so that if you have a
larger program and want to access the sensor from a different file, you
don't import it twice.