Install an Arduino library from GitHub

In this tutorial you will learn how to install an Arduino library from GitHub.

And first of all, why would you want to do that?

If you open the Arduino library manager (on the Arduino IDE: Tools > Manage Libraries), you can already find a lot of libraries to install and use, without any extra step.

But, maybe you will have one of those situations:

  • The library you found on GitHub is not available in the list.
  • You can find the library but not the version you want.
  • You want to get the latest code (not necessarily the latest stable version) to test new functionalities.

If you are in any of those cases, then the solution is to manually install the Arduino library from GitHub.

And let’s see how to do that.


You are learning how to use Arduino to build your own projects?

Check out Arduino For Beginners and learn step by step.


>> Watch this video as an additional resource:

After watching the video, subscribe to the Robotics Back-End Youtube channel so you don’t miss the next tutorials!

Download the Arduino library from GitHub

To install an Arduino library from GitHub, you first have to download it. In this tutorial I will choose the IRremote library as an example. This library allows you to read data from an IR remote controller with Arduino. It can be installed directly from the Arduino IDE, but here of course we’ll do it the GitHub way.

Find the library on GitHub

The easiest way to find the library is simply to search for “name of the library + github” on Google.

In this case, let’s search for “IRremote github”, which leads us to the GitHub page for the library. You can also go on GitHub first and type the library name on the search bar.

Download a specific version of the library…

After you’ve found the library on GitHub, click on “tags”.

This will bring you to all the possible tagged version for the library.

blank

Now, you can choose whichever version you want to download – either the latest on the top, or any previous one. Note: the versions you see on the screenshot above are the ones I got when writing the tutorial. You may have more recent versions available.

Click on the “zip” button on the selected version to download it as an archive.

… or download the latest source code

You might also want to download the library with the very last changes (commits) – not necessary a tagged version.

In this case, from the main page of the library, select a branch (here we keep “master” which is the main branch). Click on “Code” and “Download ZIP”.

Arduino Library - Download Code From GitHub

Install the Arduino library

Now that you have downloaded the zip file for the library, let’s install it. Installing an Arduino library is a super easy process: you just have to extract the zip file and put the library inside the correct folder on your computer.

Find where you need to put the library

Let’s start to find out where you need to install the library.

When you install the Arduino IDE, there is actually a specific folder created just for that.

To find this folder, open the Arduino IDE, and go to File > Preferences.

Here you can find where your Arduino programs (named “sketched”) are saved.

Arduino IDE - Sketchbook location

Now, open a file manager and go to this folder. If you’ve already created some Arduino programs you will find them here. What you will also see is a folder named “libraries”.

Go into this folder. You will find a “readme.txt” file, and also some other folders if you ever installed other Arduino libraries before.

And by just finding this folder, you’ve already solved half of the problem. Now let’s come back to the zip file we’ve just downloaded.

Extract the library

This step is super basic but also super important.

The number one mistake when installing an Arduino library is to forget to extract it. If you try to use the zip file directly it won’t work.

So, extract the library from the zip file. You can use winrar or 7-zip for example.

Now, you will get one folder, which actually contains the library you want to install. With the IRremote library, I get a folder named “Arduino-IRremote-3.6.1”, because I’ve downloaded the version with the 3.6.1 tag.

Note: when you extract on Windows, it might create an additional folder on top of the folder you’ve extracted. For example, to reach the “README.md” file, you could end up going to Arduino-IRremote-3.6.1 > Arduino-IRremote-3.6.1 > README.md. In this case, make sure you don’t use the additional folder. You should be able to reach this file by just going to Arduino-IRremote-3.6.1 > README.md.

Install the GitHub library

Now that you’ve done the 2 previous steps, things are super easy. Just move or copy/paste the extracted library into the Arduino “libraries” folder.

Arduino Library Installed

And that’s it, the library is installed!

Use the Arduino library

Great, you’ve successfully installed an Arduino library from GitHub!

Restart the Arduino IDE

What I would recommend is that you first restart the Arduino IDE. It’s not necessarily needed to restart in order to import the library into your code, but if you want to get access to the examples you’ll have to do it. Also, restarting will probably take you less time than reading this paragraph.

Test the library

Now, the first thing I usually do when I install a library is to make sure it can be found by the Arduino IDE. To do that, just try to import the library. Create an empty program with just an include line. To include the library, make sure you use angle brackets “< >”.

#include <IRremote.hpp>

void setup() { }

void loop() { }

Compile the sketch on the Arduino IDE. If you get something like “fatal error: IRremote.hpp: No such file or directory”, then it means that something went wrong during the installation. In this case, go back to the beginning of the tutorial and re-do all the steps one by one.

If you see “Done compiling”, then success! You can now use the library in your code. You can also load the libraries examples (if any), by clicking on File > Examples > “find your library name here”.

If you want to replace the Arduino library from GitHub

To conclude here, if you ever want to replace the library with a different version, you just have to repeat the same steps (download + install).

Make sure you replace the library with the new downloaded one – you can’t have 2 installed libraries with the same name.

Did you find this tutorial useful?

Do you want to learn Arduino from scratch?

If yes, this course is for you:

Arduino For Beginners - Complete Course

>> Arduino Programming For Beginners <<

LEARN HOW TO PROGRAM ROBOTS

Did you find this tutorial useful?

Do you want to become better at programming robots, with Arduino, Raspberry Pi, or ROS2?

If yes, subscribe to receive exclusive content and special offers!