-
Notifications
You must be signed in to change notification settings - Fork 39
Add SPI Interface for BME680 #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Mostly copied from the BME280 python library.
@brentru wanna try this? I know you had a BME680 recently! |
@ladyada yep! I'll test it out today on hardware |
@@ -324,7 +324,7 @@ class Adafruit_BME680_I2C(Adafruit_BME680): | |||
will be from the previous reading.""" | |||
def __init__(self, i2c, address=0x77, debug=False, *, refresh_rate=10): | |||
"""Initialize the I2C device at the 'address' given""" | |||
import adafruit_bus_device.i2c_device as i2c_device | |||
from adafruit_bus_device import i2c_device |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you changing the I2C import here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its kinda the style we use in other drivers - so im not oppsoed to this change :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @brentru. I changed it mostly to make pylint happy.
When I added the SPI code, pylint complained about the SPI import, so I "fixed" it. Not wanting the library to have two different import styles, the choice was to either change the i2c import to match the new SPI import, which would make pylint happy, or to change the SPI import to match the i2c import. Also, I feel like the imports are a bit cleaner this way.
I put it in it's own commit to make it obvious that it has nothing to do with the SPI code.
Output doesn't look correct on hardware. code.py output:
Test Setup:
|
Added the debug init parameter and copied the debug functionality from the i2c class Added the refresh_rate initi parameter Improved the SPI class docstring
In SPI mode, we must change the memory page depending on which register is being read/written. Renamed const _BME680_REG_STATUS to _BME680_REG_MEAS_STATUS to more closely match the name in the datasheet.
@brentru Thanks for testing it. It seems that the SPI interface on the BME680 is a little bit different from the BME280. On the BME680, we have to toggle between two memory pages, depending on the register we are accessing. Could you retest with the latest commit? I added the memory page toggling. If it still gives bad values, try with debug=True. The debug data might help figure out what exactly is going on there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your change seems to fix the numbers, but the write function is expecting an array.
Ok, it looks like it's working and the values were similar to the BME280. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_BME680 to 3.1.0 from 3.0.7: > Merge pull request adafruit/Adafruit_CircuitPython_BME680#16 from jraber/master Updating https://github.com/adafruit/Adafruit_CircuitPython_Lo to 1.0.1 from 3d4a850: < Merge pull request adafruit/Adafruit_CircuitPython_Lo#3 from dastels/master Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Added the following libraries: Adafruit_CircuitPython_Logger
Addresses issues #10 (SPI not implemented)
I copied the SPI interface from the BME280 library and only slightly modified it.
I haven't tested this, as I don't have a BME680. It would be great is someone with access to a BME680 could give it a try.