HMC5883L 3-axis digital compass module GY-273

(1 customer review)

1,00

New model: HMC5983

Out of Stock

Receive stock notification email?

SKU: HE01611-600 Categories: , Tags: , , , Send:

Description

!! No longer available !! New model: HMC5983

HMC5883L 3-axis digital compass chip on a breakout board. Connects via the I2C interface.

HMC5883L specifications:
– Based on the: HMC5883L chip.
– Works on: 3-5v.
– Interface: I2c.
– Measuring range: ± 1.3-8 Gauss.

Arduino code example:

Library

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

HMC5883L compass;


void setup(){
 Serial.begin(9600);
 Wire.begin();
 
 compass = HMC5883L(); //new instance of HMC5883L library
 setupHMC5883L(); //setup the HMC5883L
}

// Our main program loop.
void loop(){
 
 float heading = getHeading();
 Serial.println(heading);
 delay(100); //only here to slow down the serial print

}

void setupHMC5883L(){
 //Setup the HMC5883L, and check for errors
 int error; 
 error = compass.SetScale(1.3); //Set the scale of the compass.
 if(error != 0) Serial.println(compass.GetErrorText(error)); //check if there is an error, and print if so

 error = compass.SetMeasurementMode(Measurement_Continuous); // Set the measurement mode to Continuous
 if(error != 0) Serial.println(compass.GetErrorText(error)); //check if there is an error, and print if so
}

float getHeading(){
 //Get the reading from the HMC5883L and calculate the heading
 MagnetometerScaled scaled = compass.ReadScaledAxis(); //scaled values from compass.
 float heading = atan2(scaled.YAxis, scaled.XAxis);

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

 return heading * RAD_TO_DEG; //radians to degrees
}

1 rating for HMC5883L 3-axis digital compass module GY-273

  1. Electronics4Fun (verified owner) -

    Good and accurate compass sensor.

Only logged in customers who have purchased this product may leave a review.

Shipping within the Netherlands

This product will be delivered via PostNL letter post in a bubble envelope.
- €3.45 shipping costs for orders under €25.
- €2.95 shipping costs for orders between €25 - €45.
- Orders above € 45,- will be free of charge sent by PostNL letter post.

  • Ordered before 16:30 PM on workdays, shipped the same day!
    Click here for costs outside the Netherlands.
  • Product question?

      Your Name (required)

      Your Email (required)

      your question