Using Code Libraries
With this project, we start doing something new: using code libraries.
A library is a chunk of code that is specifically written to do a common task. Sensor code libraries give makers the means to access the functions of a sensor (as well as other electronic components) fairly confidently, because the code has been tested by the author and updated by people who use it.
Many sensors, including the DHT-22, have their own sensor code libraries, found on repositories like GitHub. The DHT-22’s library was written and placed on GitHub by Ben Adams for hobbyists to use in building microprocessor-based gadgets that include this sensor. This saves everyone the trouble of duplicating his effort. (We’ve also forked a DHT-22 code library from Ben Adams’s repository, containing updates that will enable the sensor to work with the autumn 2011 Arduino 1.0 code update.)
Before you tear your hair out writing a sensor code library from scratch, search around to see if one already exists. You’ll be glad you did. If you do end up writing an original code library, consider sharing it with fellow makers on a site like GitHub.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access