3-Axis digital compass weird behavior

Hello,

I have recently bought an HMC5883L 3-Axis Digital compass module to use it with arduino.
I soldered the pins myself as you can see in the pic.

And I connected it to my arduino Uno using 5v Vcc, SCL to pin A5, SDA to pin A4 (I2C protocol) and I used pull up 4.7K resistors.

I tested it with an I2C Scanner and I found the device on the address 0x1E, then I used a simple example to read from it but it seems to give almost same values whatever I rotate it in all directions, with Z being always 0.

I wrote this code to see all the values in the 13 registers inside the device:

#include <Wire.h> //I2C Arduino Library
#define addr 0x1E //I2C Address for The HMC5883

void setup(){
  
  Serial.begin(9600);
  Serial.print("HMC5833L COMPASS SENSOR BEGIN");
  Serial.println();
  Wire.begin();
  
  
  Wire.beginTransmission(addr);
  
  Wire.write(0x02);
  Wire.write(0x00);
  Wire.endTransmission();//Set measueremnt mode to continuous.
}


void loop(){
  
  int cra,crb,mr,xm,xl,zm,zl,ym,yl,sr,ira,irb,irc; // Variables to read from registers
  
   
  Wire.beginTransmission(addr);//Set the pointer to the first register to start reading.
  Wire.write(0x00); 
  Wire.endTransmission();
  
  Wire.requestFrom(addr, 9);
 
  if(9<=Wire.available()){
    
    cra = Wire.read();   
    crb= Wire.read(); 
    mr = Wire.read(); 
    xm= Wire.read(); 
    xl = Wire.read(); 
    zm= Wire.read(); 
    zl= Wire.read();
    ym= Wire.read();
    yl= Wire.read();
    
  }

  Wire.beginTransmission(addr);//Set the pointer to the register 0x09 "Status register"
  Wire.write(0x09);            //bcz after reading data output the pointer jumps back to 0x03.
  Wire.endTransmission();
  
  Wire.requestFrom(addr, 4);
  if(4<=Wire.available()){

    sr= Wire.read();
    ira= Wire.read();
    irb= Wire.read();
    irc= Wire.read();
    
  
  }
  
  // Show Values
  Serial.print("Configuration register A: ");
  Serial.println(cra,HEX);
  Serial.print("Configuration register B: ");
  Serial.println(crb,HEX);
  Serial.print("Mode register: ");
  Serial.println(mr,HEX);
  Serial.print("X MSB Value: ");
  Serial.println(xm,HEX);
  Serial.print("X LSB Value: ");
  Serial.println(xl,HEX);
  Serial.print("Z MSB Value: ");
  Serial.println(zm,HEX);
  Serial.print("Z LSB Value: ");
  Serial.println(zl,HEX);
  Serial.print("Y MSB Value: ");
  Serial.println(ym,HEX);
  Serial.print("Y LSB Value: ");
  Serial.println(yl,HEX);
  Serial.print("Status register: ");
  Serial.println(sr,HEX);
  Serial.print("Identification register register A: ");
  Serial.println(ira,HEX);
  Serial.print("Identification register register B: ");
  Serial.println(irb,HEX);
  Serial.print("Identification register register C: ");
  Serial.println(irc,HEX);
  Serial.println();
  
  
 
  delay(5000);
}

And I am getting this output in the serial monitor:

There is many weird things in thes registers (ZMSB, ZLSB, Status register):

1- Z MSB and LSB are always 0 no matter what.

2- As said in the datasheet, the status register turns 3 after reading from the mode register, but it
has to go back to 1 after reading the all 6 data output registers.
Here it stays 3 after reading from the 6 output registers.

3- The most significant bit of Configuration register A should be 0 (reserved) as said in the data
sheet, but here is 1 (Idk if that’s Ok or not).

I cannot tell what the actual problem here is, why I am getting this weird behavior, so I wanna ask anyone here having experience with these sensors, what might be the problem ??

You can find attached the datasheet for the HMC5883L.

HMC5883L_3-Axis_Digital_Compass_IC.pdf (718 KB)

No pictures show up on my screen. Post output as text, with quote or code tags.

This is the output in text :

HMC58833L COMPASS SENSOR BEGIN
Configuration register A: F0
Configuration Register B: 20
Mode register: 0
X MSB Value: FD
X LSB Value: E4
Z MSB Value: 0
Z LSB VAlue: 0
Y MSB Value: FD
Y LSB Value: FE
Status register: 3
Identification register register A: 48
Identification register register B: 34
Identification register register C: 33

Configuration register A: F0
Configuration Register B: 20
Mode register: 0
X MSB Value: FD
X LSB Value: E2
Z MSB Value: 0
Z LSB VAlue: 0
Y MSB Value: FD
Y LSB Value: FE
Status register: 1
Identification register register A: 48
Identification register register B: 34
Identification register register C: 33

Configuration register A: F0
Configuration Register B: 20
Mode register: 0
X MSB Value: FD
X LSB Value: E0
Z MSB Value: 0
Z LSB VAlue: 0
Y MSB Value: FD
Y LSB Value: FF
Status register: 3
Identification register register A: 48
Identification register register B: 34
Identification register register C: 33

The delay is 5 sec between every output, and I was rotating the sensor to different angles between these mesures.

My antivirus software blocks your image preview site. Here is a simple procedure for posting images on this forum properly.

Post a link to the module data sheet or manufacturer's web page.

If it is a genuine Honeywell part, then your sensor may be defective. If the module does not have a voltage regulator and 5V-3.3V level shifters, it was almost certainly damaged when you connected it to 5V.

There are chinese clones that don't work quite the same way as the Honeywell sensor, but I think they have a different I2C address.

The soldering on the breakout board looks very bad. Cover the entire pin and use a hotter iron.

soldering.gif

soldering.gif

Ok Ill fix the soldering and see how it goes.

Here I fixed the solder :


but the output is still the same.