I want to add include path

lib_dir sets the path of the one folder in which libraries can be found, by default lib/ of the project folder. You are putting there multiple -I options, which is wrong. Also this option is only valid for the [platformio] section. But why change this at all?

Why change this? If D:/00_Schaffengott/107_FireStation/02_Firmware/STM32F103_JTAG_TEST/ is the project path, then that path plus src/ will already be the default src_dir.

I think you meant [env].

  1. If D:/00_Schaffengott/107_FireStation/02_Firmware/STM32F103_JTAG_TEST is your project folder, then instead of the first option, you should be using include_dir
  2. While the second line may attempt to include the headers found in that folder, none of the library files will be compiled because they are excluded from the build due to the compatibility settings lib_deps = adafruit/Adafruit HTU21DF Library@^1.0.5 is Arduino library, PIO recognizes that and excludes it. If you want to still force inclusion, use lib_compat_mode = off in the platformio.ini (docs). Then, none of those build_flags are necessary.

But, take a minute and think. If you look at the library you want to use, you will see that it in turn depends on the Adafruit_BusIO library. You will see that that in turn depends on the functions in the Arduino core (Arduino.h), the Wire (Wire.h) library for I2C transfers and the Arduino SPI library (SPI.h) for SPI transfers. You will have to re-implement all needed core functions if you want that to work, which is a lot of unnecessary work.

I’d rather suggest you copy the Adafruit_HTU21DF_Library library into your project’s lib/ folder, remove the library.properties file (so PlatformIO does not recognize it as an incompatible Arduino library anymore), remove all dependencies and start implementing the needed I2C transfer functions. The sensor library literally only needs a I2C read and write functions here to read out the sensor.

Also keep in mind that the library is written in C++, so you will have to rename main.cmain.cpp if you want to sensibly interface with a C++ library…

This error is however not related to any library. You probably forgot to copy the main.h header file into the project, or include paths are set up wrongly.

3 Likes