Newbie alert! Trying to use the C++ boilerplate .....epic fail

Hey all,
I am trying to use the C++ boilerplate for the first time to build the BME688 C/C++ in visual studio code. I have followed the instructions and now I am at the point where I need to edit the CMakelists.txt to pull in the Pimoroni librares ect…

And…I’m stuck…

I noticed the base boilerplate example is for “Pico explorer” main.cpp pulls in this .h file based on the CMake file they provide and the library is detected by main.cpp.

So I used that as my guide post to try and start to setup the BME68X libraries,
Immediately after editing the CMakelists, the following fail as cannot find the location/file:
#include “pico/stdlib.h”
#include “bme68x.hpp”
#include “common/pimoroni_i2c.hpp”

I decided to tackle one at a time, starting with common/pimoroni_i2c.hpp
Edit CMakelists, and nothing. Also why is it bombing on pico/stdlib.

My folder structure is as such
in there I have my Pico SDK installed fine per the instructions from Raspberry ( I can use visual studio code on my projects no problem)
SDK path has been saved in my .bashrc file as well as added to the VS settings.json as the Pimoroni documentation talks about.

folders are right next to each other
/pico/pico-sdk (official from RPi)
/pico/pico-boilerplate (where I’m trying to build the BME example

The build process finds the compiler, version ect…but bombs out.
I have cleared out main.cpp because I dragged in the cpp and hpp files from:
just the cpp and hpp files.

here is my CMakelist.txt file I know this is what I need to fix somehow and I probably dont/shouldn’t drag those cpp .hpp files into my workspace.

cmake_minimum_required(VERSION 3.12)

# Change your executable name to something creative!
set(NAME bme688) # <-- Name your project/executable here!


# Gooey boilerplate
project(${NAME} C CXX ASM)

# Initialize the SDK

# Add your source files
    main.cpp # <-- Add source files here!

#include(libraries/pico_explorer/pico_explorer) <------this was the orginial code in the shell boilerplate

# Include required libraries
# This assumes `pimoroni-pico` is stored alongside your project
include(/home/pi/Desktop/pico/pico/pimoroni-pico/common/pimoroni_common.hpp) #<---here I tried just /common/pimoroni orginially, by giving the full path I get less errors.
include(drivers/bme68x/src)   #<-----added this, didnt do anything
include(pico_stdlib hardware_i2c) #<----addded this didn't do anything

# Pull in pico libraries that we need
target_link_libraries(${OUTPUT_NAME} pico_stdlib hardware_i2c pimoroni_i2c bme68x) #<---added pico_stdlib, hardware_i2c and bme68x, pimoroni_i2c was there from the example

# create map/bin/hex file etc.

# We can't control the uninitialized result variables in the BME68X API
# so demote unitialized to a warning for this target.
target_compile_options(${DRIVER_NAME} INTERFACE -Wno-error=uninitialized)

# Don't forget to link the libraries you need!
    bme68x   #<----I added this the above was already there
 # <-- List libraries here!  (I didn't write this array its part of the example)

#Display command line
#pico_enable_stdio_uart(bme688 1)
#pico_enable_stdio_usb(bme88 1)   <----had to comment this out, I added it but, throwing errors so I figured deal with that later.

# create map/bin/hex file etc.

#<--I removed some code here that was basically creating a zip file and packing it up, I dont need that.

How the heck to I get a proper CMakelists.txt to make this work to compile the BME688? I’m terrible at CMAKE, I have two book on it and it still confuses me!

I was able to compile all of the examples using the instructions provided so I have U2F’s of every project. I have a BME 680 hooked up and I put the 688 U2F on it but nothing happens, well maybe something happens but nothing is outputted to the terminal (don’t know if that was setup or not). Also its a 680 not a 688 so I don’t know if maybe its not compatible, and I also don’t know what I2C pins the U2F is using I figured the default ones so I hooked up to pins 4 and 5. I have no way of knowing if the U2F is doing anything.

I need someone with wizard magic skills to help me out and tell me what my CMakelist.txt files needs to look like and if I should be copy/pasting any files into my Visual Studio workplace. I just need one solid example that pulls things in from multiple locations from the Pimoroni-pico so I can understand it.

The boilerplate is too barebones for me and I’m sure I can mess with it for decades trying to figure it out. Hoping someone out there is gracious enough to help me. I admit I suck at this, I’ve tried to research it on my own but I’m not getting anywhere.

I would literally paypal someone some cash for a working CMakelist.txt file that pulls in everything (with some explanation commented out) I need and compiles the program so I can and also tells me which files I need to add to Visual Studio Workspace. That way I can start to edit it and build my program (the 680 is just part of my program I want to build). I just need some instructions for super dummies :(

I don’t use Micropython. I am a C/C++ guy. So please don’t suggest “just use the python version”.

-A very confused and loyal customer.

Well I think I might have got it. It compiled, and its reading in the terminal “fetching 10 readings please wait” I know it can take 20 mins for the chip to init I read that on the site. So hopefully I’ll get some output here soon.

This is the weird setup ever. I dont have any files in my Visual Studio code project except for one main.cpp that I wiped and pasted the contents of one of the cpp programs (parallel output). I had go go look at the Micropython code to find which pins it was using for I2C. I had guessed right but this make it very hard to change the code because I am using files buried in the Pimoroni-Pico folders. I wish I had the c,h,cpp,hpp files all in a nice structure but I dont have that skillset. I really hope I get readings…come on 20 minutes…

Well I’m getting data. Not sure it makes sense. But I guess its a start.

You might also want to try my implementation (at least to compare the cmake stuff). You can find it here: GitHub - bablokb/pico-bme688: Read the BME688 with a Raspberry Pi Pico using the official API of Bosch-Sensortec. Note that this is only the library project, I have a few additional repos named pico-bme688-xxx which use the library to create executables.

Regarding the question about the data: IMHO the sensor is useless unless you have very specific needs to detect VOCs (volatile organic compounds). No problem to distinguish different smelling cheeses, but I put the sensor next to my 3D-printer and the data does not show any relevant difference between PLA and PETG. My nose is a better sensor in this respect. In a second experiment I spent hours in a closed room to see if this is reflected in the data, but no chance. A CO2-sensor would detect the air-quality much better.

Thanks, I appreciate it! I just want to at least get it working the values I’m getting make zero sense.

Well I spent the entire day getting your projects build (cause I suck).

I have 1. The Bosch API downloaded and init’d from github,
then I did 2. the general bme688 github page same steps as above
lastly I did 3 the parallel example using the recusive init.

I was able to compile the last one in visual studio code, no errors, good stuff gave me a parallel u2f.
However, now I went to test thinking SUCCESS! I run a terminal and I get:

API name [bme68x_init]  Error [-3] : Device not found
TimeStamp(ms), Temperature(deg C), Pressure(Pa), Humidity(%), Gas resistance(ohx
API name [bme68x_get_data]  Warning [2] : No new data found

So disappointing. I am using I2C pins 2 and 3 as the CMakeFiles.txt show.

@bablokb any thoughts, I mean I have to be super close its got to be something dumb I did (or didn’t do). Nothing else connected just a plain pico and the BME.

Thanks (BTW your code is awesome!)

Grabbed some fresh wires and moved the pico to another part of the breadboad. Nothing same thing :(. I know the chip works because when I attempted the other Pimoroni code I was getting numbers so the chip is outputting data. Not sure why this way it isn’t.

I ended up building the rest of your examples, the one that acted differently was the scan code, that one would produce a few random numbers piled on top of a printf statement.

This is what the scan code outputted:

,0API name [bme68x_get_data]  Warning [2] : No new data found                                                         
,536875API name [bme68x_get_data]  Warning [2] : No new data found                                                    
,0API name [bme68x_get_data]  Warning [2] : No new data found                                                         
API name [bme68x_get_data]  Warning [2] : No new data found                                                           
100035,84.5,5422304,4165268,1116742API name [bme68x_get_data]  Warning [2] : No new data found                        
,1712857API name [bme68x_get_data]  Warning [2] : No new data found                                                   
,553777API name [bme68x_get_data]  Warning [2] : No new data found                                                    
,537141API name [bme68x_get_data]  Warning [2] : No new data found 

Don’t think that is doing anything really. The rest show device not detected or just prints no data found depending on the program. I tried using a stemma conntector (4 pin) on one of the Pimoroni Pico Lipo’s and on to the BME, that resulted in literally nothing on the console, I dont know if there is more that has to be done to work with those. The only thing I can think of it looks like your code uses the “high” address for the chip, and to use that you have to solder the connection on the BME. I tried using a piece of wire to make the connection but still nothing changed. Maybe I’ll see if I can change it in the code/recompile and maybe that will work? Woof, this sucks :( I just want to use the BME!

Eureka! Turns out was the high IC2 address of the BME being used in the code when the chip defaults to the low address. So my ghetto hold a wire to try and bridge it didn’t work. I changed the code, had to clear out the cmake cache then I saw it build with the

I was hopeful and sure enough! Data, we have data!!!


I just need to play around and see how to calibrate it more and also display AQI. I read through the Bosch document, it was confusing I dont understand all these heat array numbers. Going to have to spend some time on it. Also looks like temp is off by 5 degrees F. I changed the altitude in the CMakeFile already. Even if the AQI sucks I still want it cause why not :)

If you have advice on the above I’ll take it. I owe you a drink. PM or something and I can paypal you some cash for your help and the code!!


I’m glad it is working, you owe me nothing :-)

To be honest, I don’t have the Pimoroni-breakout, I have one from Adafruit and one from pi3g. That is probably the reason that my code defaults to the high address.

Temperature is a big problem with this sensor. For the gas-measurement, it has to heat up an internal plate and that seems to disturb the measurement. Best thing is to pause between measurements and send the pico to deep-sleep in between.

I would not recommend this sensor to anyone anymore. Best is to use a BME280 (temperature, pressure, humidity) or if you can do without the pressure I would recommend an AHT20. If you look at the datasheet and the complicated mathematical formulas needed for the BME688, it seems to imply that the calculated values are very exact, but they aren’t. This is just over engineered German BS (I am German, but that is how we are).

I now own an ENS160 which gives an AQI directly. I did not test it yet, so I can’t tell if it gives me better results for my use-cases.

@bablokb I appreciate the honest feedback. I believe you as you seem to know what you are doing I am building a project that gives the most data about the environment around me. I’ll use this chip for somethings like what it provides now with maybe a slight modification for heat.

I have temp/humidity covered with a very easy to use (code wise) DHT22. Its very accurate. I wanted pressure, and the other goodies the BME has, sad that I have another ordered this time a BME 688 :(

I will look into the chips you shared. If you have recommendations for good AIQ and other types of general sensors, (Waveshare makes a Flame sensor) but I can’t find it separately, just as part of a kit they sell. I wanted to add that as well. I have a 7.5 inch e-paper that is going to display all the data and update it every 1 or 2 minutes. I’m adding GPS coordinates and light sensors too. Again just for fun and because some of those projects will be used for other projects in the future. I love Pimoroni and their Pico Lipo’s especially but this chip was a major disappointment. I am going to work on another I bought from them today the LTR-559. I hope it goes better than this one did. You saved me on the the BME. Would it be ok if we kept in touch and maybe I could ask for help from you now and then. Again I don’t mind giving you some cash for your time. You have been very generous and I would love to return the favor. I was checking your github page and marking things down. If you have other code for Pico sensors/projects you’ve dont that are not github throw them up there! They can help me and others like me who just need some guidance!

Anglerfish27 --From the U.S.