Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BME680 platform IO ESP32

    BME680 platform IO ESP32

    peter3099
    Member
     Hello
     
    I'm trying to configure the BSEC library on platform io in order to use a BME680 that I have connected to an ESP32, but no matter what I do I always get 
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o):(.literal._ZN4Bsec11beginCommonEv+0x4): undefined reference to
    `bsec_init'
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o):(.literal._ZN4Bsec11beginCommonEv+0x8): undefined reference to
    `bsec_get_version'
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o):(.literal._ZN4Bsec18updateSubscriptionEP21bsec_virtual_sensor_thf+0x0): undefined reference to `bsec_update_subscription'
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o):(.literal._ZN4Bsec8setStateEPh+0x0): undefined reference to `bsec_set_state'
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o):(.literal._ZN4Bsec15readProcessDataEx19bsec_bme_settings_t+0x14): undefined reference to `bsec_do_steps'
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o):(.literal._ZN4Bsec3runEx+0x0): undefined reference to `bsec_sensor_control'
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o):(.literal._ZN4Bsec3runEx+0x4): undefined reference to `bsec_get_state'
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o): In function `Bsec::beginCommon()':
    D:\Ascough\XPS\SE\Projects\SymphonySense\Code\PlatformIO\SSv0.1 - ESP32/.pio\libdeps\esp32\BSEC Software Library_ID6979\src/bsec.cpp:477: undefined reference to `bsec_init'
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o): In function `Bsec::getVersion()':
    D:\Ascough\XPS\SE\Projects\SymphonySense\Code\PlatformIO\SSv0.1 - ESP32/.pio\libdeps\esp32\BSEC Software Library_ID6979\src/bsec.cpp:477: undefined reference to `bsec_get_version'
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o): In function `Bsec::updateSubscription(bsec_virtual_sensor_t*,
    unsigned char, float)':
    D:\Ascough\XPS\SE\Projects\SymphonySense\Code\PlatformIO\SSv0.1 - ESP32/.pio\libdeps\esp32\BSEC Software Library_ID6979\src/bsec.cpp:477: undefined reference to `bsec_update_subscription'
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o): In function `Bsec::setState(unsigned char*)':
    D:\Ascough\XPS\SE\Projects\SymphonySense\Code\PlatformIO\SSv0.1 - ESP32/.pio\libdeps\esp32\BSEC Software Library_ID6979\src/bsec.cpp:477: undefined reference to `bsec_set_state'
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o): In function `Bsec::readProcessData(long long, bsec_bme_settings_t)':
    D:\Ascough\XPS\SE\Projects\SymphonySense\Code\PlatformIO\SSv0.1 - ESP32/.pio\libdeps\esp32\BSEC Software Library_ID6979\src/bsec.cpp:386: undefined reference to `bsec_do_steps'
    .pio\build\esp32\lib149\libBSEC Software Library_ID6979.a(bsec.cpp.o): In function `Bsec::run(long long)':
    D:\Ascough\XPS\SE\Projects\SymphonySense\Code\PlatformIO\SSv0.1 - ESP32/.pio\libdeps\esp32\BSEC Software Library_ID6979\src/bsec.cpp:201: undefined reference to `bsec_init'
    D:\Ascough\XPS\SE\Projects\SymphonySense\Code\PlatformIO\SSv0.1 - ESP32/.pio\libdeps\esp32\BSEC Software Library_ID6979\src/bsec.cpp:211: undefined reference to `bsec_update_subscription'
    D:\Ascough\XPS\SE\Projects\SymphonySense\Code\PlatformIO\SSv0.1 - ESP32/.pio\libdeps\esp32\BSEC Software Library_ID6979\src/bsec.cpp:211: undefined reference to `bsec_sensor_control'
    D:\Ascough\XPS\SE\Projects\SymphonySense\Code\PlatformIO\SSv0.1 - ESP32/.pio\libdeps\esp32\BSEC Software Library_ID6979\src/bsec.cpp:247: undefined reference to `bsec_get_state'
    collect2.exe: error: ld returned 1 exit status
    *** [.pio\build\esp32\firmware.elf] Error 1
     
    I saw the instructions for the library but I cannot find the platform txt nor I know what to put on it.
    Could you please advice what's the correct way to do it?
    Thanks 
    12 REPLIES 12

    handytech
    Community Moderator
    Community Moderator

    These errors mean that your toolchain couldn't successfully find the BSEC library.

    Some instructions we share (including about platform.txt) are meant for the Arduino IDE, which works differently than PlatformIO.

    You would probably get the best help from PlatformIO directly, but it seems that you need to inform your toolchain about static libraries in a "platformio.ini" project configuration file, e.g. it may look something like this:

    [env:specific_inclibs]
    build_flags =
      -I/path/to/bsec/headers_files/directory
      -L/path/to/bsec/libalgobsec.a/directory
      -lalgobsec

     

    Hi 

     

    Thanks for your answer, this is my platform.ini

    [env:esp32]
    platform = espressif32
    board = esp32dev
    framework = arduino
    monitor_speed = 115200
    upload_port = COM[3]
    monitor_port = COM[3]
    ; build_flags = -D MQTT_MAX_PACKET_SIZE=4096
    build_flags =
      -IC:\Users\Pedro\.platformio\lib\BSEC Software Library_ID6979\src\bme680
      -LC:\Users\Pedro\.platformio\lib\BSEC Software Library_ID6979\src\esp32
      -lalgobsec
     
    I installed the library locally 
     
    During the compilation I get
    ...
    -- <BSEC Software Library> 1.5.1474
    ...
    Compiling .pio\build\esp32\lib5f4\BSEC Software Library_ID6979\bme680\bme680.c.o
    Compiling .pio\build\esp32\lib5f4\BSEC Software Library_ID6979\bsec.cpp.o
     
    It doesn't give me the same error as before, but eventually at the end it says 
    *** [.pio\build\esp32\firmware.elf] Implicit dependency `C:\Users\Pedro\.platformio\platforms\espressif32\builder\Software' not found, needed by target `.pio\build\esp32\firmware.elf'.
     
    And it fails to compile, if I remove the bsec library and all the parts related to bsec then it builds ok
     
    Any advice

    handytech
    Community Moderator
    Community Moderator

    I will take the wild guess that your toolchain doesn't like spaces in your paths.

    I would suggest to rename your folder "BSEC Software Library_ID6979" into something without spaces, or use quotes around paths including spaces.

    Finally although it may be optional anyway, I expect the path to the library's header files to be by default under "\src\inc" instead of "\src\bme680".

    Thank for that, making some progress.

    I changed the name of the folder to one with no spaces

    build_flags =
      -IC:\Users\Pedro\.platformio\lib\BSECSoftwareLibrary_ID6979\src\inc
      -LC:\Users\Pedro\.platformio\lib\BSECSoftwareLibrary_ID6979\src\esp32
      -lalgobsec
     

    and I got

    Linking .pio\build\esp32\firmware.elf
    c:/users/pedro/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: cannot find -lalgobsec
    collect2.exe: error: ld returned 1 exit status
    *** [.pio\build\esp32\firmware.elf] Error 1

    I tried commenting lalgobsec line on the build

     
    But if I do that I come back to the original error.
     
    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist