Changing i2c address of sensors hmc6343

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.

Screenshot 2022-03-15 192946

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);
}
  }

Welcome to the forum.

How much ? How old ? :scream:

Did you pay 200 dollars for a 14 year old sensor ?
Sparkfun sells a module for 200 dollars : https://www.sparkfun.com/products/12916.
Sparkfun has also a datasheet and a library.

According to the datasheet, you have to write to EEPROM address 0.

  1. current I2C address of the chip
  2. EEPROM command
  3. first byte is EEPROM address
  4. second byte is data to be written to EEPROM
  Wire.beginTransmission( 0x19);
  Wire.write( 0xF1);       // EEPROM command
  Wire.write( 0x00);       // EEPROM address (zero for new I2C address)
  Wire.write( 0x15 << 1);  // new I2C address
  Wire.endTransmission();
  Serial.println( "address changed");
  delay(1000);

Every chip that can alter its I2C address has problems.

1 Like

Haha i thought the same thing when i was presented with this chip. Thank you very much for the help this solved the problem!

Unsurprisingly, they still have some in stock.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.