Learn ESP32, ESP8266, Arduino, and Raspberry Pi

How to install and use Arduino library

The Arduino environment can be extended through the use of libraries, just like most programming platforms. Libraries provide extra functionality for use in sketches, e.g. working with hardware or manipulating data. Libraries are a collection of code that makes it easy for you to connect to a sensor, display, module, etc. For example, the built-in LiquidCrystal library makes it easy to talk to character LCD displays. We will learn how to install and use different libraries in Arduino.

Tag: Project 125 How to install and use a library in Arduino.

Project resources

  • Sketch: None;
  • Libraries: None;
  • Other attachments: None.

Arduino libraries

A number of libraries come installed with the Arduino IDE:

1.Standard Libraries

  • EEPROM – reading and writing to “permanent” storage
  • Ethernet – for connecting to the internet using the Arduino Ethernet Shield, Arduino Ethernet Shield 2 and Arduino Leonardo ETH
  • Firmata – for communicating with applications on the computer using a standard serial protocol.
  • GSM – for connecting to a GSM/GRPS network with the GSM shield.
  • LiquidCrystal – for controlling liquid crystal displays (LCDs)
  • SD – for reading and writing SD cards
  • Servo – for controlling servo motors
  • SPI – for communicating with devices using the Serial Peripheral Interface (SPI) Bus
  • SoftwareSerial – for serial communication on any digital pins. Version 1.0 and later of Arduino incorporate Mikal Hart‘s NewSoftSerial library as SoftwareSerial.
  • Stepper – for controlling stepper motors
  • TFT – for drawing text , images, and shapes on the Arduino TFT screen
  • WiFi – for connecting to the internet using the Arduino WiFi shield
  • Wire – Two Wire Interface (TWI/I2C) for sending and receiving data over a net of devices or sensors.

The Matrix and Sprite libraries are no longer part of the core distribution.

2.101 Only Libraries

  • CurieBLE – Interact with smartphones and tablets with Bluetooth Low Energy (BLE).
  • CurieIMU – Manage the on-board accelerometer and gyro.
  • CurieTimerOne – Allows to use Timer functions.
  • CurieTime – Allows to control and use the internal RTC (Real Time Clock)

3.Due Only Libraries

  • Audio – Play audio files from a SD card.

4.Due, Zero and MKR1000 Libraries

  • USBHost – Communicate with USB peripherals like mice and keyboards.
  • Scheduler – Manage multiple non-blocking tasks.

5.Zero and all the SAMD21 based MKR boards libraries

  • AudioFrequencyMeter – Sample an audio signal and get its frequency back
  • AudioZero – Play audio files from a SD card
  • RTC – Real Time Clock to schedule events
  • ArduinoSound – A simple way to play and analyze audio data
  • I2S – To use the I2S protocol on SAMD21

6.WiFi 101 and MKR1000 Library

  • WiFi101 – library to be used only with Wifi shield 101
  • WiFi101OTA – Over-the-air updates on MKR1000

7.MKR WiFi 1010, MKR VIDOR 4000, Arduino NANO 33 IoT and Arduino UNO WiFi Rev.2

  • WiFi NINA – library to use the WiFi Nina module of the above boards.

8.Arduino Nano 33 BLE, Nano 33 BLE Sense, NANO 33 IoT, Uno WiFi Rev 2, MKR WiFi 1010.

  • ArduinoBLE – library to use the BLE features of the above boards.

9.Arduino Nano 33 IoT and UNO WiFi Rev. 2

  • ArduinoLSM6DS3 – library to use the LSM6DS3 6 axis IMU available on the Arduino Nano 33 IoT and the Arduino UNO WiFi Rev. 2.

10.Arduino Nano 33 BLE and BLE Sense

  • ArduinoLSM9DS1 – library to use the LSM9DS1 9 axis IMU available on the Arduino Nano 33 BLE and the Arduino Nano 33 BLE Sense.

