Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lumapu
Copy link

@lumapu lumapu commented Jan 20, 2021

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

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();
Copy link
Owner

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

Copy link
Author

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.



/****************************************************************/
bool BME280Spi::IsConnected(void) {
Copy link
Owner

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.

Copy link
Author

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.

Copy link
Owner

@finitespace finitespace left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants