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

I2c._sendAddress sends wrong address #10

Open
PhilHaw opened this issue Jan 17, 2021 · 2 comments
Open

I2c._sendAddress sends wrong address #10

PhilHaw opened this issue Jan 17, 2021 · 2 comments

Comments

@PhilHaw
Copy link

PhilHaw commented Jan 17, 2021

I've found that I2c._sendAddress(address) is actually sending the address shifted right one bit.

For example, if address is 0x30 then I2c._sendAddress(address) actually sends 0x18.

As a workaround I have to use I2c._sendAddress(address << 1);

@rambo
Copy link
Owner

rambo commented Jan 17, 2021

That method just sets whatever you gave as the addrss to TWDR and waits for ACK/NACK it doesn't do any automagical bit shifting. The write & read methods of course expect the 7-bit slave address and will use the SLA_W and SLA_R macros to construct the correct 8 bit address for reading/writing.

@PhilHaw
Copy link
Author

PhilHaw commented Jan 17, 2021

I discovered this issue when I used my logic analyzer to see why my device at 0x30 wasn't responding and found that I2c._sendAddress(0x30) actually sends 0x18 so it got no ACK from my device!

Apart from that, the big bonus of your library is that it overcomes the 32 byte buffer limit in the Wire lib so big thanks for that!

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

2 participants