Several techniques can be used to make the Arduino Web Editor pick a specific library when multiple libraries with the same name are available. One method is importing a copy of the library you want to use. Imported libraries are given preference over the pre-installed libraries (full details here). The technique works with any library, but we’ll use the DS18B20
library as an example in this guide.
See this forum post if you’re interested in learning alternative methods to the technique described in this guide.
-
From the menu on the left side of the Arduino Web Editor window, click “Libraries”.
-
Click the “Library Manager” button.
-
Search for “DS18B20”.
-
If the star to the right of the library is not already filled, click the star to add the library to your “Favorites”.
-
Click the “Done” button.
-
From the menu on the left side of the Arduino Web Editor window, click “Libraries”.
-
From the Libraries pane of the Arduino Web Editor window, click the “Favorites” tab.
-
Find “DS18B20” in the list of favorite libraries and hover the mouse pointer over
DS18B20
. -
Click the downward pointing triangle to the right of
DS18B20
. -
Click “Download Library”.
-
Click the upward pointing arrow button (Import) to the right side of the “Library Manager” button.
-
If you get a pop-up about importing your sketchbook, click the “Import” button.
-
Select the downloaded library (DS18B20-1.0.0.zip).
-
Click the “Open” button.
-
Wait for Arduino Web Editor to display the notification that the library was successfully imported.
-
Click the “OK” button.
This will cause the version of the library you imported to always be used by all sketches (1.0.0 in this case), so you may want to occasionally check to see if the library author has released a new version of the library and repeat the process with the new version in order to take advantage of any improvements or bug fixes that have been made to the library in the new release.
Again, this general technique will work for any library, it’s not specific to the DS18B20
.
Occasionally importing the stock library alone won’t cause it to have priority. The reason is that even though this gives the library the highest “Location Priority”, there are other factors that are prioritized higher. Most often, this would be the “Library Name/Folder Name Priority”. The solution is to give the imported library a perfect “Library Name/Folder Name Priority” score. Because the imported library is installed to a folder matching the library name, these are both controlled by the name value in the library.properties file. So this workaround requires you to edit the library.properties file before importing the library, as demonstrated here.