EP1000

Libraries

The power and convience of the Arduino system is the extensive availability of libraries for almost every sensor and acutator availble. To use a device, one only needs to interface the device to the Arduino system (following the many tutorials available on the Internet), locate the library (code to interact with the device), load the library into the IDE, write and compile your application.

This makes the Arduino a very versatile system which is easy to implement and available to hobbists to expert.

The library consists of

Loading the library

To use the library we need to “load” the library into the Arduino system. There are 3 methods to do this:

First, let us note down the folders where the libaries may be located:

Library Folder location
Arduino IDE System Libraries C:\Program Files (x86)\Arduino\libraries
User libraries D:\Users<username>\Documents\Arduino\libraries

You can locate the User library folder by using the IDE > File > Preferences to locate the Sketchbook location where the user library location can be found.

Arduino IDE Managed Libraries

The simplest method of loading a library is to use the Library Management tool in the IDE. This is located using IDE > Tools > Manage Libraries

IDE Library Management Tool

Type in the name of the library you want to load and click OK. The Arduino IDE will handle the reat. The library and the example file(s) will be automatically downloaded and installed. The library will be automatically installed in the User Library Folder.

This is the simplest way of loading a library. The library may now be included using the IDE > Sketch > Include Library. You will be able to file the new library in the list. clicking on the library will inert the “#include " line in your code.

Problems: Sometimes the library you require is not in the System Library list because the device is new or rarely used, you may have re-written the library or is only available for a particular version of the device.

Compressed Libraries

The second method requires you to

  1. Manually download the library from the device site as a compress (.zip) file.
  2. Use IDE > Sketch > Include Library > Add ZIP Library to point to the downloaded file.
  3. The Arduino IDE will do the rest and install the library in the User Library folder.

Include ZIP library

This method of loading the library allows you to select a particular library for your code. Hence, you can include your own libraries or a particular library the works only with your board.

Problems: There are so many libraries out there. You need to know specifially which one you would like to use and once you ahve checked that it is working, put a note in your code where you have obtained your code for future reference.

Manually installed library

This is the most manual method of installing a libary where the user have full control. Note however, that this method is not recommended as you can make mistakes or located your files in wrong folders etc. This method requires you to

  1. Manually download the library from the device site. This is usually a compress (.zip) file.
  2. Extract the files from the ZIP folder, which usually creates a folder with the name of the libary.
  3. Check that the folder has the .h and .cpp files (you may decided to exclude the example files/folders)
  4. Copy the folder (with the .h and .cpp file) to either the Arduino System Library Folder or the User Library folder.
  5. Restart the Arduino IDE

The library will be displayed and included the normal way as in the above 2 cases. This allows you to even include libraries that you have written yourself.

Problems: Errors may occur that will halt your IDE, which may give rise to other problems in troubleshooting.

References:

  1. Adafruit: All About Arduino Libraries
  2. Sparkfun: Installing an Arduino Library
  3. Youtube: Arduino Libraries! How to Install them properly! Tutorial showing you 3 different ways

 

Tested Libraries

Use the following table as a guide to the tested libraries and code for your IO devices : IO Devices Collection

Here is a link to some sample code (incomplete)

Updated January 2021