Adding libraries to the IDE

Manually adding libraries supplied to aid you connect and talk to a particular component, be that a temp sensor, heart sensor etc. or a library that just has some useful functions, are plentiful on the internet. But how do you add them to your Arduino set up and use them?

First you need to find your library. For example perhaps you’ve bought a BMP280 pressure and temperature sensor. I would simply type in “BMP280 Arduino GitHub” into your internet search engine, and if that doesn’t bring much help try adding “Adafruit” to that search query. Why GitHub? Most peoples work on such things as libraries are intended for others to use and alter and so Github is the place that most people place this code. Why Adafruit? Adafruit has put in a lot of effort creating drivers for any product they supply and these products are usually based on common chips that you can buy from various places on the internet. Adafruit products can be a little bit more expensive than a cheap product from another supplier. But that supplier has not created the drivers, Adafruit put the effort into writing and making this code openly available and like the Arduino project itself it’s considered perhaps polite to buy something from them at some point.

Once you’ve got your library you go to the following menu (shown as screenshot below as well)

“Sketch->Include Library->Add .zip library…”

Select the file you’ve just downloaded and wait a few seconds whilst the zip file contents are unpacked and put into your libraries folder. A confirmation will appear on your Arduino IDE status bar.

Examples
Most libraries (if not all) come with some examples to get you going, these can be find on the menu “File->Examples->……“.

Using your library
Always start by looking at the example supplied and you will see somewhere very near the top a line that reads something like

include “MyNewLibrary.h”

Where “MyNewLibrary.h” will refer to the library you just added. Adding this line allows you to access all the functions and classes within this library.

Possible Issues – “Spurious .github folder” found.
This can come up as a warning as as a warning it can be ignored, but it is annoying to see, I hat any left over warnings in any code I write whether I deam them as important or not (as in this case). All this means is that in the original Zip file downloaded it includes a folder that the Arduino IDE was not expecting (and it ignores). If you look in the Zip file downloaded you will see a folder called “.github“. Usually these occur on Adafruit libraries but I’m unsure if it is unique to them. You can if you’ve not already imported it deleted this from the Zip file before adding as a library to your Arduino IDE. If you’ve already added it then you need delete it from where the Arduino has placed this library.

Removing the Spurious .github folder once installed
Select menu option “File->Preferences…” At the top of the preferences window you will see “SketchBook location“. This is where all your sketches are saved by default and where the libraries folder is located. Take a note of this location (or copy the string by selecting and CTRL +C).

Open up a filer window  and paste (or write in) the location from the previous step. Within the window opened you will see a “libraries” folder. Open it and within this folder you will see your newly added folder for your chosen library. Open this and you will see the “.github” folder. Just delete it and you will no longer get this message. The folder is unimportant to the operation of the library you have just added.

That’s it, hope this helps some of you get rid of this annoying warning!