RaemondBW / SWire

Software implementation of I2C for Arduino (Tested with the atmega328p based boards)
MIT License
3 stars 1 forks source link

Issues reading MPU6050 #4

Closed ghost closed 3 years ago

ghost commented 3 years ago

i am having a hardtime reading the value from MPU6050 the address is 0x68 but can you explain why its changing to 0xD1 in requestFrom(uint8_t address, uint8_t numBytes)

if (writeByte(((current_rw_address << 1) | 1) & 0xFF)) { stop(); return 0; }

i am new to this library so dont mind if i made mistake

RaemondBW commented 3 years ago

in i2c addresses are 7 bits long + 1 bit to indicate read/write. So the address that you write/read from is (address << 1) + (0 if write, 1 if read). 0x68 << 1 + 1 = 0xD1.

tl;dr: use address 0x34 instead.