Skip to content

How to Install Arduino Libraries

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about How to Install Arduino Libraries. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

You try to include a library in your Arduino sketch and get fatal error: <LibraryName>.h: No such file or directory, or the Arduino Library Manager does not show the library you need. Without the correct library, sketches fail to compile.

Quick Fix

WRONG — manually downloading and extracting without using the Library Manager:

# (works but creates version conflicts and missing dependencies)

RIGHT — use the Arduino IDE Library Manager:

# Sketch → Include Library → Manage Libraries
# Search for "DHT sensor library" by Adafruit
# Select the latest version and click Install
# (install all dependencies when prompted)

Fix 2: Install via Library Manager (CLI)

arduino-cli lib install "DHT sensor library"
# Downloading DHT sensor library@1.4.4...
# DHT sensor library@1.4.4 downloaded
# Installing DHT sensor library@1.4.4...
# Installed DHT sensor library@1.4.4

Install all dependent libraries:

arduino-cli lib install "Adafruit Unified Sensor"
# Downloading Adafruit Unified Sensor@1.1.9...
# Installed Adafruit Unified Sensor@1.1.9

Fix 3: Manual Installation (ZIP)

WRONG — extracting the library directly into libraries/ without the correct folder structure:

unzip library.zip -d ~/Arduino/libraries/
# The extracted folder must contain the .h and .cpp files at the top level
# Not nested inside an extra directory

RIGHT — check the folder structure:

# The ZIP should extract with the library folder name:
# ~/Arduino/libraries/DHT-sensor-library/DHT.h
# ~/Arduino/libraries/DHT-sensor-library/DHT.cpp
# (not ~/Arduino/libraries/DHT-sensor-library/DHT-sensor-library/DHT.h)

# In Arduino IDE: Sketch → Include Library → Add .ZIP Library
# Select the ZIP file directly

Fix 4: Fix Missing Dependencies

WRONG — installing only the main library:

// #include <DHT.h>    // requires "Adafruit Unified Sensor" as dependency
// fatal error: Adafruit_Sensor.h: No such file or directory

RIGHT — install all dependencies:

arduino-cli lib install "DHT sensor library" "Adafruit Unified Sensor"
# (or use the Library Manager GUI which prompts for dependencies)

Fix 5: Check Library Path

ls ~/Arduino/libraries/
# DHT-sensor-library  Adafruit-Unified-Sensor  WiFiNINA

If your libraries are in the wrong location, move them:

mv ~/Downloads/DHT-sensor-library ~/Arduino/libraries/

Fix 6: Platform-Specific Libraries

Some libraries only work on specific boards:

// #include <WiFiNINA.h>  // only for MKR WiFi 1010, Nano 33 IoT
// #include <Ethernet.h>  // requires Ethernet shield

Check the library documentation for board compatibility before installing.

Use DodaTech's Library Sync to manage Arduino libraries across multiple machines, ensuring every developer has the correct versions and dependencies.

Prevention

  • Use the Library Manager for dependency resolution.
  • Keep libraries updated via Library Manager.
  • Use <a href="/iot/arduino/">Arduino</a>-cli for reproducible builds in CI.
  • Check library documentation for board compatibility.
  • Clean the libraries/ folder periodically and reinstall.

Common Mistakes with library install

  1. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  2. Using return to exit a function early instead of wrapping a pure value in the monad
  3. Mixing let bindings with <- bindings in do notation, producing type errors

These mistakes appear frequently in real-world Arduino code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why does the Library Manager show "No libraries found"?

Check your internet connection. The Library Manager downloads the library index from Arduino's servers. If behind a proxy, configure it in File → Preferences → Proxy Settings. On restricted networks, use manual ZIP installation.

How do I update a library?

In the Library Manager, libraries with updates show an "Update" button. Click it to upgrade to the latest version. For CLI: <a href="/iot/arduino/">Arduino</a>-cli lib upgrade "LibraryName". Always check the changelog for breaking changes before updating.

Can I use libraries from other platforms (PlatformIO)?

Yes, PlatformIO uses the same library format. Libraries installed via PlatformIO are stored in ~/.platformio/lib/ and use a different directory structure. To use a PlatformIO library in Arduino IDE, copy the source files manually.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro