Tags: AccelerometerCompass, Magnetometer, Sensor, GY, 273, 3v, 5v, QMC5883l, Triple, Axis,

Accelerometer With Compass Magnetometer Sensor GY-273 3v-5v QMC5883l Triple Axis

  • 30.00 AED
    • Ex Tax:30.00 AED
    • Product Code:
    • Availability: In Stock
    The Honeywell HMC5883L sensor used in the module is sensitive to the earths magnetic fields in three axes. These axes are labeled as X, Y, and Z. An output is provided for each of these axes that describes the position of these axes relative to the earth’s magnetic field. As illustrated, twisting o..

    The Honeywell HMC5883L sensor used in the module is sensitive to the earths magnetic fields in three axes. These axes are labeled as X, Y, and Z. An output is provided for each of these axes that describes the position of these axes relative to the earth’s magnetic field.

    As illustrated, twisting or turning the device will provide the corresponding outputs.

    GY-273 Magnetometer Rotation vs OutputGY-273 Arduino Basic Output Tutorial

    In this tutorial, you will connect the GY-273, load a basic sketch and see an output to your serial monitor. The purpose of this tutorial is to verify that you can read and output and to

    Connect the Arduino to the GY-273

    Just four connections are required. Refer to the picture below.

    GY-273 Magnetometer Tutorial hook up

    Copy, Paste and Upload the GY-273 Example Sketch

    #include <Wire.h> //I2C Arduino Library 
    #define addr 0x1E //I2C Address for The HMC5883 
    void setup(){ 
    Serial.begin(9600); 
    Wire.begin(); 
    Wire.beginTransmission(addr); //start talking 
    Wire.write(0x02); // Set the Register 
    Wire.write(0x00); // Tell the HMC5883 to Continuously Measure 
    Wire.endTransmission(); 
    } 
    void loop(){ 
    int x,y,z; //triple axis data 
    //Tell the HMC what regist to begin writing data into 
    Wire.beginTransmission(addr); 
    Wire.write(0x03); //start with register 3. 
    Wire.endTransmission(); 
     //Read the data.. 2 bytes for each axis.. 6 total bytes 
    Wire.requestFrom(addr, 6); 
    if(6<=Wire.available()){ 
    x = Wire.read()<<8; //MSB x 
    x |= Wire.read(); //LSB x 
    z = Wire.read()<<8; //MSB z 
    z |= Wire.read(); //LSB z 
    y = Wire.read()<<8; //MSB y 
    y |= Wire.read(); //LSB y 
    } 
    // Show Values 
    Serial.print("X Value: "); 
    Serial.println(x); 
    Serial.print("Y Value: "); 
    Serial.println(y); 
    Serial.print("Z Value: "); 
    Serial.println(z); 
    Serial.println(); 
    delay(500); 
    } 
    

    Open the Serial Monitor and Verify Your Output.

    Your output should look something like this. Once you’ve established that you have an output, try turning your device along it’s various axes and view the results.

    GY-273 Arduino Tutorial Output

    Run the Adafruit Example

    You won’t need to change any of your connections.

    Get the Libraries

    If you don’t already know this, Adafruit is an awesome contributor to the Arduino community. In fact, if you’re a buyer of Arduino devices, I highly recommend you throw a few dollars their way on occasion. They’ve earned it.

    In the case of the HMC5883L, they’ve put together a couple libraries that will really get you going in the right direction. If you’re not familiar with using libraries for other devices, I suggest reading the instructions on the Arduino website.

    Like I alluded to, you will need two libraries…

    The first is Adafruit’s Unified Sensor Library.. Found HERE

    The second is Adafruit’s HMC5883L Library… Found HERE

    Run Adafruit’s HMC5883L Example

    Navigate to the Examples directory under your Arduino IDE file menu. You’ll find the HMC5883 example there. Open it, upload it and open your serial monitor.

    When the plane defined by the X and Y axes is parallel to the ground, you will get an output that indicates a compass heading.

    GY-273 Adafruit Output Example

    .rTable { display: table; width: 100%;} .rTableRow { display: table-row; } .rTableHeading { background-color: #ddd; display: table-header-group; } .rTableCell, .rTableHead { display: table-cell; padding: 3px 10px; border: 1px solid #999999; } .rTableHeading { display: table-header-group; background-color: #ddd; font-weight: bold; } .rTableFoot { display: table-footer-group; font-weight: bold; background-color: #ddd; } .rTableBody { display: table-row-group; }

    There are no reviews for this product.

    Write a review

    Please login or register to review