Using the BME680 with IAQ with the Teensy 3.1/3.2

Markus_L811

Well-known member
If you want to use the IAQ function, you need to add an precompiled file and change some of the file locations.

1. Download the lib from github: Link
2. Create an Folder basic_BME680 in your Sketchfolder "C:\-your path-\Documents\Arduino\"
3. Copy some files to it.
BSEC_BME680\examples\basic\basic.ino
BSEC_BME680\src\*
BSEC_BME680\src\bme680\bme*
BSEC_BME680\src\inc\*
BSEC_BME680\src\bsec.*
BSEC_BME680\keywords.txt
BSEC_BME680\src\cortex-m4 (the cortex-m4 folder with file, the Teensy 3.1/3.2 is an m4)

4. Modify the bcec.h
Change:
#include "inc/bsec_datatypes.h"
#include "inc/bsec_interface.h"
#include "bme680/bme680.h"
to:
#include "bsec_datatypes.h"
#include "bsec_interface.h"
#include "bme680.h"

5. Now the tricky part change the platform.txt from teensyduino (1.8.12 for example)
Open arduino-1.8.12\hardware\teensy\avr\platform.txt
Search for: ## Link

Change:
recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" {build.flags.libs}

to:
recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "C:\-your path-\Documents\Arduino\basic_BME680\cortex-m4\libalgobsec.a" "-L{build.path}" {build.flags.libs}

So after this you should run the BME680 with all features.

Downside the precompiled is now part as long as it stayes inside the platform.txt and it needs to be done with every new Teensyduino version.

Atm. I don't know an better way to get this done:
When you add this to the platform.txt
compiler.libraries.ldflags=

And change the ## Link to this
recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "{compiler.libraries.ldflags}" "-L{build.path}" {build.flags.libs}

the compiler ask for the libalgobsec.a in the folder BSEC_BME680\src\mk20dx256 but even if I do him the favor it won't compile sucessfully. If someone has some hints to do that would be nice.

Paul does not support to include precompiled from the lib itself at this point so far.

File with the complete folder added with this version "Bosch Sensortec Environmental Cluster (BSEC) Software v1.4.7.4 released on July 3rd, 2019" and changed bcec.h
 

Attachments

  • basic_BME680.zip
    22 bytes · Views: 113
Last edited:
If you want to use the IAQ function, you need to add an precompiled file and change some of the file locations.

1. Download the lib from github: Link
2. Create an Folder basic_BME680 in your Sketchfolder "C:\-your path-\Documents\Arduino\"
3. Copy some files to it.
BSEC_BME680\examples\basic\basic.ino
BSEC_BME680\src\*
BSEC_BME680\src\bme680\bme*
BSEC_BME680\src\inc\*
BSEC_BME680\src\bsec.*
BSEC_BME680\keywords.txt
BSEC_BME680\src\cortex-m4 (the cortex-m4 folder with file, the Teensy 3.1/3.2 is an m4)

4. Modify the bcec.h
Change:
#include "inc/bsec_datatypes.h"
#include "inc/bsec_interface.h"
#include "bme680/bme680.h"
to:
#include "bsec_datatypes.h"
#include "bsec_interface.h"
#include "bme680.h"

5. Now the tricky part change the platform.txt from teensyduino (1.8.12 for example)
Open arduino-1.8.12\hardware\teensy\avr\platform.txt
Search for: ## Link

Change:
recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" {build.flags.libs}

to:
recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "C:\-your path-\Documents\Arduino\basic_BME680\cortex-m4\libalgobsec.a" "-L{build.path}" {build.flags.libs}

So after this you should run the BME680 with all features.

Downside the precompiled is now part as long as it stayes inside the platform.txt and it needs to be done with every new Teensyduino version.

Atm. I don't know an better way to get this done:
When you add this to the platform.txt
compiler.libraries.ldflags=

And change the ## Link to this
recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "{compiler.libraries.ldflags}" "-L{build.path}" {build.flags.libs}

the compiler ask for the libalgobsec.a in the folder BSEC_BME680\src\mk20dx256 but even if I do him the favor it won't compile sucessfully. If someone has some hints to do that would be nice.

Paul does not support to include precompiled from the lib itself at this point so far.

File with the complete folder added with this version "Bosch Sensortec Environmental Cluster (BSEC) Software v1.4.7.4 released on July 3rd, 2019" and changed bcec.h


Hello!!

Im trying to compile but obviously im making an error as is not working.

I followed your instructions but i have question as you first say to put the full path to lib file in "recipe.c.combine.pattern" var inside arduino-1.8.12\hardware\teensy\avr\platform.txt and later you mentioned to put the "{compiler.libraries.ldflags}" empty var......

Im allways getting an error "undefined reference to" so i assume that lib is not linking ok

Does it works for you¿
 
Hello!!

Im trying to compile but obviously im making an error as is not working.

