0

Issues with a HMC5883L setup
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Issues with a HMC5883L setup

by ADustyOldMuffin on Thu Aug 31, 2017 12:52 am

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 | TOGGLE FULL SIZE
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 | TOGGLE FULL SIZE
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/datasheets/HMC5883L_3-Axis_Digital_Compass_IC.pdf

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

Re: Issues with a HMC5883L setup

by franklin97355 on Thu Aug 31, 2017 10:26 pm

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

franklin97355
 
Posts: 19230
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Issues with a HMC5883L setup

by ADustyOldMuffin on Thu Aug 31, 2017 11:30 pm

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.

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

Re: Issues with a HMC5883L setup

by liquidlogic on Thu Aug 16, 2018 3:19 pm

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

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

Re: Issues with a HMC5883L setup

by liquidlogic on Wed Aug 29, 2018 3:12 pm

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.

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

Re: Issues with a HMC5883L setup

by vitzmuni on Sat Oct 13, 2018 10:08 am

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?

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

Re: Issues with a HMC5883L setup

by franklin97355 on Sat Oct 13, 2018 2:33 pm

What board and what code are you running?

franklin97355
 
Posts: 19230
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Please be positive and constructive with your questions and comments.