-
Notifications
You must be signed in to change notification settings - Fork 105
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
Added check connection state for i2c devices #120
base: master
Are you sure you want to change the base?
Conversation
If the BME280 isn't connected correctly you can handle this issue in your application.
@@ -40,6 +40,7 @@ BME280I2C::BME280I2C | |||
):BME280(settings), | |||
m_settings(settings) | |||
{ | |||
Wire.begin(); |
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.
This is on the user, per previous issue
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.
My investigations showed that Wire.begin()
is necessary to have a non blocking behaviour for Wire.endTransmission()
.
I just tested it here again.
src/BME280Spi.cpp
Outdated
|
||
|
||
/****************************************************************/ | ||
bool BME280Spi::IsConnected(void) { |
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.
Since these are defaulted to true, this indicates to me that IsConnected shouldn't be in the base class.
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.
That's correct. Now it's implemented much simpler! Thank you for your annotation.
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.
Please look at other comments and resolve
…class BME280I2C. No connection check in base class any more.
If the BME280 isn't connected correctly you can handle this issue in your application.
I had an assembly using the AskSinPP library. The sensor was damaged during use. While debugging the sketch stopped while initializing the BME280 sensor. If there is a check whether the sensor is acknowledging you can easier debug a hardware defect.
Related issue # and issue behavior
none
Description of changes/fixes
added new member function the check the connection by reading only the slave address. The 'endTransaction' command returns if there was a NACK on I2C line.
@mention a person to review
Steps to test
Disconnect BME280 from your microcontroller (works only for I2C BME280s). Check the return status of BME280::Initialize() maybe output some information that the sensor can't be found.
Second do the positive test by connecting the BME280 through I2C bus.
Any outstanding TODOs or known issues
not tested for BRZO, but the documentation says the same behaviour as the Wire library
not tested for SPI connections - only minor changes