I followed your instructions but i have question as you first say to put the full path to lib file in "recipe.c.combine.pattern" var inside arduino-1.8.12\hardware\teensy\avr\platform.txt and later you mentioned to put the "{compiler.libraries.ldflags}" empty var......

Im allways getting an error "undefined reference to" so i assume that lib is not linking ok

Does it works for you¿

You have to use this Line with you path

Code:
recipe.c.combine.pattern="{compiler.path}{build.to olchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" [COLOR="#FF0000"]"C:\-your path-\Documents\Arduino\basic_BME680\cortex-m4\libalgobsec.a"[/COLOR] "-L{build.path}" {build.flags.libs}

The 2nd Line you used showes the actuall Arduino solution.

Did you use an Teensy 3.1/3.2?
 
You have to use this Line with you path

Code:
recipe.c.combine.pattern="{compiler.path}{build.to olchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" [COLOR="#FF0000"]"C:\-your path-\Documents\Arduino\basic_BME680\cortex-m4\libalgobsec.a"[/COLOR] "-L{build.path}" {build.flags.libs}

The 2nd Line you used showes the actuall Arduino solution.

Did you use an Teensy 3.1/3.2?

Thank you Markus!!

I will use 3.2, i was confused because i think i will need to set the path with -L and later the name of the lib to link -lalgobsec ......

I come from using a esp8266 (nodemcu) but i was having problems with a unstable serial communication, the boards sometimes stop sending data, and i was not using the wifi. So i move to use a teensy, in a few days teensy will arrive and see if i get a reliable communication. For sensor im using adafruit one

Can i ask you what bsec library version are you using and if is working correctly?
 
The above mentioned Bosch Sensortec Environmental Cluster (BSEC) Software v1.4.7.4 the latest changed one parts for the latest Arduino 1.8.13, and yes it works well, I did not use it on continuous run, but it works for hours as I tested it.

My intention was to get it work, on an Teensy not to use it :D
 
I tried to download the zip you linked to see the version but is a empy folder once i uncompress it.

Is compiling ok!! now i need the board to upload and test it.

Thank you!!

NOTE: also works installing the library with the arduino library manager and puting the linker flag as you describe
 
NOTE: also works installing the library with the arduino library manager and puting the linker flag as you describe

That is new, didn't work in the first place as I tested it, sorry for the empty zip there is the filled, no idea why his was empty

Get this with Arduino: 1.8.13 (Windows 10), TD: 1.53, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz (overclock), Faster, US English"

Library BSEC-Arduino-library-master has been declared precompiled:

Precompiled library in "C:\Users\Markus\Documents\Arduino\libraries\BSEC-Arduino-library-master\src\mk20dx256" not found

The plaform does not support 'compiler.libraries.ldflags' for precompiled libraries.

arm-none-eabi-gcc: error: {compiler.libraries.ldflags}: No such file or directory

Error compiling for board Teensy 3.2 / 3.1.

And with the folder mk20dx256

Arduino: 1.8.13 (Windows 10), TD: 1.53, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz (overclock), Faster, US English"

Library BSEC-Arduino-library-master has been declared precompiled:

Using precompiled library in C:\Users\Markus\Documents\Arduino\libraries\BSEC-Arduino-library-master\src\mk20dx256

The plaform does not support 'compiler.libraries.ldflags' for precompiled libraries.

arm-none-eabi-gcc: error: {compiler.libraries.ldflags}: No such file or directory

Error compiling for board Teensy 3.2 / 3.1.

Did you change something else? From the Library Manager you will get the 1.4.703 from Github the 1.5.1474
 

Attachments

  • basic_BME680.zip
    63.4 KB · Views: 102
Last edited:
Hello

I installed the library using the libraray manager, not importing zip file.... arduino 1.8.13, teensyduino 1.53 on Ubuntu 20.04

here is the output

https://gist.github.com/natxopedreira/420a274da9b5766d5045f8940308ea3f

Sorry no it doesn't work
Code:
Compiling library "BSEC_Software_Library"
Library BSEC_Software_Library has been declared precompiled:
Precompiled library in "/home/natxo/Arduino/libraries/BSEC_Software_Library/src/mk20dx256" not found
The plaform does not support 'compiler.libraries.ldflags' for precompiled libraries.

Is not included inside.
 
Sorry no it doesn't work
Code:
Compiling library "BSEC_Software_Library"
Library BSEC_Software_Library has been declared precompiled:
Precompiled library in "/home/natxo/Arduino/libraries/BSEC_Software_Library/src/mk20dx256" not found
The plaform does not support 'compiler.libraries.ldflags' for precompiled libraries.

Is not included inside.

Maybe thats a warning?, compilation does not stop and if library is not found in linking phase you should get some errors about using undefined methods that im calling in code.

Anyway i will update on Monday as my hardware will arrive and i will test, if not work i know your method works as is tested for you

