Go Down

Topic: HMC8553L compiling errors (Read 499 times) previous topic - next topic

kellyluu

hi, i'm trying to compile the code for HMC5883L but these errors keep appearing.
D:\Program Files (x86)\Arduino\libraries\HMC5883L\HMC5883L.cpp: In member function 'int HMC5883L::SetMeasurementMode(uint8_t)':
D:\Program Files (x86)\Arduino\libraries\HMC5883L\HMC5883L.cpp:104: warning: no return statement in function returning non-void
D:\Program Files (x86)\Arduino\libraries\HMC5883L\HMC5883L.cpp: In member function 'void HMC5883L::Write(int, int)':
D:\Program Files (x86)\Arduino\libraries\HMC5883L\HMC5883L.cpp:109: error: 'class TwoWire' has no member named 'send'
D:\Program Files (x86)\Arduino\libraries\HMC5883L\HMC5883L.cpp:110: error: 'class TwoWire' has no member named 'send'
D:\Program Files (x86)\Arduino\libraries\HMC5883L\HMC5883L.cpp: In member function 'uint8_t* HMC5883L::Read(int, int)':
D:\Program Files (x86)\Arduino\libraries\HMC5883L\HMC5883L.cpp:117: error: 'class TwoWire' has no member named 'send'
D:\Program Files (x86)\Arduino\libraries\HMC5883L\HMC5883L.cpp:128: error: 'class TwoWire' has no member named 'receive'
D:\Program Files (x86)\Arduino\libraries\HMC5883L\HMC5883L.cpp:123: warning: address of local variable 'buffer' returned
D:\Program Files (x86)\Arduino\libraries\HMC5883L\HMC5883L.cpp: In member function 'char* HMC5883L::GetErrorText(int)':
D:\Program Files (x86)\Arduino\libraries\HMC5883L\HMC5883L.cpp:139: warning: deprecated conversion from string constant to 'char*'
D:\Program Files (x86)\Arduino\libraries\HMC5883L\HMC5883L.cpp:141: warning: deprecated conversion from string constant to 'char*'

can someone pls explain to me?

thanks
kelly

Grumpy_Mike

Looks like your libary was designed for an older version of the arduino. What are you trying to compile?

kellyluu

this is the example sketch i downloaded

/*
HMC5883L_Example.pde - Example sketch for integration with an HMC5883L triple axis magnetomerwe.
Copyright (C) 2011 Love Electronics (loveelectronics.co.uk)

This program is free software: you can redistribute it and/or modify
it under the terms of the version 3 GNU General Public License as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

// Reference the I2C Library
#include <Wire.h>
// Reference the HMC5883L Compass Library
#include <HMC5883L.h>

// Store our compass as a variable.
HMC5883L compass;
// Record any errors that may occur in the compass.
int error = 0;

// Out setup routine, here we will configure the microcontroller and compass.
void setup()
{
  // Initialize the serial port.
  Serial.begin(9600);

  Serial.println("Starting the I2C interface.");
  Wire.begin(); // Start the I2C interface.

  Serial.println("Constructing new HMC5883L");
  compass = HMC5883L(); // Construct a new HMC5883 compass.
   
  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));
}

// Our main program loop.
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.
  // Find yours here: http://www.magnetic-declination.com/
  // Mine is: 2? 37' W, which is 2.617 Degrees, or (which we need) 0.0456752665 radians, I will use 0.0457
  // If you cannot find your Declination, comment out these two lines, your compass will be slightly off.
  float declinationAngle = 0.0457;
  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;

  // Output the data via the serial port.
  Output(raw, scaled, heading, headingDegrees);

  // Normally we would delay the application by 66ms to allow the loop
  // to run at 15Hz (default bandwidth for the HMC5883L).
  // However since we have a long serial out (104ms at 9600) we will let
  // it run at its natural speed.
  // delay(66);
}

// Output the data down the serial port.
void Output(MagnetometerRaw raw, MagnetometerScaled scaled, float heading, float headingDegrees)
{
   Serial.print("Raw:\t");
   Serial.print(raw.XAxis);
   Serial.print("   ");   
   Serial.print(raw.YAxis);
   Serial.print("   ");   
   Serial.print(raw.ZAxis);
   Serial.print("   \tScaled:\t");
   
   Serial.print(scaled.XAxis);
   Serial.print("   ");   
   Serial.print(scaled.YAxis);
   Serial.print("   ");   
   Serial.print(scaled.ZAxis);

   Serial.print("   \tHeading:\t");
   Serial.print(heading);
   Serial.print(" Radians   \t");
   Serial.print(headingDegrees);
   Serial.println(" Degrees   \t");
}

Nick Gammon

Read this before posting a programming question

Code tags, please.

Please state where you got this library from (link).
http://www.gammon.com.au/electronics

s_tanay

Quote
Code tags, please.



Why are code tags much nicer than just the code outside?

AWOL

#5
Sep 06, 2013, 02:26 pm Last Edit: Sep 06, 2013, 02:31 pm by AWOL Reason: 1
Quote
Why are code tags much nicer than just the code outside?

They're easier to scroll, and they don't do this:

char array [100];
int b;
int s;
int i;
...
b = 12;
s = 14;
i = 0;
...
char x= array ;
char y = array ;
char z= array ;

and so on.
Code: [Select]
char array [100];
int b;
int s;
int i;
...
b = 12;
s = 14;
i = 0;
...
char x= array [s];
char y = array [b];
char z= array [i];

See?

(that last "[font=Verdana][[/font]i]" case is probably the most common)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Grumpy_Mike


Quote
Code tags, please.

Why are code tags much nicer than just the code outside?

So you code is not mangled by the forum software thinking some things are similes or other odd formatting characters.

It is also a bit of a test:-
If you are too stupid to be able to do it you have little chance of understanding the answer. If you are too lazy, arrogant or selfish to do it then you don't deserve to get an answer.

It wasn't planned to be like that but it neatly works out like that.

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up