Add Libraries To Arduino

Move all your sketches and libraries to the cloud in a few clicks! It is super easy with the Import feature on the Arduino Web Editor.

  • 30,157 views
  • 10 comments
  • 63 respects

Apps and online services

About this project

Zipped folders containing sketches and libraries. Make sure your libraries are in a folder called ‘ libraries ’. Be sure not to mix sketches and libraries in the same folder. But let’s import your whole sketchbook in a few clicks, so you will be all set up to start using the Arduino Web Editor. Find your sketchbook. Open Arduino IDE and click to the Sketch tab. Then, click on Include Library Manage Libraries. The library manager will open and you will find a list of libraries that are already installed or ready for installation. Scroll through the list to find the library you want you to install; then select the version of the library you want to install.

Are you sticking to the desktop Arduino IDE because all your work is saved locally? That’s no longer a problem! Our brand new import tool enables you to upload your entire sketchbook with just a few clicks on the Arduino Web Editor. It is particularly handy because it lets you move all your sketches and libraries to the cloud in a single flow.

Once your sketchbook is online it will be available on any device and backed up.

What can you import to the Web Editor?

  • Single sketches in .ino, .pde and .zip format.
  • Libraries in .zip format.
  • Zipped folders containing sketches and libraries. Make sure your libraries are in a folder called ‘libraries’. Be sure not to mix sketches and libraries in the same folder.

But let’s import your whole sketchbook in a few clicks, so you will be all set up to start using the Arduino Web Editor.

1. Find your sketchbook

On your PC find out where your sketchbook folder is (it is called ‘Arduino’, unless you renamed it). On Windows it’s usually under My Computer/Documents/Arduino, on Mac User/Documents/Arduino, and on Linux is $HOME/Arduino.

2. Zip your sketchbook

Make a .zip pack of your sketchbook, you should obtain a file called Arduino.zip. Make sure it is .zip format, any other archive formats will not work.

3. Import your sketchbook to the cloud

Go to create.arduino.cc/editor. For some general information on how to get started on the Web Editor see this tutorial. When you are logged in and ready, hit the import button on the sketchbook panel. A popup with some instructions on how to import files into the Web Editor will be displayed. Press “Import” to continue.

You will now see a file system window, select your Arduino.zip pack. Wait for the import process to finish. If your sketchbook is big (containing lots of files), this may take a while.

Add Libraries To Arduino

4. You are done!

Once the import process is done there will be two reports, one for sketches and one for libraries.

If you already have sketches with the same name on the online IDE, these sketches will fail to import to avoid conflicts.

If you have libraries in your sketchbook, another report will tell you those that got successfully imported. If you have existing custom libraries with the same names, it’ll prompt you to overwrite the existing ones. Be sure to proceed with caution!

Importing a custom library

The Arduino community has written over 700 libraries that you can include in your sketches without having to install a thing. You can browse through all of them in the Library Manager and favorite the ones you like the most.

But what if you want to use your own custom library on the Web IDE? Just zip your custom library and click on the 'Import' button on the Library panel.

If you want to import multiple custom libraries at once you can do so by creating a single zip file which contains all of them and just import it.

A few more notes on the importing process

  • Maximum of 100MB is allowed, for either .zip or individual files, make sure your sketchbook does not exceeds this limit
  • Only sketches and libraries can be imported. Files in the ‘hardware’ folder will be ignored. We suggest you exclude them from your .zip, especially if they’re taking a lot of space.
  • Libraries must be in a folder called “libraries”.
  • Remove backups, unrelated files and things you don’t want to import in general.

Please note that all the libraries that you have added via the Library Manager on the desktop IDE will be already available on the Web Editor without having to do anything. If you want to see their related examples or select a specific version, look for them on the online Library Manager.

More info on the online Library Manager on this tutorial.

Enjoy!

Author

Arduino_Genuino
  • 76 projects
  • 10,686 followers

Published on

December 13, 2016
Write a comment

Members who respect this project

and 58 others

IdeSee similar projects
you might like

How To Add Libraries To Arduino From Github

Table of contents