Code:
Linking everything together...
/home/natxo/arduino-1.8.13/hardware/teensy/../tools/arm/bin/arm-none-eabi-gcc -O2 -Wl,--gc-sections,--relax,--defsym=__rtc_localtime=1602756998 -T/home/natxo/arduino-1.8.13/hardware/teensy/avr/cores/teensy3/mk20dx256.ld -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -o /tmp/arduino_build_876421/basic.ino.elf /tmp/arduino_build_876421/sketch/basic.ino.cpp.o /tmp/arduino_build_876421/libraries/BSEC_Software_Library/bsec.cpp.o /tmp/arduino_build_876421/libraries/BSEC_Software_Library/bme680/bme680.c.o /tmp/arduino_build_876421/libraries/Wire/Wire.cpp.o /tmp/arduino_build_876421/libraries/Wire/WireIMXRT.cpp.o /tmp/arduino_build_876421/libraries/Wire/WireKinetis.cpp.o /tmp/arduino_build_876421/libraries/Wire/utility/twi.c.o /tmp/arduino_build_876421/libraries/SPI/SPI.cpp.o /tmp/arduino_build_876421/core/core.a /home/natxo/Arduino/lifesens_bme680_teensy/cortex-m4/libalgobsec.a -L/tmp/arduino_build_876421 -larm_cortexM4l_math -lm -lstdc++
/home/natxo/arduino-1.8.13/hardware/teensy/../tools/arm/bin/arm-none-eabi-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/arduino_build_876421/basic.ino.elf /tmp/arduino_build_876421/basic.ino.eep
/home/natxo/arduino-1.8.13/hardware/teensy/../tools/arm/bin/arm-none-eabi-objcopy -O ihex -R .eeprom /tmp/arduino_build_876421/basic.ino.elf /tmp/arduino_build_876421/basic.ino.hex
/home/natxo/arduino-1.8.13/hardware/teensy/../tools/stdout_redirect /tmp/arduino_build_876421/basic.ino.lst /home/natxo/arduino-1.8.13/hardware/teensy/../tools/arm/bin/arm-none-eabi-objdump -d -S -C /tmp/arduino_build_876421/basic.ino.elf
/home/natxo/arduino-1.8.13/hardware/teensy/../tools/stdout_redirect /tmp/arduino_build_876421/basic.ino.sym /home/natxo/arduino-1.8.13/hardware/teensy/../tools/arm/bin/arm-none-eabi-objdump -t -C /tmp/arduino_build_876421/basic.ino.elf
/home/natxo/arduino-1.8.13/hardware/teensy/../tools/teensy_post_compile -file=basic.ino -path=/tmp/arduino_build_876421 -tools=/home/natxo/arduino-1.8.13/hardware/teensy/../tools/ -board=TEENSY32
Opening Teensy Loader...
 
Maybe thats a warning?, compilation does not stop and if library is not found in linking phase you should get some errors about using undefined methods that im calling in code.

Anyway i will update on Monday as my hardware will arrive and i will test, if not work i know your method works as is tested for you

Code:
Linking everything together...
/home/natxo/arduino-1.8.13/hardware/teensy/../tools/arm/bin/arm-none-eabi-gcc -O2 -Wl,--gc-sections,--relax,--defsym=__rtc_localtime=1602756998 -T/home/natxo/arduino-1.8.13/hardware/teensy/avr/cores/teensy3/mk20dx256.ld -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -o /tmp/arduino_build_876421/basic.ino.elf /tmp/arduino_build_876421/sketch/basic.ino.cpp.o /tmp/arduino_build_876421/libraries/BSEC_Software_Library/bsec.cpp.o /tmp/arduino_build_876421/libraries/BSEC_Software_Library/bme680/bme680.c.o /tmp/arduino_build_876421/libraries/Wire/Wire.cpp.o /tmp/arduino_build_876421/libraries/Wire/WireIMXRT.cpp.o /tmp/arduino_build_876421/libraries/Wire/WireKinetis.cpp.o /tmp/arduino_build_876421/libraries/Wire/utility/twi.c.o /tmp/arduino_build_876421/libraries/SPI/SPI.cpp.o /tmp/arduino_build_876421/core/core.a /home/natxo/Arduino/lifesens_bme680_teensy/cortex-m4/libalgobsec.a -L/tmp/arduino_build_876421 -larm_cortexM4l_math -lm -lstdc++
/home/natxo/arduino-1.8.13/hardware/teensy/../tools/arm/bin/arm-none-eabi-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/arduino_build_876421/basic.ino.elf /tmp/arduino_build_876421/basic.ino.eep
/home/natxo/arduino-1.8.13/hardware/teensy/../tools/arm/bin/arm-none-eabi-objcopy -O ihex -R .eeprom /tmp/arduino_build_876421/basic.ino.elf /tmp/arduino_build_876421/basic.ino.hex
/home/natxo/arduino-1.8.13/hardware/teensy/../tools/stdout_redirect /tmp/arduino_build_876421/basic.ino.lst /home/natxo/arduino-1.8.13/hardware/teensy/../tools/arm/bin/arm-none-eabi-objdump -d -S -C /tmp/arduino_build_876421/basic.ino.elf
/home/natxo/arduino-1.8.13/hardware/teensy/../tools/stdout_redirect /tmp/arduino_build_876421/basic.ino.sym /home/natxo/arduino-1.8.13/hardware/teensy/../tools/arm/bin/arm-none-eabi-objdump -t -C /tmp/arduino_build_876421/basic.ino.elf
/home/natxo/arduino-1.8.13/hardware/teensy/../tools/teensy_post_compile -file=basic.ino -path=/tmp/arduino_build_876421 -tools=/home/natxo/arduino-1.8.13/hardware/teensy/../tools/ -board=TEENSY32
Opening Teensy Loader...

