Skip to content

wake up command freezes Wire library #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

Open
vgoof opened this issue Jun 29, 2021 · 0 comments
Open

wake up command freezes Wire library #16

vgoof opened this issue Jun 29, 2021 · 0 comments

Comments

@vgoof
Copy link

vgoof commented Jun 29, 2021

Thanks for this library, works nicely!

I noted an issue though which of course might be a hardware issue but anyway I would like to share it. Hopefully it helps. Please note that this might be an hardware issue and I am also not an I2C expert.

I noticed that my code froze when I was using the sleep() and wake() commands, perhaps this has to do with using other I2C devices as well.

I made the following changes to fix this.

  1. I commented the code on lines 282, 283, and 284 at line 279, the chip goes to sleep without them anyway.

  2. I change line 290 to:
    _i2cPort->endTransmission(false); // stop i2c bus transmission BEFORE sending wake up request
    so instead of setting true, I set false.

  3. I commented line 302 and instead added the code below (I don't think the delay is needed). The reason is, that the wake up command seems to interfere with the normal I2C operation and on my device (a feather M0) the only way to reset it was calling begin again.
    delay(10); _i2cPort->begin();

  4. When the sensor is a sleep and you reset your program without powering down, begin will always return false. So it is not a bad idea upon begin try to wake the sensor if begin returns false. I added a member variable 'bool isResetOnBegin;" (you will probably prefer _isResetOnBegin). Then I do the following to try and wake once:
    ` bool beginSuccess = isConnected();
    if(!beginSuccess && !isResetOnBegin)
    {
    wake();
    isResetOnBegin = true;;
    }

    return beginSuccess;
    `

Hope this information helps other people!

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

No branches or pull requests

1 participant