Why am I getting this error message?

I get this error with the code below which is very frustrating because I can't get the values I need without it.

ERROR MESSAGE:
Arduino: 1.6.5 (Mac OS X), Board: "Arduino/Genuino Uno"

Build options changed, rebuilding all
HMC5883L_calibrate_Tweaked.ino: In function 'void setup()':
HMC5883L_calibrate_Tweaked:26: error: 'class HMC5883L' has no member named 'begin'
HMC5883L_calibrate_Tweaked:32: error: 'class HMC5883L' has no member named 'setRange'
HMC5883L_calibrate_Tweaked:32: error: 'HMC5883L_RANGE_1_3GA' was not declared in this scope
HMC5883L_calibrate_Tweaked:35: error: 'class HMC5883L' has no member named 'setMeasurementMode'
HMC5883L_calibrate_Tweaked:35: error: 'HMC5883L_CONTINOUS' was not declared in this scope
HMC5883L_calibrate_Tweaked:38: error: 'class HMC5883L' has no member named 'setDataRate'
HMC5883L_calibrate_Tweaked:38: error: 'HMC5883L_DATARATE_30HZ' was not declared in this scope
HMC5883L_calibrate_Tweaked:41: error: 'class HMC5883L' has no member named 'setSamples'
HMC5883L_calibrate_Tweaked:41: error: 'HMC5883L_SAMPLES_8' was not declared in this scope
HMC5883L_calibrate_Tweaked.ino: In function 'void loop()':
HMC5883L_calibrate_Tweaked:46: error: 'Vector' was not declared in this scope
HMC5883L_calibrate_Tweaked:46: error: expected ';' before 'mag'
HMC5883L_calibrate_Tweaked:49: error: 'mag' was not declared in this scope
HMC5883L_calibrate_Tweaked:50: error: 'mag' was not declared in this scope
HMC5883L_calibrate_Tweaked:51: error: 'mag' was not declared in this scope
HMC5883L_calibrate_Tweaked:52: error: 'mag' was not declared in this scope
Multiple libraries were found for "HMC5883L.h"
Used: /Users/michaelknight/Documents/Arduino/libraries/HMC5883L
Not used: /Users/michaelknight/Documents/Arduino/libraries/Arduino-HMC5883L-master
'class HMC5883L' has no member named 'begin'

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

/*
  Calibrate HMC5883L. Output for HMC5883L_calibrate_processing.pde
  Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
  GIT: https://github.com/jarzebski/Arduino-HMC5883L
  Web: http://www.jarzebski.pl
  (c) 2014 by Korneliusz Jarzebski
*/

#include <Wire.h>
#include <HMC5883L.h>

HMC5883L compass;

int minX = 0;
int maxX = 0;
int minY = 0;
int maxY = 0;
int offX = 0;
int offY = 0;

void setup()
{
  Serial.begin(9600);

  // Initialize Initialize HMC5883L
  while (!compass.begin())
  {
    delay(500);
  }

  // Set measurement range
  compass.setRange(HMC5883L_RANGE_1_3GA);

  // Set measurement mode
  compass.setMeasurementMode(HMC5883L_CONTINOUS);

  // Set data rate
  compass.setDataRate(HMC5883L_DATARATE_30HZ);

  // Set number of samples averaged
  compass.setSamples(HMC5883L_SAMPLES_8);
}

void loop()
{
  Vector mag = compass.readRaw();

  // Determine Min / Max values
  if (mag.XAxis < minX) minX = mag.XAxis;
  if (mag.XAxis > maxX) maxX = mag.XAxis;
  if (mag.YAxis < minY) minY = mag.YAxis;
  if (mag.YAxis > maxY) maxY = mag.YAxis;

  // Calculate offsets
  offX = (maxX + minX)/2;
  offY = (maxY + minY)/2;

  /*Serial.print(mag.XAxis);
  Serial.print(":");
  Serial.print(mag.YAxis);
  Serial.print(":");
  Serial.print(minX);
  Serial.print(":");
  Serial.print(maxX);
  Serial.print(":");
  Serial.print(minY);
  Serial.print(":");
  Serial.print(maxY);
  Serial.print(":");*/
  Serial.print(offX);
  Serial.print(":");
  Serial.print(offY);
  Serial.print("\n");
}

There appears to be two flavors of the header file. The one located at:

does not contain the methods you used in your code. However, the file found at:

does. Are you sure you downloaded the correct library file?

econjack:
There appears to be two flavors of the header file. The one located at:

arduino/Libraries/HMC5883L/HMC5883L.h at master · manifestinteractive/arduino · GitHub

does not contain the methods you used in your code. However, the file found at:

Arduino-HMC5883L/HMC5883L.h at master · jarzebski/Arduino-HMC5883L · GitHub

does. Are you sure you downloaded the correct library file?