Interesting it linked

Code:
/home/natxo/Arduino/lifesens_bme680_teensy/cortex-m4/libalgobsec.a

but says it did not find

Code:
Precompiled library in "/home/natxo/Arduino/libraries/BSEC_Software_Library/src/mk20dx256" not found

May someone can explain that
 
Interesting it linked

Code:
/home/natxo/Arduino/lifesens_bme680_teensy/cortex-m4/libalgobsec.a

but says it did not find

Code:
Precompiled library in "/home/natxo/Arduino/libraries/BSEC_Software_Library/src/mk20dx256" not found

May someone can explain that


IMO it says that not found what it expected, but as you later are setting the lib manually it links and compile

I dont know how arduino make sytem works as it should work using a ldflag, setting the path with -L/home/natxo/Arduino/lifesens_bme680_teensy/cortex-m4 and later set the lib name -lalgobsec and when i tried it linked but get errors about the order on how libs link......
 
Interesting it linked

Code:
/home/natxo/Arduino/lifesens_bme680_teensy/cortex-m4/libalgobsec.a

but says it did not find

Code:
Precompiled library in "/home/natxo/Arduino/libraries/BSEC_Software_Library/src/mk20dx256" not found

May someone can explain that

I found a partial explain
https://github.com/BoschSensortec/BSEC-Arduino-library/blob/master/library.properties

"precompiled=true" means that it use a precompile lib

"ldflags=-lalgobsec" this set the name of the lib to link

and the expected path is src/artuitecture/libraryfile.a

so maybe putting the lib inside a architecture folder and set architectures architectures=cortex-m4

So in teory modifying the library.properties of the installed lib should work, need to set the correct architecture


