I2C Sensors Part Deux
If you recall from the previous tutorial, there was some question of what the I2C bus address for the module would be, so once we get the hardware installed, we will probe the bus for addresses to make sure we know which one we got. In the case of my sensor pictured above:
So this module is at the default 0x77 address. We'll note that in the test program.
We will need the Adafruit library specific to the BME-680 to get the added functionality. Update your system if it's been more than a few days, then:
$ sudo pip3 install adafruit-circuitpython-bme680
Next, I will copy the BMP280 test program, so we can leave the original untouched for comparison:
$ cp bmp280test.py bme680test.py
Now we can edit the BME680 program. If you just change all instances of bmp280 to bme680 and BMP280 to BMP680, and fix the address, the program will run! It will, of course, only give you the readings that were available in the BMP280, because that is all the program knows about. This is due partly to the regularity of the I2C protocol implemented by the Bosch devices, but also in large part to good programming by the Adafruit library developers.
We can get the two additional readings available from the BMP680 with:
With that, the full program (running) now looks like:
The source code is available in this gist.
The Adafruit page on their BME680 sensor has quite a bit of additional information on this versatile sensor, including some hints on how to calibrate the sensor. I also recommend their sensor modules, especially if you are a beginner, as their quality and support is outstanding.


Comments
Post a Comment