Issues with a HMC5883L setup

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ADustyOldMuffin
 
Posts: 2
Joined: Thu Aug 31, 2017 12:37 am

Issues with a HMC5883L setup

Post by ADustyOldMuffin »

So I'm going to be trying to use the Electromagnetic Compass HMC5883L to see if it can sense cars and what not above it, anyway my main issue is anytime I try to read any data from it I get either a 0 or a -1. I originally thought I had botched my solder job and got a new one after trying everything, and I have been having just as many issues with this one as before.

My wiring is as follows -

HMC --- UNO

GND --- GND
VCC --- 5V
SCL --- A5
SDA --- A4

My code is fairly simple as start setup pretty normally, import the needed things then initialize the HMC with this-

Code: Select all

void Init_HMC5803L()
{
  /* Set the module to 8x averaging and 15Hz measurement rate */
  Wire.beginTransmission(HMC5803L_Address);
  Wire.write(0x00);
  Wire.write(0x70);
  
  /* Set a gain of 5 */
  Wire.write(0x01);
  Wire.write(0xA0);
  Wire.endTransmission();
}
I then read in values from the loop function using this function -

Code: Select all

int HMC5803L_Read(byte Axis)
{
  int Result;
  
  /* Initiate a single measurement */
  Wire.beginTransmission(HMC5803L_Address);
  Wire.write(0x02);
  Wire.write(0x01);
  Wire.endTransmission();
  delay(6);
  
  /* Move modules the resiger pointer to one of the axis data registers */
  Wire.beginTransmission(HMC5803L_Address);
  Wire.write(Axis);
  Wire.endTransmission();
  
  /* Read the data from registers (there are two 8 bit registers for each axis) */ 
  Wire.requestFrom(HMC5803L_Address, 2);
  Result = Wire.read() << 8;
  Result |= Wire.read();
  
  return Result;
}
My only output though is -1 -1 -1, and I have fussed with this all day.
Here are the datasheets - https://cdn-shop.adafruit.com/datasheet ... ass_IC.pdf

User avatar
Franklin97355
 
Posts: 23911
Joined: Mon Apr 21, 2008 2:33 pm

Re: Issues with a HMC5883L setup

Post by Franklin97355 »

What do you get when you run the library example code?

User avatar
ADustyOldMuffin
 
Posts: 2
Joined: Thu Aug 31, 2017 12:37 am

Re: Issues with a HMC5883L setup

Post by ADustyOldMuffin »

HMC5883 Magnetometer Test
--------------------------------------------
Sensor: HMC5883
Driver Ver: 1
Unique ID: 12345
Max Value: 800.00 uT
Min Value: -800.00 uT
Resolution: 0.20 uT
----------------------------------------------

Then it hangs and doesn't continue the code.

User avatar
liquidlogic
 
Posts: 12
Joined: Wed Jan 01, 2014 5:23 pm

Re: Issues with a HMC5883L setup

Post by liquidlogic »

I have the same problem with mine - no data after the "HMC5883 Magnetometer Test" Sensor/Driver/etc information.

User avatar
liquidlogic
 
Posts: 12
Joined: Wed Jan 01, 2014 5:23 pm

Re: Issues with a HMC5883L setup

Post by liquidlogic »

Ok, I think I isolated the issue:

I tried the same sketch using an Arduino Uno (not a clone), and it worked perfectly. I originally used a Nano Clone when I ran into the problem. It is not, however, isolated to a single Nano clone. None of the Nano clones that I tried were able to get it working successfully.

User avatar
vitzmuni
 
Posts: 1
Joined: Sat Oct 13, 2018 10:07 am

Re: Issues with a HMC5883L setup

Post by vitzmuni »

Hi everyone, any news regarding this issue? i'm experiencing the same thing. it enters the loop function and hangs after sensors_event_t event;
Any ideas?

User avatar
Franklin97355
 
Posts: 23911
Joined: Mon Apr 21, 2008 2:33 pm

Re: Issues with a HMC5883L setup

Post by Franklin97355 »

What board and what code are you running?

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”