i have an BME680 env sensor and wanted to get it working with my rock pi 4. However, its a paint to figure out how to read in SDA and SDL propperly. Adafruit has written a lib for it: https://github.com/adafruit/Adafruit_CircuitPython_BME680 but i an not make us of it as there are missing attributes (maybe because of the different arch).
My suggestion would be that you avoid the adafruit library. There is no use for it AT ALL.
You really have two choices;
Kernel driver, userspace driver.
You can find the kernel driver… in the kernel. You will have to enable it in your kernel configuration, and in your devicetree, and rebuild… then it should work.
Alternatively, if you want to go with a userspace driver, you want to go right to the source;
Now the really neat thing about their driver, is that they designed it to be completely independent of the underlying operating system. That means that it can run as a userspace driver on Linux, or as a bare-metal driver on a microcontroller. The only downside to this is that in order to have this flexibility, there are a few functions that you have to write yourself.
In the readme, look down under the heading “Templates for function pointers”. Pick the proper 3 functions to implement, and implement them. Since you’re using I2C, you’ll want to implement user_delay_ms, user_i2c_read, and user_i2c_write.
user_delay_ms is trivial. All it needs is one line; usleep(1000*period);
One thing to note about the Bosch driver; there is possibly a bug in it right here;
I have a feeling that it won’t hit you in the bme680 as it hit me in the bme280, because it looks like they reversed the order of the get_regs and soft_reset calls prior to the get_calib_data call. Basically, after the device is reset, it takes a little bit of time for the chip to finish booting before the calibration data is available to read.
With the order of those calls being reversed, and the fact that you will be running as linux userspace (whereas I was running on a multi-core microcontroller), it probably won’t hit you, HOWEVER, if it does, you can always do this; https://github.com/BoschSensortec/BME280_driver/pull/74