11.Arduino Nano 33 BLE Sense

  • PDM – library to use the digital microphone MP34DT05, our library PDM can be used also with our ArduinoSound library.
  • ArduinoAPDS9960 – library to use the gesture sensor APDS9960; it senses gesture, color, ambience illumination and proximity.
  • ArduinoLPS22HB – library to use the barometer and temperature sensor LPS22; it is an ultra-compact sensor which functions as a digital output barometer.
  • ArduinoHTS221 – library to use the relative humidity sensor HTS221; it is an ultra-compact sensor that uses a polymer dielectric planar capacitor structure capable of detecting relative humidity variations, returned as digital output on a serial interface.

12.MKR Motor Carrier Only Library

13.MKR FOX 1200 only Library

  • SigFox – library to be used only with MKRFOX1200

14.MKR WAN 1300 only Library

  • MKRWAN – library to be used only with MKR WAN 1300

15.MKR GSM 1400 only Library

  • MKRGSM – library to be used only with MKR GSM 1400

16.MKR NB 1500 only Library

  • MKRNB – library to be used only with MKR NB 1500

17.MKR 1000, MKR WiFi 1010, MKR GSM 1400, MKR NB 1500, MKR RS485 Shield, UNO WiFI Rev.2, Ethernet Shield only Library

  • Arduino Modbus – library to communicate with Modbus Protocol over RS485 and TCP with Modbus clients and servers.

18.MKR GPS Shield Library

  • ArduinoMKRGPS – library to be used with the Arduino MKR GPS Shield

19.MKR RGB Shield Libraries

  • ArduinoMKRRGB – library to be used with the Arduino MKR RGB Shield
  • ArduinoGraphics – library with graphic primitives, works also with the MKR RGB Shield

20.MKR 485 Shield Libraries

  • ArduinoRS485 – library that implements RS485 on the Arduino MKR RS485 shield

21.MKR ENV Shield Library

  • ArduinoMKRENV – library to read all the values measued by the Arduino MKR ENV Shield sensors

22.MKR THERM Shield Library

  • ArduinoMKRTHERM – library to read the sensors connected to the Arduino MKR THERM Shield

23.Esplora Only Library

  • Esplora – this library enable you to easily access to various sensors and actuators mounted on the Esplora board.

24.Arduino Robot Library

  • Robot – this library enables easy access to the functions of the Arduino Robot.

25.Yún devices Library

  • Bridge Library – Enables communication between the Linux processor and the microcontroller on the Yún.
  • Ciao Library – Aims to simplify interaction between microcontroller and Linino OS allowing a variety of connections with most common protocols

26.USB Libraries (Leonardo, Micro, Due, Zero and Esplora)

  • Keyboard – Send keystrokes to an attached computer.
  • Mouse – Control cursor movement on a connected computer.

Once you are comfortable with the Arduino software and using the built-in functions, you may want to extend the ability of your Arduino with additional libraries. There are hundreds of additional libraries available on the Internet for download. To use the additional libraries, you will need to install them.

Step by Step instruction

1.How to install a library with Library Manager

  1. Download and install Arduino IDE software. The latest version of it you can find here –
  2. To install a new library into your Arduino IDE you can use the Library Manager (available from Arduino IDE version 1.6.2).
  3. Open Arduino IDE.
  4. From the menu of Arduino IDE, choose Sketch ->Include library ->Manage Libraries…
how to install library

5.Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation. In this example we will install the Adafruit_BME680 library. Scroll the list to find it, click on it, then select the version of the library you want to install. Sometimes only one version of the library is available. If the version selection menu does not appear, don’t worry: it is normal. You can also type in adafruit BME680 to locate the library.

How to install library
How to install library

6.Finally click on Install button and wait for the Arduino IDE to install the new library.

How to install library

7.Downloading may take time depending on your connection speed. Once it has finished, an Installed tag should appear next to the Adafruit BME680 library. You can close the library manager by clicking on Close button.

How to install library

8.After installing the libraries, restart your Arduino IDE.