I'm pretty sure I followed along to this and I downloaded the files as instructed:

Video Tutorial

It seems pretty clear to me you need to download and install the "other" version and give it a try.

econjack:
It seems pretty clear to me you need to download and install the "other" version and give it a try.

Well so much for this being an easy task today.... sure I thought what could be simpler go to the site download the library, run the calibrate file, get the off set values and plug them into my other code..... right?? but Nooooooooo nothing but errors no matter what..... like what am I not installing these blasted libraries correctly or something?

Yup... its like right off the hop I get this crap? I don't get it what am I doing wrong? The library is downloaded and this is the same file the guy is using on Brainy Bits ??

I don't think you need

  • master
    in the library name.
    .

LarryD:
I don't think you need

  • master
    in the library name.
    .

I pulled out the "Master" but I still get the same error crap?

Arduino: 1.6.5 (Mac OS X), Board: "Arduino/Genuino Uno"

HMC5883L_calibrate.ino: In function 'void setup()':
HMC5883L_calibrate:26: error: 'class HMC5883L' has no member named 'begin'
HMC5883L_calibrate:32: error: 'class HMC5883L' has no member named 'setRange'
HMC5883L_calibrate:32: error: 'HMC5883L_RANGE_1_3GA' was not declared in this scope
HMC5883L_calibrate:35: error: 'class HMC5883L' has no member named 'setMeasurementMode'
HMC5883L_calibrate:35: error: 'HMC5883L_CONTINOUS' was not declared in this scope
HMC5883L_calibrate:38: error: 'class HMC5883L' has no member named 'setDataRate'
HMC5883L_calibrate:38: error: 'HMC5883L_DATARATE_30HZ' was not declared in this scope
HMC5883L_calibrate:41: error: 'class HMC5883L' has no member named 'setSamples'
HMC5883L_calibrate:41: error: 'HMC5883L_SAMPLES_8' was not declared in this scope
HMC5883L_calibrate.ino: In function 'void loop()':
HMC5883L_calibrate:46: error: 'Vector' was not declared in this scope
HMC5883L_calibrate:46: error: expected ';' before 'mag'
HMC5883L_calibrate:49: error: 'mag' was not declared in this scope
HMC5883L_calibrate:50: error: 'mag' was not declared in this scope
HMC5883L_calibrate:51: error: 'mag' was not declared in this scope
HMC5883L_calibrate:52: error: 'mag' was not declared in this scope
Multiple libraries were found for "HMC5883L.h"
Used: /Users/michaelknight/Documents/Arduino/libraries/HMC5883L
Not used: /Users/michaelknight/Documents/Arduino/libraries/Arduino-HMC5883L
'class HMC5883L' has no member named 'begin'

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

What does ANY of that even mean?

This is the code I'm needing the off set values for as it works "Almost accurate" but is off.

#include <Wire.h>
#include <HMC5883L.h>

HMC5883L compass;
int error = 0;

void setup()
{
Serial.begin(115200);

//Serial.println(“Starting the I2C interface.”);
Wire.begin();


//Serial.println(“Constructing new HMC5883L”);
compass = HMC5883L();

//Serial.println(“Setting scale to +/- 1.3 Ga”);
error = compass.SetScale(1.3); // Set the scale of the compass.
if(error != 0) // If there is an error, print it out.
Serial.println(compass.GetErrorText(error));

//Serial.println(“Setting measurement mode to continous.”);
error = compass.SetMeasurementMode(Measurement_Continuous); // Set the measurement mode to Continuous
if(error != 0) // If there is an error, print it out.
Serial.println(compass.GetErrorText(error));


//Defines pins Our LEDs are On
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
}

void loop()
{
// Retrive the raw values from the compass (not scaled).
MagnetometerRaw raw = compass.ReadRawAxis();
// Retrived the scaled values from the compass (scaled to the configured scale).
MagnetometerScaled scaled = compass.ReadScaledAxis();

// Values are accessed like so:
int MilliGauss_OnThe_XAxis = scaled.XAxis;// (or YAxis, or ZAxis)

// Calculate heading when the magnetometer is level, then correct for signs of axis.
float heading = atan2(scaled.YAxis, scaled.XAxis);

// Once you have your heading, you must then add your ‘Declination Angle’, which is the ‘Error’ of the magnetic field in your location.
// (+) Positive or (-) for negative
// For Winnipeg, Manitoba CANADA declination angle is +3 Degrees 8' E (positive)
// Formula: (deg + (min / 60.0)) / (180 / M_PI);
// Find yours here: http://www.magnetic-declination.com/
float declinationAngle = (03.0 + (08.0 / 60.0)) / (180 / M_PI);
heading += declinationAngle;

// Correct for when signs are reversed.
if(heading < 0)
heading += 2*PI;

// Check for wrap due to addition of declination.
if(heading > 2*PI)
heading -= 2*PI;

// Convert radians to degrees for readability.
float headingDegrees = heading * 180/M_PI;

//Light North LED
if(headingDegrees > 325 or headingDegrees < 45)
{
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
Serial.println("N");
}

//Light South LED
if(headingDegrees > 135 and headingDegrees < 225)
{
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
digitalWrite(10, HIGH);
Serial.println("S");
}

//Light West LED
if(headingDegrees > 225 and headingDegrees < 325)
{
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
Serial.println("W");
}

//Light East LED
if (headingDegrees > 45 and headingDegrees < 135)
{
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
digitalWrite(10, LOW);
Serial.println("E");
}

Output(raw, scaled, heading, headingDegrees);
}

