Problems with Magnetometer 5883L

Post Reply
Mirddyn
Posts: 3
Joined: Tue Jun 26, 2012 6:37 am

Problems with Magnetometer 5883L

Post by Mirddyn »

Hello,

I have received the magnetometer and spent the whole weekend trying to make it work, but it does not. I have not only followed the Honeywell manual, but I have tried the library and the configuration from the Geeetech Wiki, but it 5keeps not working.

I am able to communicate with it by I2C (1E address), and I am able to change the configuration registers (although not all the configurations that are in the Honeywell manual are accepted by the magnetometer).

The problem is that the readings from the magnetometer don't change as I change the direction of the board. I have checked that the mode is correctly configured as "continuous mode", but it keeps not changing. I am also reading the 6 data registers at the same time in order to make the magnetometer update the readings, but without any effect.

In order to have an stronger magnetic field I have finally used an external magnet, and even with that most of the times the magnetometer does not realize that there is a magnet next to it (some times it does and then goes to the full scale).

I am not using the two 4,7k resistors, as the I2C communication seems to work without them, and I didn't want to make any change in the module that could be blamed to have broken it.

Please tell me how to proceed.

Regards
User avatar
techsupport
Site Admin
Posts: 210
Joined: Sat Mar 03, 2012 2:32 pm

Re: Problems with Magnetometer 5883L

Post by techsupport »

Hi friend,

Please use 3.3 V power supply and try to use the code in the attachment to test again.

regards;
techsupport
Attachments
HMC5883L.rar
(730 Bytes) Downloaded 1143 times
Your real trustworthy partner in China!!
Email: forum@geeetech.com
Mirddyn
Posts: 3
Joined: Tue Jun 26, 2012 6:37 am

Re: Problems with Magnetometer 5883L

Post by Mirddyn »

Hello,
Actually I have always been powering the board with 3,3 Volts, Infact I am even using a logical level converter for the SCL and SDA signals to use 3,3V instead of the 5V that come from the Arduino. And there is no doubt that it is working as I have I2C communications with other devices (gyro, accel, barometer).

Regarding your code, attached you can see the readings from the serial monitor. When I make little changes in the heading the sensor doesn't change at all, then, when I make big changes (more than 90 degrees) It sends several different values and then goes back to the initial ones. It makes no sense, the sensor is malfunctioning.

How can I get a working one?

Best regards



x: -63 y: -494 z: -8
x: -64 y: -495 z: -7
x: -64 y: -497 z: -9
x: -65 y: -496 z: -6
x: -65 y: -494 z: -6
x: -66 y: -496 z: -8
x: -63 y: -497 z: -5
x: -63 y: -493 z: -4
x: -64 y: -493 z: -5
x: -67 y: -493 z: -5
x: -66 y: -497 z: -8
x: -63 y: -493 z: -6
x: -63 y: -494 z: -8
x: -67 y: -493 z: -7
x: -67 y: -498 z: -7
x: -65 y: -497 z: -7
x: -65 y: -495 z: -6
x: -64 y: -496 z: -6
x: -65 y: -495 z: -7
x: -62 y: -493 z: -5
x: -66 y: -493 z: -6
x: -65 y: -494 z: -7
x: -64 y: -493 z: -8
x: -67 y: -496 z: -6
x: -63 y: -493 z: -7
x: -66 y: -493 z: -6
x: -64 y: -491 z: -6
x: -64 y: -490 z: -9
x: -64 y: -486 z: -4
x: 1502 y: 19 z: 4357
x: 1502 y: 19 z: 4357
x: 1502 y: 19 z: 4357
x: 1502 y: 19 z: 4357
x: 1502 y: 19 z: 4357
x: 1502 y: 19 z: 4357
x: -67 y: -481 z: -6
x: -63 y: -481 z: -3
x: -62 y: -481 z: -7
x: -64 y: -484 z: -7
x: -65 y: -483 z: -5
x: -68 y: -483 z: -8
x: -63 y: -479 z: -7
x: -64 y: -484 z: -7
x: -64 y: -481 z: -7
x: -64 y: -482 z: -10
x: -65 y: -479 z: -5
x: -64 y: -479 z: -6
x: -63 y: -479 z: -6
x: -62 y: -477 z: -6
x: -63 y: -484 z: -5
x: -64 y: -478 z: -5
x: -63 y: -477 z: -2
x: -62 y: -477 z: -6
x: -61 y: -480 z: -11
x: -64 y: -479 z: -6
x: -62 y: -479 z: -5
x: -66 y: -479 z: -4
x: -67 y: -476 z: -3
x: -61 y: -478 z: -6
x: -65 y: -478 z: -6
x: -62 y: -480 z: -3
x: -66 y: -480 z: -6
User avatar
techsupport
Site Admin
Posts: 210
Joined: Sat Mar 03, 2012 2:32 pm