9.You can now find the new library available in the Sketch -> Include Library menu.

2.How to download and install a library from .Zip file

Libraries are often distributed as a ZIP file or folder. The name of the folder is the name of the library. Inside the folder will be a .cpp file, a .h file and often a keywords.txt file, examples folder, and other files required by the library. Starting with Arduino IDE version 1.0.5, you can install 3rd party libraries in the IDE. Do not unzip the downloaded library, leave it as is.

  1. Download and install Arduino IDE software. The latest version of it you can find here –
  2. Open Arduino IDE.
  3. From the menu of Arduino IDE, choose Sketch ->Include library ->Add .Zip Library… At the top of the drop down list, select the option to Add .ZIP Library.
How to install library

4.You will be prompted to select the library you would like to add. Navigate to the .zip file’s location and open it with Open button.

How to install library

5.Return to the Sketch -> Include Library menu. You should now see the library at the bottom of the drop-down menu. It is ready to be used in your sketch. The zip file will have been expanded in the libraries folder in your Arduino sketches directory.

How to install library

6.After installing the libraries, restart your Arduino IDE.

7.Please note: the Library will be available to use in sketches, but with older IDE versions examples for the library will not be exposed in the File -> Examples until after the Arduino IDE has restarted.

3. How to install a library manually

When you want to add a library manually, you need to download it as a ZIP file, expand it and put in the proper directory. You can use the 7-Zip software, which you can download here. The ZIP file contains all you need, including usage examples if the author has provided them. The library manager is designed to install this ZIP file automatically as explained in the former chapter, but there are cases where you may want to perform the installation process manually and put the library in the libraries folder of your sketchbook by yourself.

  1. Download and install Arduino IDE software. The latest version of it you can find here –
  2. Open Arduino IDE.
  3. Go to Arduino IDE menu File->Preferences.
How to install library

4.You can find or change the location of your sketchbook folder at  Sketchbook location. You can modify it. Click on OK button when done.

How to install library

5.Go to the directory where you have downloaded the ZIP file of the library. Extract the ZIP file with all its folder structure in a temporary folder, then select the main folder, that should have the library name. Copy it in the libraries folder inside your sketchbook.

How to install library

6.After installing the libraries, restart your Arduino IDE.

Please note: Arduino libraries are managed in three different places: inside the IDE installation folder, inside the core folder and in the libraries folder inside your sketchbook. The way libraries are chosen during compilation is designed to allow the update of libraries present in the distribution. This means that placing a library in the “libraries” folder in your sketchbook overrides the other libraries versions.

The same happens for the libraries present in additional cores installations. It is also important to note that the version of the library you put in your sketchbook may be lower than the one in the distribution or core folders, nevertheless it will be the one used during compilation. When you select a specific core for your board, the libraries present in the core’s folder are used instead of the same libraries present in the IDE distribution folder.

Last, but not least important is the way the Arduino Software (IDE) upgrades itself: all the files in Programs/Arduino (or the folder where you installed the IDE) are deleted and a new folder is created with fresh content. This is why we recommend that you only install libraries to the sketchbook folder so they are not deleted during the Arduino IDE update process.

4. How to use a library in Arduino

  1. Download and install Arduino IDE software. The latest version of it you can find here –
  2. Open Arduino IDE.
  3. To use an existing library in a sketch simply go to the Arduino IDE menu Sketch-> Import Library, and pick from the libraries available. This will insert an #include statement at the top of the sketch for each header (.h) file in the library’s folder. These statements make the public functions and constants defined by the library available to your sketch. They also signal the Arduino environment to link that library’s code with your sketch when it is compiled or uploaded.
how to use library
how to use library

5. How to write a library for Arduino

You can find more information here and here.

Wrapping up

We have learnt how to install and use 3rd party libraries in Arduino.

Check for more DIY projects here.

Thank you for reading and supporting us.

Check for more DIY projects on and!

If you are looking for high quality PCBs PCBWay is the best choice: