I am trying to change a code from HMC6343 to hmc5883. I need the compass address for the following code
//Instruct compass to read echoes
Wire.beginTransmission(compassAddress); // transmit to device
// the address specified in the datasheet is 66 (0x42)
// but i2c adressing uses the high 7 bits so it's 33
Wire.write(0x50); // Send a "Post Heading Data" (0x50) command to the HMC6343
Wire.endTransmission(); // stop transmitting
//Wait for readings
delay(2); // datasheet suggests at least 1 ms
//Request heading reading from compass
Wire.requestFrom(compassAddress, 2); // request 2 bytes from slave device #33
the address specified in the datasheet is 66 (0x42)
The I2C in data sheets can be confusing.
0x42 = 0100 0010b but if this is the 7 bit address then it is 100 0010b and then shifted left to the 8 bit address + R/W register it is 1000 0100x = 0x84.
Then don’t forget the lsb is the r/w bit so clear/set as needed.
Some data sheets get this address already shifted to the high order 7 bits.
I that case its 0x42 and the lsb is the R/W bit.
First try the 0x84 and if doesn’t work then try non-shifted.
the address specified in the datasheet is 66 (0x42)
The I2C in data sheets can be confusing.
0x42 = 0100 0010b but if this is the 7 bit address then it is 100 0010b and then shifted left to the 8 bit address + R/W register it is 1000 0100x = 0x84.
Then don’t forget the lsb is the r/w bit so clear/set as needed.
Some data sheets get this address already shifted to the high order 7 bits.
I that case its 0x42 and the lsb is the R/W bit.
First try the 0x84 and if doesn’t work then try non-shifted.
Please note this code is for HMC6343 so is the data sheet referred to.