I have two hmc6343 sensors and need to change the address on one. I have run a scanner and receive the address 0x19. I am running the code shown below but after i power the sensor off and back on and run the scanner again, I still receive 0x19.
The code i am using to change the sensor i2c address.
#include <Wire.h>
#include <EEPROM.h>
//#include "SFE_HMC6343.h"
void setup() {
Wire.begin(); // Enable I2C communication as master
Serial.begin (19200); // Enable communication back to host PC at 19200 bps
}
void loop() {
// put your setup code here, to run once:
Wire.beginTransmission( 0x19);
int error = Wire.endTransmission();
if( error != 0)
{
Serial.println( "The sensor is not at 0x19");
}
else
{
Serial.println( "The sensor is found, changing I2C address");
//Wire.beginTransmission( 0x19);
//Wire.write( 0x53); // password register
//Wire.write( 0xAA); // password
//Wire.endTransmission();
//delay(1000); // not described somewhere, just for safety
Wire.beginTransmission( 0x19);
Wire.write((byte)0x00); // new I2C address
Wire.write( 0x15 << 1); // new I2C address
Wire.endTransmission();
Serial.println( "address changed");
delay(1000);
}
}