TinuDHT – ATtiny Library for DHT11

Ever wanted to do a project with that cheap DHT11 temperature/humidity sensor and did not want to go the Arduino way but with a simple ATtiny85? You probably know already about  the issues with the existing Arduino based libraries running on the ATtiny microcontrollers, but can’t deal with them. TinuDHT is our answer to this.

TinuDHT is a C library for working with the DHT11 temperature/humidity sensor intended to be used with the Tinusaur but should also work with any other board based on ATtiny85 or similar microcontroller.

DHT11

The DHT11 is very basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor for measurements, and sends out the info to the data pin. It is relatively simple to use it, but requires precise timing to retrieve the data correctly. One disadvantage of this sensor is that you can get new data from it no more often than once every 1 or 2 seconds.

The primary problem with the direct use of the Arduino libraries is that the ATtiny85 and Tinusaur in particular do not have enough resource to handle the send/receive process properly, i.e. not enough CPU power, in result of which the timing of the signals that are sent to the sensor and received from it become messed up. In addition those libraries use Arduino specific code and/or C++ specific syntax which makes them incompatible with the plain C language.

TinuDHT library is based on DHT11Lib code. It was adapted for ATtiny, removed Arduino dependencies and timing was adjusted to work well on ATtiny85 at 1 MHz. There are few other changes and optimizations for speed and size.

TinuDHT is written in plain C and does not require any additional libraries to function except those that come with the WinAVR SDK. Check our WINAVR Setup guide.

Please go to TinuDHT page to see the full document.

The source code of the TinuDHT library is available at https://bitbucket.org/tinusaur/tinudht.

Tinusaur Board DHT11 LCD Battery

2 thoughts on “TinuDHT – ATtiny Library for DHT11”

  1. Hi, I try to use your TinyDHT library with a ATtiny85 but I see “H:\arduino cu de toate\arduino-1.0.4-windows\arduino-1.0.4\libraries\TinuDHT\tinudht.c: In function ‘tinudht_read’:
    H:\arduino cu de toate\arduino-1.0.4-windows\arduino-1.0.4\libraries\TinuDHT\tinudht.c:64: error: ‘for’ loop initial declaration used outside C99 mode”… I try to change in tinudht.c declaration of the value “i” outside loop but don’t work…
    Any ideea?

    Reply
  2. This is because the library uses newer version of the C/C++ compiler that the one you’ve got. With the most recent versions of the IDE’s this shouldn’t be a problem.

    Let me know if you still have the problem.

    Reply

Leave a Comment