Unable to compile with DS18B20.h and OneWire.h

This appears to be a recurring problem. I’m adding a DS18B20 to my board to use with my Photon, and included relevant libraries (DS18B20.h v0.1.8 and OneWire.h v2.0.1).

I’m using the Web IDE. My system firmware target is 0.7.0. I included the libraries via the Web IDE (e.g., “Include in Project”). The include statements were added automatically by the IDE.

When I compile, I get: DS18B20.h: No such file or directory

I also get: Onewire.h: No such file or directory

This happens whether I use <> or “”.

Are these libraries out of date? Are there alternative libraries/components that I should use for temperature sensing? Your help would be very much appreciated.

Could you make a screenshot where we can see the code, includes on the left, ad error on the bottom?
Alternatively, a share link from the web ide would allow us to see an exact copy of your project.

The w needs to be a capital W in OneWire.h

But for the DS18B20 library you don’t need to import OneWire.h since the library already features a dependency which instructs the build environment to import that automatically for you.

What system version are you targeting?

When I build any of the contained samples they build just fine with v0.5.3+
Also try adding a blank line before the include statement (the Web IDE preprocessor sometimes has glitches).

Thanks @Moors7 and @ScruffR – I mistyped in my post, and actually had OneWire.h correctly in my code with the W capitalized.

I also noticed in DS18B20.h that OneWire.h was included. I went ahead and removed OneWire.h from my includes, but kept the library installed (unless I should remove that too?).

My system firmware target is 0.7.0 (also on the device). Included libraries include: blynk (0.5.4), OneWire (2.0.1), and DS18B20 (0.1.8).

The only includes are <DS18B20.h> and <blynk.h>. I copied the compilation error below:

Processing gijutsuapp.ino
Checking library blynk…
Installing library blynk 0.5.4 to lib/blynk …
Library blynk 0.5.4 installed.
make -C …/modules/photon/user-part all
make[1]: Entering directory '/firmware/modules/photon/user-part’
make -C …/…/…/user
make[2]: Entering directory '/firmware/user’
Building cpp file: src/gijutsuapp.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p …/build/target/user/platform-6-msrc/
arm-none-eabi-gcc -DSTM32_DEVICE -DSTM32F2XX -DPLATFORM_THREADING=1 -DPLATFORM_ID=6 -DPLATFORM_NAME=photon -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD006 -DUSBD_PID_CDC=0xC006 -DSPARK_PLATFORM -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=6 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DSYSTEM_VERSION_STRING=0.7.0 -DRELEASE_BUILD -I./inc -I…/wiring/inc -I…/system/inc -I…/services/inc -I…/communication/src -I…/hal/inc -I…/hal/shared -I…/hal/src/photon -I…/hal/src/stm32f2xx -I…/hal/src/stm32 -I…/hal/src/photon/api -I…/hal/src/photon/include -I…/hal/src/photon/wiced/security/BESL/host/WICED/ -I…/hal/src/photon/wiced/security/BESL/include -I…/hal/src/photon/wiced/security/BESL -I…/hal/src/photon/wiced/security/BESL/crypto -I…/hal/src/photon/wiced/WWD/include/ -I…/hal/src/photon/wiced/platform/include/ -I…/hal/src/photon/wiced/platform/GCC/ -I…/hal/src/photon/wiced/security/BESL/supplicant/ -I…/hal/src/photon/libraries/crypto -I…/platform/shared/inc -I…/platform/MCU/STM32F2xx/STM32_USB_Host_Driver/inc -I…/platform/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I…/platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I…/platform/MCU/STM32F2xx/STM32_USB_Device_Driver/inc -I…/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc -I…/platform/MCU/shared/STM32/inc -I…/platform/MCU/STM32F2xx/CMSIS/Include -I…/platform/MCU/STM32F2xx/CMSIS/Device/ST/Include -I…/dynalib/inc -Isrc -I./libraries -Ilib/blynk/src -I. -MD -MP -MF …/build/target/user/platform-6-msrc/gijutsuapp.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DBOOTLOADER_SDK_3_3_0_PARTICLE -DPARTICLE_DCT_COMPATIBILITY -DSPARK_PLATFORM_NET=BCM9WCDUSI09 -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc -DLOG_INCLUDE_SOURCE_INFO=1 -DPARTICLE_USER_MODULE -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0x80A0000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=5 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,2,207 -DMODULE_DEPENDENCY2=0,0,0 -D_WINSOCK_H -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="“app”" -fno-exceptions -fno-rtti -fcheck-new -std=gnu++11 -c -o …/build/target/user/platform-6-msrc/gijutsuapp.o src/gijutsuapp.cpp
gijutsuapp.ino:2:21: fatal error: DS18B20.h: No such file or directory
compilation terminated.
…/build/module.mk:267: recipe for target ‘…/build/target/user/platform-6-msrc/gijutsuapp.o’ failed
make[2]: Leaving directory '/firmware/user’
make[2]: *** […/build/target/user/platform-6-msrc/gijutsuapp.o] Error 1
…/…/…/build/recurse.mk:11: recipe for target ‘user’ failed
make[1]: *** [user] Error 2
make[1]: Leaving directory ‘/firmware/modules/photon/user-part’
…/build/recurse.mk:11: recipe for target ‘modules/photon/user-part’ failed
make: *** [modules/photon/user-part] Error 2
Error: Could not compile. Please review your code.

As we can’t know what your exact code looks like, I’d like to reiterate on the request for a Screenshot, so we know what we’re dealing with.
Also, make sure you’re using a version of system firmware >0.5.3.

1 Like

Since you are using Web IDE use the SHARE THIS REVISION feature to provide us with a link to your exact setup to try making it build.

Yes, remove the library too.

1 Like

Is there an email address that I can share this to?

If there’s nothing private in there, just post it here? Otherwise PM us.

1 Like

This will blow your mind…

There’s something private in my file, so instead of taking it out, I tested adding DS18B20.h to another app file without anything private (a local copy of servo.ino). If the compiler complained there, I planned to share that file.

That file compiled!! Excuse me, WT*?

So I pasted my code into that file, overwriting the entire thing. It compiled!

I went back to my old file, and It still didn’t compile with DS18B20.h. Maybe it’s in a bad file location, or has a path missing? I created it with “Create New App”.

Who knows, but I’m cool with calling this solved because it compiles now, and I’ll create future files this way. But if you want to debug this, let me know.

Thanks so much for your help!!

It could be that you had a version pre 0.5.3 selected when you created that project and imported the library. Once the project was setup for that version there is no changing of the project layout.

That would explain what you are seeing.

1 Like

Thanks @ScruffR – I agree because I remember updating the version at one point after I created the project, and wasn’t aware that I couldn’t change the layout.

1 Like