Code:
name=BSEC Software Library
version=1.5.1474
author=Bosch Sensortec
maintainer=Bosch Sensortec <contact@bosch-sensortec.com>
sentence=Bosch Sensortec Environmental Cluster (BSEC) Software library
url=https://www.bosch-sensortec.com/software-tools/software/bsec/
paragraph=  for use with the BME680 has been conceptualized to provide higher-level signal processing and fusion for the BME680. The library receives compensated sensor values from the sensor API. It processes the BME680 signals to provide the requested sensor outputs. 
category=Sensors
includes=bsec.h
[COLOR=#ff0000]architectures=cortex-m4[/COLOR]
dot_a_linkage=true
precompiled=true
ldflags=-lalgobsec

THat will make the compiler look for the lib in the correct folder, or thats my teory, sadly i can not test as i dont have my computer with me

The compiler is getting the architecture of the teensy as mk20dx256 but the lib structure expected to be indentified as cortex-m4 and curiosly that architecture is not included in the original library.properties.... curious
 
Last edited:
I found a partial explain
https://github.com/BoschSensortec/BSEC-Arduino-library/blob/master/library.properties

"precompiled=true" means that it use a precompile lib

"ldflags=-lalgobsec" this set the name of the lib to link

and the expected path is src/artuitecture/libraryfile.a

so maybe putting the lib inside a architecture folder and set architectures architectures=cortex-m4

So in teory modifying the library.properties of the installed lib should work, need to set the correct architecture

Code:
name=BSEC Software Library
version=1.5.1474
author=Bosch Sensortec
maintainer=Bosch Sensortec <contact@bosch-sensortec.com>
sentence=Bosch Sensortec Environmental Cluster (BSEC) Software library
url=https://www.bosch-sensortec.com/software-tools/software/bsec/
paragraph=  for use with the BME680 has been conceptualized to provide higher-level signal processing and fusion for the BME680. The library receives compensated sensor values from the sensor API. It processes the BME680 signals to provide the requested sensor outputs. 
category=Sensors
includes=bsec.h
[COLOR=#ff0000]architectures=cortex-m4[/COLOR]
dot_a_linkage=true
precompiled=true
ldflags=-lalgobsec

THat will make the compiler look for the lib in the correct folder, or thats my teory, sadly i can not test as i dont have my computer with me

The compiler is getting the architecture of the teensy as mk20dx256 but the lib structure expected to be indentified as cortex-m4 and curiosly that architecture is not included in the original library.properties.... curious

Hello natxo,

you are right if I change this Lines inside this files

library.properties:
Code:
[B]architectures=samd,sam,esp8266,nrf52,esp32,avr[/B]

to

[B]architectures=*[/B]

and inside the platform.txt
Code:
## Link
recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" {build.flags.libs}

## Link
compiler.libraries.ldflags=
recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" [COLOR="#FF0000"]{compiler.libraries.ldflags}[/COLOR] "-L{build.path}" {build.flags.libs}

Without quotes, that does the trick.

And add the src\cortex-m4 as copy with the name \src\mk20dx256.

It does as you say.

Code:
Library BSEC-Arduino-library-master has been declared precompiled:
Using precompiled library in C:\Users\Markus\Documents\Arduino\libraries\BSEC-Arduino-library-master\src\mk20dx256
Sketch uses 73052 bytes (27%) of program storage space. Maximum is 262144 bytes.
Global variables use 6524 bytes (9%) of dynamic memory, leaving 59012 bytes for local variables. Maximum is 65536 bytes.
 
Thank you Markus, good to know!!!!

Anyway i will take a look when i have my computer and some time because this

Code:
## Link
compiler.libraries.ldflags=
recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" {compiler.libraries.ldflags} "-L{build.path}" {build.flags.libs}

Is a bit nosese, library.properties files is defining the ldflag for the compiler to use "ldflags=-lalgobsec" and also you are defining a variable without any value "compiler.libraries.ldflags=" so i don't understand how that line is working.

Good news is that if someone needs to use this lib here is defined how he can make it work :)
 
Thank you,

but there are 2 parts, the library.properties tells the IDE whats to do:

dot_a_linkage=true
precompiled=true
ldflags=-lalgobsec

So the IDE know there is an precompiled file named algobsec.a which is needed for the lib to work proper.

The platfom.txt contains the procedur for the compiler to create an working .hex for the specific microcontroller e.g. Teensy 3.1/2

compiler.libraries.ldflags=
is an variable now filled with the path of the algobsec.a to link it inside the recipe.c.combine.pattern toolchain, so we need the variable placed on the right place inside the toolchain, but if you compile something that has no precompiled .a it has to stay empty so that it does not interfer with it, what is way better than my first line, what does nothing else than hardcode it in.

But why it only works without quotes, I have no idea.

Btw.

architectures=* is now for all.

Arduino differ per Core-Architectur (avr, cortex-m0 usw.), Paul with the Controller-Familie (mk20dx256).

And the Teensy 3.1/2 is an cortex-m4 thats why we need this under an different name so the compiler can use the correct path with his variables.
 
I agree with you with one exception point that is the cause that make no sense to me.

compiler.libraries.ldflags= Here is the declaration of a variable and set that var equal to.... no value, in wich line this var is getting the value of the ldflags, thats what is confusing me.


I will say that if you put inside quotes is dealing as an string thats what do not work if you put the name of the var inside quotes
 
I agree with you with one exception point that is the cause that make no sense to me.

compiler.libraries.ldflags= Here is the declaration of a variable and set that var equal to.... no value, in wich line this var is getting the value of the ldflags, thats what is confusing me.


I will say that if you put inside quotes is dealing as an string thats what do not work if you put the name of the var inside quotes

Good point, but it does not work without it.
Code:
Library BSEC-Arduino-library-master has been declared precompiled:
Using precompiled library in C:\Users\Markus\Documents\Arduino\libraries\BSEC-Arduino-library-master\src\mk20dx256
The plaform does not support 'compiler.libraries.ldflags' for precompiled libraries.
arm-none-eabi-gcc: error: {compiler.libraries.ldflags}: No such file or directory
Error compiling for board Teensy 3.2 / 3.1.
Absend from the changes inside the platform.txt and the library.properties.

I added some folders for the from Paul used Controllers and I can make it compile for all starting from the Teensy 3.0 to the Teensy 4.1 but not for the Teensy LC with 62k he is to small even for the reduced, lite Version of the algobsec.a (crashed on a littlebit of 316 bytes) added it, so may someone can use it.
 

Attachments

  • BSEC-Arduino-library-master.zip
    592.2 KB · Views: 104
Um guys?

My background is very weak in compiler and linker vocabulary. In the end of all this, was there a list of things I need to do to get this library to work? I just tried the basic.ino example program and it doesn't compile for me. I'm currently reading the readme.md file and I just can't make heads or tails of it.. I don't know what pertains to the teensy and what came from Bosch..

Code:
/var/folders/wt/mcbdk5yn5wz6z1zcpf20xvzw0000gn/T/arduino_build_105760/sketch/basic.ino.cpp.o: In function `setup':
/Users/jimlee/Documents/Arduino/libraries/BSEC-Arduino-library/examples/basic/basic.ino:18: undefined reference to `Bsec::begin(unsigned char, TwoWire&, void (*)(unsigned long))'
/Users/jimlee/Documents/Arduino/libraries/BSEC-Arduino-library/examples/basic/basic.ino:36: undefined reference to `Bsec::updateSubscription(bsec_virtual_sensor_t*, unsigned char, float)'
/Users/jimlee/Documents/Arduino/libraries/BSEC-Arduino-library/examples/basic/basic.ino:42: undefined reference to `Bsec::delay_ms(unsigned long)'
/var/folders/wt/mcbdk5yn5wz6z1zcpf20xvzw0000gn/T/arduino_build_105760/sketch/basic.ino.cpp.o: In function `loop':
/Users/jimlee/Documents/Arduino/libraries/BSEC-Arduino-library/examples/basic/basic.ino:48: undefined reference to `Bsec::run(long long)'
/var/folders/wt/mcbdk5yn5wz6z1zcpf20xvzw0000gn/T/arduino_build_105760/sketch/basic.ino.cpp.o: In function `__static_initialization_and_destruction_0':
/Users/jimlee/Documents/Arduino/libraries/BSEC-Arduino-library/examples/basic/basic.ino:8: undefined reference to `Bsec::Bsec()'
collect2: error: ld returned 1 exit status
Error compiling for board Teensy 3.2 / 3.1.

-jim lee
 
Hi

You need to tell the compiler to link the library, i dont have my work computer here so i can not tell you exacttly what to put, if you can wait..... if not try to follow instructions on this post and post if any problem. All the solutions exposed here works, is only more than one way to do it
 
I plugged in the adafruit bme680 board today, and the bsec library sketch is not finding it.
FYI, I also had to add in "while (!Serial)":

while (!Serial)
Serial.begin(115200);

The adafruit library did find it and returned values:
adafruit bme680 i2cdemo

Loop Temp°C Humid% Press hPa Alt m Air mΩ
==== ====== ====== ========= ======= ======
75 27.87 39.218 981.74 265.02 158.97

But the BSEC Library one outputs this:
BSEC library version 1.4.8.0

BME680 error code : -2


I assume it's failing on the i2c handshake but not sure why. I see in the defs:
/** Error code definitions */
#define BME680_OK INT8_C(0)
/* Errors */
#define BME680_E_NULL_PTR INT8_C(-1)
#define BME680_E_COM_FAIL INT8_C(-2)
#define BME680_E_DEV_NOT_FOUND INT8_C(-3)
#define BME680_E_INVALID_LENGTH INT8_C(-4)

I tried to add Wire.setClock(100000), since that was the rate that the adafruit one used.

Both sketches are from the Arduino Library Manager.
Here's the bsec library sketch:
Code:
#include "bsec.h"

// Helper functions declarations
void checkIaqSensorStatus(void);
void errLeds(void);

// Create an object of the class Bsec
Bsec iaqSensor;

String output;

// Entry point for the example
void setup(void)
{
  while (!Serial)
  Serial.begin(115200);
// Wire.setClock(100000);
  Wire.begin();


  iaqSensor.begin(BME680_I2C_ADDR_PRIMARY, Wire);
  output = "\nBSEC library version " + String(iaqSensor.version.major) + "." + String(iaqSensor.version.minor) + "." + String(iaqSensor.version.major_bugfix) + "." + String(iaqSensor.version.minor_bugfix);
  Serial.println(output);
  checkIaqSensorStatus();

  bsec_virtual_sensor_t sensorList[10] = {
    BSEC_OUTPUT_RAW_TEMPERATURE,
    BSEC_OUTPUT_RAW_PRESSURE,
    BSEC_OUTPUT_RAW_HUMIDITY,
    BSEC_OUTPUT_RAW_GAS,
    BSEC_OUTPUT_IAQ,
    BSEC_OUTPUT_STATIC_IAQ,
    BSEC_OUTPUT_CO2_EQUIVALENT,
    BSEC_OUTPUT_BREATH_VOC_EQUIVALENT,
    BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE,
    BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY,
  };

  iaqSensor.updateSubscription(sensorList, 10, BSEC_SAMPLE_RATE_LP);
  checkIaqSensorStatus();

  // Print the header
  output = "Timestamp [ms], raw temperature [°C], pressure [hPa], raw relative humidity [%], gas [Ohm], IAQ, IAQ accuracy, temperature [°C], relative humidity [%], Static IAQ, CO2 equivalent, breath VOC equivalent";
  Serial.println(output);
}

// Function that is looped forever
void loop(void)
{
  unsigned long time_trigger = millis();
  if (iaqSensor.run()) { // If new data is available
    output = String(time_trigger);
    output += ", " + String(iaqSensor.rawTemperature);
    output += ", " + String(iaqSensor.pressure);
    output += ", " + String(iaqSensor.rawHumidity);
    output += ", " + String(iaqSensor.gasResistance);
    output += ", " + String(iaqSensor.iaq);
    output += ", " + String(iaqSensor.iaqAccuracy);
    output += ", " + String(iaqSensor.temperature);
    output += ", " + String(iaqSensor.humidity);
    output += ", " + String(iaqSensor.staticIaq);
    output += ", " + String(iaqSensor.co2Equivalent);
    output += ", " + String(iaqSensor.breathVocEquivalent);
    Serial.println(output);
  } else {
    checkIaqSensorStatus();
  }
}

// Helper function definitions
void checkIaqSensorStatus(void)
{
  if (iaqSensor.status != BSEC_OK) {
    if (iaqSensor.status < BSEC_OK) {
      output = "BSEC error code : " + String(iaqSensor.status);
      Serial.println(output);
      for (;;)
        errLeds(); /* Halt in case of failure */
    } else {
      output = "BSEC warning code : " + String(iaqSensor.status);
      Serial.println(output);
    }
  }

  if (iaqSensor.bme680Status != BME680_OK) {
    if (iaqSensor.bme680Status < BME680_OK) {
      output = "BME680 error code : " + String(iaqSensor.bme680Status);
      Serial.println(output);
      for (;;)
        errLeds(); /* Halt in case of failure */
    } else {
      output = "BME680 warning code : " + String(iaqSensor.bme680Status);
      Serial.println(output);
    }
  }
}

void errLeds(void)
{
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(100);
  digitalWrite(LED_BUILTIN, LOW);
  delay(100);
}


here's the adafruit sketch:
Code:
/*! @file I2CDemo.ino

@section I2CDemo_intro_section Description

Example program for using I2C to set and read the Bosch BME680 sensor. The sensor measures
temperature, pressure and humidity and is described at
https://www.bosch-sensortec.com/bst/products/all_products/BME680. The datasheet is available from
Bosch at https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME680_DS001-11.pdf \n\n

The most recent version of the BME680 library is available at https://github.com/SV-Zanshin/BME680
and the documentation of the library as well as example programs are described in the project's wiki
pages located at https://github.com/SV-Zanshin/BME680/wiki. \n\n

The BME680 is an extremely small physical package that is so tiny as to be impossible to solder at
home, hence it will be used as part of a third-party breakout board. There are several such boards
available at this time, for example \n Company  | Link
-------  | ----------
Sparkfun | https://www.sparkfun.com/products/14570
BlueDot  | https://www.bluedot.space/sensor-boards/bme680/
Adafruit |
https://learn.adafruit.com/adafruit-BME680-humidity-barometric-pressure-temperature-sensor-breakout
\n\n

Bosch supplies sample software that runs on various platforms, including the Arduino family; this
can be downloaed at https://github.com/BoschSensortec/BSEC-Arduino-library . This software is part
of the Bosch "BSEC" (Bosch Sensortec Environmental Cluster) framework and somewhat bulky and
unwieldy for typical Arduino applications, hence the choice to make a more compact and rather less
abstract library.

This example program initializes the BME680 to use I2C for communications. The library does not
using floating point numbers to save on memory space and computation time. The values for
Temperature, Pressure and Humidity are returned in deci-units, e.g. a Temperature reading of "2731"
means "27.31" degrees Celsius. The display in the example program uses floating point for
demonstration purposes only.  Note that the temperature reading is generally higher than the ambient
temperature due to die and PCB temperature and self-heating of the element.\n\n

The pressure reading needs to be adjusted for altitude to get the adjusted pressure reading. There
are numerous sources on the internet for formulae converting from standard sea-level pressure to
altitude, see the data sheet for the BME180 on page 16 of
http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf. Rather than put a floating-point
function in the library which may not be used but which would use space, an example altitude
computation function has been added to this example program to show how it might be done.

@section I2CDemolicense License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version. This program is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have
received a copy of the GNU General Public License along with this program.  If not, see
<http://www.gnu.org/licenses/>.

@section I2CDemoauthor Author

Written by Arnd\@SV-Zanshin

@section I2CDemoversions Changelog

Version | Date       | Developer  | Comments
------- | ---------- | ---------- | ---------------------------------------------------------------
1.0.3   | 2020-07-04 | SV-Zanshin | Issue #25 implement clang-formatting
1.0.2   | 2020-05-09 | SV-Zanshin | Issue #8  clean up comments and code
1.0.1   | 2019-01-30 | SV-Zanshin |           Removed old comments
1.0.1   | 2019-01-26 | SV-Zanshin | Issue #3  convert documentation to Doxygen
1.0.0b  | 2018-06-30 | SV-Zanshin |           Cloned from original BME280 program
*/
#include "Zanshin_BME680.h"  // Include the BME680 Sensor library
/**************************************************************************************************
** Declare all program constants                                                                 **
**************************************************************************************************/
const uint32_t SERIAL_SPEED{115200};  ///< Set the baud rate for Serial I/O

/**************************************************************************************************
** Declare global variables and instantiate classes                                              **
**************************************************************************************************/
BME680_Class BME680;  ///< Create an instance of the BME680 class
///< Forward function declaration with default value for sea level
float altitude(const int32_t press, const float seaLevel = 1013.25);
float altitude(const int32_t press, const float seaLevel) {
  /*!
  @brief     This converts a pressure measurement into a height in meters
  @details   The corrected sea-level pressure can be passed into the function if it is known,
             otherwise the standard atmospheric pressure of 1013.25hPa is used (see
             https://en.wikipedia.org/wiki/Atmospheric_pressure) for details.
  @param[in] press    Pressure reading from BME680
  @param[in] seaLevel Sea-Level pressure in millibars
  @return    floating point altitude in meters.
  */
  static float Altitude;
  Altitude =
      44330.0 * (1.0 - pow(((float)press / 100.0) / seaLevel, 0.1903));  // Convert into meters
  return (Altitude);
}  // of method altitude()

void setup() {
  /*!
  @brief    Arduino method called once at startup to initialize the system
  @details  This is an Arduino IDE method which is called first upon boot or restart. It is only
            called one time and then control goes to the main "loop()" method, from which
            control never returns
  @return   void
  */
  Serial.begin(SERIAL_SPEED);  // Start serial port at Baud rate
#ifdef __AVR_ATmega32U4__      // If this is a 32U4 processor, then wait 3 seconds to init USB port
  delay(3000);
#endif
  Serial.print(F("Starting I2CDemo example program for BME680\n"));
  Serial.print(F("- Initializing BME680 sensor\n"));
  while (!BME680.begin(I2C_STANDARD_MODE)) {  // Start BME680 using I2C, use first device found
    Serial.print(F("-  Unable to find BME680. Trying again in 5 seconds.\n"));
    delay(5000);
  }  // of loop until device is located
  Serial.print(F("- Setting 16x oversampling for all sensors\n"));
  BME680.setOversampling(TemperatureSensor, Oversample16);  // Use enumerated type values
  BME680.setOversampling(HumiditySensor, Oversample16);     // Use enumerated type values
  BME680.setOversampling(PressureSensor, Oversample16);     // Use enumerated type values
  Serial.print(F("- Setting IIR filter to a value of 4 samples\n"));
  BME680.setIIRFilter(IIR4);  // Use enumerated type values
  Serial.print(F("- Setting gas measurement to 320\xC2\xB0\x43 for 150ms\n"));  // "�C" symbols
  BME680.setGas(320, 150);  // 320�c for 150 milliseconds
}  // of method setup()
void loop() {
  /*!
  @brief    Arduino method for the main program loop
  @details  This is the main program for the Arduino IDE, it is an infinite loop and keeps on
            repeating. The "sprintf()" function is to pretty-print the values, since floating
            point is not supported on the Arduino, split the values into those before and those
            after the decimal point.
  @return   void
  */
  static int32_t  temp, humidity, pressure, gas;  // BME readings
  static char     buf[16];                        // sprintf text buffer
  static float    alt;                            // Temporary variable
  static uint16_t loopCounter = 0;                // Display iterations
  if (loopCounter % 25 == 0) {                    // Show header @25 loops
    Serial.print(F("\nLoop Temp\xC2\xB0\x43 Humid% Press hPa   Alt m Air m"));
    Serial.print(F("\xE2\x84\xA6\n==== ====== ====== ========= ======= ======\n"));  // "�C" symbol
  }                                                     // if-then time to show headers
  BME680.getSensorData(temp, humidity, pressure, gas);  // Get readings
  if (loopCounter++ != 0) {                             // Ignore first reading, might be incorrect
    sprintf(buf, "%4d %3d.%02d", (loopCounter - 1) % 9999,  // Clamp to 9999,
            (int8_t)(temp / 100), (uint8_t)(temp % 100));   // Temp in decidegrees
    Serial.print(buf);
    sprintf(buf, "%3d.%03d", (int8_t)(humidity / 1000),
            (uint16_t)(humidity % 1000));  // Humidity milli-pct
    Serial.print(buf);
    sprintf(buf, "%7d.%02d", (int16_t)(pressure / 100),
            (uint8_t)(pressure % 100));  // Pressure Pascals
    Serial.print(buf);
    alt = altitude(pressure);                                                // temp altitude
    sprintf(buf, "%5d.%02d", (int16_t)(alt), ((uint8_t)(alt * 100) % 100));  // Altitude meters
    Serial.print(buf);
    sprintf(buf, "%4d.%02d\n", (int16_t)(gas / 100), (uint8_t)(gas % 100));  // Resistance milliohms
    Serial.print(buf);
    delay(10000);  // Wait 10s
  }                // of ignore first reading
}  // of method loop()

Any tips on where the problem lies in the bsec library?
 
nevermind. got it. The adafruit seems to be setup by default with the secondary address: 0x77
So changed it here:
iaqSensor.begin(BME680_I2C_ADDR_SECONDARY, Wire);

And it works!
 
Back
Top