Create Editor using incorrect library

I am trying to include the library DS18B20 (v1.0.0) in my code but when I try to compile it, it uses the wrong library despite me favouriting the correct one. Any suggestions how to force it to use the correct one?

The compiler error is as follows:

Multiple libraries were found for "DS18B20.h"
Used: /home/builder/opt/libraries/latest/ds18b20_rt_0_1_7
Not used: /home/builder/opt/libraries/latest/onewirehub_2_2_1
Not used: /home/builder/opt/libraries/latest/maximwire_1_0_2
Not used: /home/builder/opt/libraries/latest/ds18b20_1_0_0
Multiple libraries were found for "OneWire.h"
Used: /home/builder/opt/libraries/latest/onewire_2_3_5
Not used: /home/builder/opt/libraries/latest/sdu_ags_sensorboard_1_0_0
Not used: /home/builder/opt/libraries/latest/max31850_onewire_1_1_0
Using library SNU at version 1.0.2 in folder: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.9/libraries/SNU
Using library SPI at version 1.0 in folder: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.9/libraries/SPI
/tmp/972259600/Temperature_monitor_feb05a/Temperature_monitor_feb05a.ino:3:13: error: invalid conversion from 'int' to 'OneWire*' [-fpermissive]
DS18B20 ds(2); // temperature sensor onewire data pin D2
^

Unfortunately, favoriting doesn't have any impact on which library gets priority.

Although there are several possible techniques that can be used to influence Arduino Web Editor to pick the library you want (see this if you're interested in learning about all of them), in this case only one of them is usable. But that's fine, we only need one!

The solution is to import the library you want to use. Imported libraries are given preference over the pre-installed libraries (see this if you're interested in the full details).

  • 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" (I know you said you already did this, but I want to provide the complete instructions in case they might be useful to others).
  • Click the "Done" button.
  • 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 popup 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.

This general technique will work for any library, it's not specific to the DS18B20.

2 Likes

Worked perfectly, thanks for the very quick reply.

You're welcome. I'm glad to hear it's working now. Enjoy! Per

importing Onewire.h solved the “serial port disappearing after upload” problem! Thank you.

  • regarding DS18B20 on Nano IoT, onewire.h and DallasTemperature.h upload bug using web editor.