Re: Problems with Magnetometer 5883L

Post by techsupport »

Hi friend,

Please send your ebay user ID to forum@geeetech.com, we will offer you repalcement.

Regards;
techsupport
Your real trustworthy partner in China!!
Email: forum@geeetech.com
JohnnyBoy
Posts: 3
Joined: Tue Aug 07, 2012 12:47 pm

Re: Problems with Magnetometer 5883L

Post by JohnnyBoy »

I have done a small testprogram...

// Compass
// by johnny Niolsson <http://www.treplex.se>

// Demonstrates use of HMC5883L
// Reads data using I2C
//
// Created 07 August 2012
//
// This example code is in the public domain.


// Address Name Access
// 00 Configuration Register A Read/Write
// 01 Configuration Register B Read/Write
// 02 Mode Register Read/Write
// 03 Data Output X MSB Register Read
// 04 Data Output X LSB Register Read
// 05 Data Output Z MSB Register Read
// 06 Data Output Z LSB Register Read
// 07 Data Output Y MSB Register Read
// 08 Data Output Y LSB Register Read
// 09 Status Register Read
// 10 Identification Register A Read
// 11 Identification Register B Read
// 12 Identification Register C Read


#include <Wire.h>

#define address 0x1E //0011110b, I2C 7bit address of HMC5883L

void setup()
{
Serial.begin(9600); // start serial for output

// Init for the compass
Serial.println("Start initiating HMC5883L"); Serial.print("Adress for HMC5883L is "); Serial.print(address,DEC); Serial.print(" ("); Serial.print(address,HEX); Serial.println(")"); delay(1000);
Wire.beginTransmission(address);
Serial.println("Before Select mode register in The Init of the HMC5883L"); delay(1000);
Wire.write(0x02); // Select mode register
Serial.println("After select mode register "); delay(1000);
Wire.write(0x00); //continuous measurement mode
Serial.println("After continuous measurement mode "); delay(1000);
Wire.endTransmission();
delay(1000);

// The compass is initalized for Continous meassurement
Serial.println("The compass is initalized for Continous meassurement");

}


I find out that The Wire.endTransmission is hanging.. It seams that the HMC5883L is not reaeasing the wire.
Could this be a faulty HMC5883L or is there a bug in the Wire lib?
What happends if the HMC5883L get a wireing conection problen due to vibration. Will the program hang???
I use Arduino 1.0.1 version of the IDE and had alot of problem with the Wire lib and older examples. I downloaded a version of Wire.h/Wire.cpp that at least compile. The Question is if I have discripances in versions and thats the reason for my Wire.endTransmission hang

Could I have made someting wrong with the pullup-resistors.

My version of HMC5883L is china produced and bought on eBay. The item has 3.3V, GND and SDA/SCL but no interupt pin.
My eBay ID is 6trollmaster if you want to offer me a HMC5883L replacement or another xxDOF/GPS
User avatar
techsupport
Site Admin
Posts: 210
Joined: Sat Mar 03, 2012 2:32 pm

Re: Problems with Magnetometer 5883L

Post by techsupport »

Hi friend;

What do you mean about "Wire.endTransmission is hanging" ? The test program can't compile?
Please reference the wiki page about HMC5883Lhttp://www.geeetech.com/wiki/index.php/ ... r_Breakout
Your real trustworthy partner in China!!
Email: forum@geeetech.com
JohnnyBoy
Posts: 3
Joined: Tue Aug 07, 2012 12:47 pm

Re: Problems with Magnetometer 5883L

Post by JohnnyBoy »

The coderow Serial.println("After continuous measurement mode "); creates a responce on the console..

The next row to be executed is
Wire.endTransmission();
delay(1000);

I expect the next Serial instruction to be executed
// The compass is initalized for Continous meassurement
Serial.println("The compass is initalized for Continous meassurement");

and that it responce on the Console

I belive that the entering of Wire.endTransmission(); never gets an exit and that it is tuck within that code
User avatar
techsupport
Site Admin
Posts: 210
Joined: Sat Mar 03, 2012 2:32 pm

Re: Problems with Magnetometer 5883L

Post by techsupport »

Adding the function Wire.begin() at the start will make it executed.The reason why the program is stuck in Wire.endTransmission() is
due to the lack of the function Wire.begin() to initiate the library.
Your real trustworthy partner in China!!
Email: forum@geeetech.com
JohnnyBoy
Posts: 3
Joined: Tue Aug 07, 2012 12:47 pm

Re: Problems with Magnetometer 5883L

Post by JohnnyBoy »

That got that part working...

Now the problem is that I still cant get any reading.

I try the example code that is provided to the HMC5883L library and I get the same reading..
I have seen this before from somone else and He got exactly the same values..

I will try to connect another type of I2C device just to see if I got the IC2 part up and running. I belive I gor som I2C memory chip laying around
Post Reply