void Output(MagnetometerRaw raw, MagnetometerScaled scaled, float heading, float headingDegrees)
{
Serial.print(headingDegrees);
//Serial.println(” Degrees \t”);

delay(500);
}

I am not clear whether you followed the advice in replies #1 and #3

UKHeliBob:
I am not clear whether you followed the advice in replies #1 and #3

Yes and as I had mentioned I get the same error messages, I posted the error messages. I followed the video to the letter, downloaded the libraries, even the other one mentioned So I have libraries up the wazzooo. And I still get errors as I have posted.
It's very frustrating Bob.

I just downloaded the library and everything works fine.
(edit: With the example in your opening post)

I am using IDE 1.06

This is where I put the library on a PC:

C:\Users\YOURNAME\Documents\Arduino\libraries\HMC5883L

.

Did you close and restart the IDE after making library changes?

LarryD:
Did you close and restart the IDE after making library changes?

yes and my directory for the files is correct too. I'm on a mac but the directory structure is still pretty much the same.
documents/Arduino/Libraries/

Arduino IDE 1.6.5

please people check my attachments and read carefully All of the errors I get and directory structure set up I have attached screen captures... as near as I can tell there is no reason for the errors but I get them??

Try removing :
Arduino-
Then restart IDE


.

LarryD:
Try removing :
Arduino-
Then restart IDE


.

Thank you LarryD that seemed to work :smiley: :smiley: :smiley: :smiley:

one problem down.... always another one to take it's place :frowning:
Every time I run this code for calibration I get different results every time?

/*
  Calibrate HMC5883L. Output for HMC5883L_calibrate_processing.pde
  Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
  GIT: https://github.com/jarzebski/Arduino-HMC5883L
  Web: http://www.jarzebski.pl
  (c) 2014 by Korneliusz Jarzebski
*/

#include <Wire.h>
#include <HMC5883L.h>

HMC5883L compass;

int minX = 0;
int maxX = 0;
int minY = 0;
int maxY = 0;
int offX = 0;
int offY = 0;

void setup()
{
  Serial.begin(9600);

  // Initialize Initialize HMC5883L
  while (!compass.begin())
  {
    delay(500);
  }

  // Set measurement range
  compass.setRange(HMC5883L_RANGE_1_3GA);

  // Set measurement mode
  compass.setMeasurementMode(HMC5883L_CONTINOUS);

  // Set data rate
  compass.setDataRate(HMC5883L_DATARATE_30HZ);

  // Set number of samples averaged
  compass.setSamples(HMC5883L_SAMPLES_8);
}

void loop()
{
  Vector mag = compass.readRaw();

  // Determine Min / Max values
  if (mag.XAxis < minX) minX = mag.XAxis;
  if (mag.XAxis > maxX) maxX = mag.XAxis;
  if (mag.YAxis < minY) minY = mag.YAxis;
  if (mag.YAxis > maxY) maxY = mag.YAxis;

  // Calculate offsets
  offX = (maxX + minX)/2;
  offY = (maxY + minY)/2;

  /*Serial.print(mag.XAxis);
  Serial.print(":");
  Serial.print(mag.YAxis);
  Serial.print(":");
  Serial.print(minX);
  Serial.print(":");
  Serial.print(maxX);
  Serial.print(":");
  Serial.print(minY);
  Serial.print(":");
  Serial.print(maxY);
  Serial.print(":");*/
  Serial.print(offX);
  Serial.print(":");
  Serial.print(offY);
  Serial.print("\n");
}

Maybe your sensor is responding to metal near by.
.

Knightriderguy:
one problem down.... always another one to take it's place :frowning:
Every time I run this code for calibration I get different results every time?

How much difference? If something didn't change at all, it wouldn't need calibration, would it?

aarg:
How much difference? If something didn't change at all, it wouldn't need calibration, would it?

Could be metal.... from what I hear these blasted things are super sensitive.... lol makes me wonder how I'm going to install that in the car :wink:

I made a little video demo of the calibration process I went through, lol a few times now :wink:

Video Demo Of Calibration

Maybe mount it on a metal plate permanently.
.