Write a comment

Introduction:

This video shows how to create a custom Arduino add-on library. As an example, I’ll show you how to write an add-on library for the DHT22 temperature and humidity sensor.

An add-on library allows you to interface your MATLAB code with the Arduino hardware.

Before we start, make sure you have the MATLAB Arduino Support Package installed and also downloaded the third-party Arduino libraries you will use and drag them into your Arduino/Libraries folder. Depending on your operating system, the default folder path may be different.

For the add-on library, you only need to write two files: a C++ header file which is downloaded to the Arduino, and the second file is a MATLAB class to send commands to the Arduino and get responses.

There are three steps to create an add-on. The first step is to set up the folders. The next step is to write the C++ Header File. And the last step to write the MATLAB Add-On Class file.

Folders:

Firstly, you must create a folder called “+arduinoioaddons” with a subfolder whose name starts with a “+”. This is where you will keep your MATLAB Class File and another subfolder called “src” which has the C++ header file.

Add Libraries To Arduino

C++ Header File

Now let’s look at how to write the C++ header file.

Be sure to include “LibraryBase.h” to extend the class needed to create your add-on library.

Also include any header files needed for your custom code. In my case, I included 'DHT.h'.

Next, define a set of command IDs for later use, to deal with commands sent from MATLAB.

As you can see, I have defined these four command IDs for my sensor.

Now, define your add-on class and make it inherit from LibraryBase since it is a required for the add-on framework.

You can also define any members needed for your class.

For the constructor, make sure the name matches your class, then define the name of your add-on library.

Next override the commandHandler method, which is called every time MATLAB sends a command to the Arduino. We are past the command ID, dataIn, and the size of that data.

The Arduino uses the command ID to determine which method to execute. Here you can wrap the third-party methods. In my case, I wrap methods from the Adafruit DHT library.

When you send a command from MATLAB, you can pass data to use here. In this example, I had MATLAB send the sensor ID and the pin to create the new sensor object.

It is required by the framework that for every command, you must send data back to MATLAB using the method sendResponseMsg().

If you'd like to get debug information, you can also define debug strings and send the information back to MATLAB using debugPrint().

In my code, I do the same for all the command ID’s: create, delete, read temperature, and read humidity.

MATLAB Add-On Class

Now you need to write the MATLAB class. Create the file in your +Adafruit folder.

This class must inherit from LibraryBase. Set these properties as the same command IDs we used in the header file.

These properties are also required for the framework. Replace the LibraryName with your library, add any dependent and third-party libraries, and change these to match your C++ header file and class name.

You can also add more properties, depending on what you need for your add-on.

Write a constructor to initialize the add-on. You must assign the Arduino object as the add-on object’s parent, which is inherited from LibraryBase.

Here I do some error handling. Then I initialized the Pin property, configured the pin to Digital Input, and called a method to create the sensor.

For each method you want to execute on the Arduino, you must use sendCommand(). You must pass the command ID, library name, and any necessary data to the Arduino. Here I pass the sensor ID and terminal.

To receive data back from the Arduino, save the returned data from sendCommand(). For example, in the readHumidity method, I save the humidity value that is returned.

Running

After writing those two files, in the command window use addpath() to add the location of your add-on folder. You can check by using the command listArduinoLibraries to see if your library is available.

Connect the Arduino hardware to MATLAB using the arduino() method with the port, board, and library. To see the debug messages, use ‘TraceOn’, true.

Add Library To Arduino Ide From Github

a = arduino(‘com8’, ‘Uno’, ‘libraries’, ‘Adafruit/DHT22’, ‘TraceOn’, true)

Now connect to the sensor using the addon() method. In my case, I will pass the Arduino object, library, and pin.

s = addon(a, ‘Adafruit/DHT22’, ‘A0’)

We can call the readTemperature(s) and readHumidity(s) methods to read the measurements from the sensor and use the data in MATLAB.

Add Libraries To Arduino Ide

That’s all you need to do to write your own add-on libraries.

How To Add Arduino Libraries

For more help, refer to the documentation on how to create a custom add-on library for Arduino.