Skip to content

wake up command freezes Wire library #16

Open
@vgoof

Description

@vgoof

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions