Libraries are helpers that you’ll soon find indispensable. They handle many tasks in the background that you would otherwise have to program manually. This includes, for example, measuring temperature and humidity with the DHT11 sensor.
You can install and update most libraries directly in your Arduino IDE. Once installed, you include them at the beginning of your sketch and can then access their functions. But let’s take it one step at a time. 🙂
The Library Manager
You’ll find the entry “Manage Libraries” in the Tools menu of your Arduino IDE – or in its sidebar (the pile of books)
Let’s take a quick look at the contents of this window:
At the very top, you’ll find the search field where you can search for libraries. More on that in a moment. Below that is the ‘Type’ dropdown menu: Here you can set various filters. You’ll rarely use the ‘Topic’ menu – here the libraries are sorted by subject. In most cases, however, you’ll simply use the search field.
The Library for the DHT11
Enter “Adafruit Unified Sensor” in the search field – the search results will appear automatically after a short time. In case the right library is not at the top, scroll down a bit until you find the right entry:
To the left of the Install button, you can select the version you want to install. In most cases, this is the current version – so you don’t need to change anything here. Click “Install”.
For the DHT11 sensor, however, you need two libraries. Next, search for “DHT11”. In the results, the entry “DHT sensor library” now appears (maybe a bit further down).
Now also click on “Install” to download the latest version.
Notes: You may be asked by the Library Manager if you want to install additional required libraries. Confirm this with “Yes”. Please also don’t be confused by the version numbers in the screenshots above: Libraries are constantly being updated, so the number may already be higher for you.
You now have all the libraries you need for your measurement. Next, you’ll learn how to include them in your sketch and use them to output temperature and humidity in the Serial Monitor.