Add Libraries To Arduino

Add Libraries To Arduino

  1. Add Libraries To Arduino
  2. Add Library To Arduino Ide

You want to do a cool project with Arduino and sensors. But you need an external library to install in Arduino. Either you don’t know how to install it or you know but you are getting error every time you try to add or even after adding library, it is showing there is no library. It is little frustrating as you are not doing anything with project but stuck in between libraries. And trying to figuring out why you are not able to add library and even after adding library, error is showing or code is not compiling. We will look 4 ways to add library in Arduino without getting error and also discuss some common error you will get while compiling with libraries. The method I am showing will solve your problem. So let’s get started.

Mar 15, 2020 Open Arduino IDE. Go to Sketches include library Manage Libraries Type library name install Type the name of library and click install. Drawback is only popular libraries can be found by this method. This will automatically add the parent directory of the new library to the project-specific library search path: Directories listed in the “Extra library directories” field will get searched for libraries same way as the system-wide directories, such as Arduino Libraries. If the Arduino tools keep finding incorrect types. In the Arduino IDE, navigate to Sketch Include Library Add.ZIP Library. At the top of the drop down list, select the option to 'Add.ZIP Library'. You will be prompted to select the library you would like to add. Navigate to the.zip file's location and open it.

Downloading Library:

You can download libraries from Github. Type sensor name and at the end type Github, you will get sensor library, download it. It will be in zip file.

Add Libraries To Arduino

How to check library is installed:

Go to File > Example > (You can see list here)

Method 1 (Easiest): ADD .zip Library

Open Arduino IDE. Go to Sketches > include library > Add .zip Library > select file location > click open.

Your Library is added successfully.

Method 2 : Manage Libraries

Open Arduino IDE. Go to Sketches > include library > Manage Libraries > Type library name > install

Type the name of library and click install. Drawback is only popular libraries can be found by this method.

Method 3 (Manually): Copy Paste library to Arduino Directory

First we need to unzip our zip library. Copy the unzip library folder.

Arduino

And go to C:Program Files (x86)Arduinolibraries paste that folder in libraries.

Arduino

If your Arduino IDE was opened at that time and close it. And Again restart Arduino IDE. So it will include that library.

Method 4 (Manually): Renaming & Deleting files.
Arduino

You did everything but still library is not showing up and getting errors.

Sometimes downloading library from internet, zip file name is with something master or any other name. Causes problem when when we install the library.

Add Library To Arduino Ide

Add

I am giving here one example with DHT library. You can download and try this exercise.

You can try to add DHT library with method 1 (Add .zip Library) and method 3 (Copy Paste library to Arduino Directory). It will show library is added but when you try to compile code it will show error. Here we are going to solve this issue.

change “DHT-sensor-library-master” library folder name to only “DHT” (I am talking about only for this example you can change name according to your library name) in arduino libraries , C:Program Files (x86)Arduinolibraries

Also make sure folder name and file .h & .cpp file name is same. If require delete other .h & .cpp file in that folder, only keep DHT.h & DHT.cpp file with examples.

Restart the Arduino IDE. Now you can see it is complied successfully.

Common Error with Libraries and Compiling in Arduino:
  1. Make sure spelling is correct in code as well as file in Arduino libraries. look for upper case and lower case as it is case sensitive.
  2. Go to Tools > Board:Make sure Board is Arduino Uno or Nano whatever you are using. Because it is compiling code for that board. For example if I am trying to compile code of Mouse for Arduino Uno or Nano. It won’t compile because it is meant for Leonardo and Due boards only.

3. Go to Tools > Port select correct port.

These are the most common things which causes error while compiling and Now you know how to solve it.

Till then keep learning keep making.