Installed HX711 library, but cannot find header file on compile

Hi,

I installed the bogde HX711 library. But on compilation, the header file isn’t found.

 *  Executing task: platformio run 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: espidf)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-espidf @ 3.50102.0 (5.1.2) 
 - tool-cmake @ 3.16.4 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-ninja @ 1.9.0 
 - tool-riscv32-esp-elf-gdb @ 12.1.0+20221002 
 - tool-xtensa-esp-elf-gdb @ 12.1.0+20221002 
 - toolchain-esp32ulp @ 1.23500.220830 (2.35.0) 
 - toolchain-xtensa-esp32 @ 12.2.0+20230208
Reading CMake configuration...
Warning! Flash memory size mismatch detected. Expected 4MB, found 2MB!
Please select a proper value in your `sdkconfig.defaults` or via the `menuconfig` target!
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/esp32dev/src/main.o
Generating LD script .pio/build/esp32dev/memory.ld
src/main.c:1:10: fatal error: HX711.h: No such file or directory

***************************************************************
* Looking for HX711.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:HX711.h"
* Web  > https://registry.platformio.org/search?q=header:HX711.h
*
***************************************************************

    1 | #include <HX711.h>
      |          ^~~~~~~~~
compilation terminated.
Compiling .pio/build/esp32dev/app_trace/app_trace.o
Compiling .pio/build/esp32dev/app_trace/app_trace_util.o
Compiling .pio/build/esp32dev/app_trace/host_file_io.o
Compiling .pio/build/esp32dev/app_trace/port/port_uart.o
Compiling .pio/build/esp32dev/app_update/esp_ota_ops.o
Compiling .pio/build/esp32dev/app_update/esp_ota_app_desc.o
Compiling .pio/build/esp32dev/bootloader_support/src/bootloader_common.o
Compiling .pio/build/esp32dev/bootloader_support/src/bootloader_common_loader.o
Compiling .pio/build/esp32dev/bootloader_support/src/bootloader_clock_init.o
Compiling .pio/build/esp32dev/bootloader_support/src/bootloader_mem.o
Compiling .pio/build/esp32dev/bootloader_support/src/bootloader_random.o
Compiling .pio/build/esp32dev/bootloader_support/src/bootloader_random_esp32.o
Compiling .pio/build/esp32dev/bootloader_support/src/bootloader_efuse.o
Compiling .pio/build/esp32dev/bootloader_support/src/flash_encrypt.o
*** [.pio/build/esp32dev/src/main.o] Error 1
====================================================================================== [FAILED] Took 3.05 seconds ======================================================================================

I checked my project’s .pio directory, and everything seems to be there:

lt ./.pio/libdeps/esp32dev/HX711/src

-rw-r--r--  1 tennis staff 2.8K Nov 24  2021 HX711.h
-rw-r--r--  1 tennis staff 7.2K Nov 24  2021 HX711.cpp

My ini file is:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = espidf
lib_deps = bogde/HX711@^0.7.5

What am I missing?
TIA,
-T

The library you are referring to is an Arduino library.
However, you are creating an ESP-IDF project. This will not work.

You can create an “Arduino as Component” project (framework = arduino, espidf). See the post by eduardogb: Arduino as ESPIF Component in PlatformIO - solution that works

Furthermore, the library must be registered accordingly: Arduino as an ESP-IDF component — Arduino-ESP32 2.0.14 documentation

1 Like

Thanks! I’ll do that.
-T