Hmc5883l three-axis electronic compass sensor connected with arduino

HMC5883L device introduction (1) device introduction

Name: HMC5883L Electronic Compass Compass Module (Triaxial Magnetic Field Sensor)

Model: GY-271

(2) Main technical parameters

Using the chip: HMCL5883L

Power supply: 3-5V

Communication method: IIC communication protocol

Test range: ±1.3-8 Gauss

(3) Working principle

The traditional compass uses a magnetized magnetic needle to sense the earth's magnetic field. When the magnetic field between the earth's magnetic field and the magnetic needle rotates, the magnetic needle rotates until the ends of the magnetic needle point to the magnetic south pole and the magnetic north pole of the earth. The same is true for the electronic compass, except that the magnetic needle is replaced by a magnetoresistive sensor, and the sensed geomagnetic information is converted into a digital signal output for use by the user.

(4) Product application field

Mobile phones, laptops, consumer electronics, car navigation systems and personal navigation systems.

(5) Device size chart
Hmc5883l three-axis electronic compass sensor connected with arduino
Hmc5883l three-axis electronic compass sensor connected with arduino
Hmc5883l three-axis electronic compass sensor connection arduino connection method:

Just connect the four lines VCC, GND, SDA, SCL. ArduinoGND-"HMC5883LGNDArduino3.3V-"HMC5883LVCCArduinoA4(SDA)-"HMC5883LSDAArduinoA5(SCL)-"HMC5883LSCL

(Note that the wiring is A4, A5, not D4, D5)

Programming:

1. Download the HMC5883L library file. Download address: http://soft2.wmzhe.com/download/AnsifaArduino/HMC5883L.zip

2. Unzip the HMC5883L library file to the arduino folder: arduino-0022\libraries.

3. Write the following program and download the following test program to arduino:

#include"Wire.h"

#include《HMC5883L.h》

HMC5883Lcompass;

Voidsetup()

{

Serial.begin(9600);

Wire.begin();

Compass=HMC5883L();

compass.SetScale(1.3);

compass.SetMeasurementMode(Measurement_Continuous);

}

Voidloop()

{

MagnetometerRawraw=compass.ReadRawAxis();

MagnetometerScaledscaled=compass.ReadScaledAxis();

floatxHeading=atan2(scaled.YAxis,scaled.XAxis);

floatyHeading=atan2(scaled.ZAxis,scaled.XAxis);

floatzHeading=atan2(scaled.ZAxis,scaled.YAxis);

If(xHeading“0)xHeading+=2*PI;

If(xHeading》2*PI)xHeading-=2*PI;

If(yHeading“0)yHeading+=2*PI;

If(yHeading》2*PI)yHeading-=2*PI;

If(zHeading“0)zHeading+=2*PI;

If(zHeading》2*PI)zHeading-=2*PI;

floatxDegrees=xHeading*180/M_PI;

floatyDegrees=yHeading*180/M_PI;

floatzDegrees=zHeading*180/M_PI;

Serial.print(xDegrees);

Serial.print(",");

Serial.print(yDegrees);

Serial.print(",");

Serial.print(zDegrees);

Serial.println(";");

Delay(100);

}

Open the Arduino serial monitor to see the result (X plane angle, Y plane angle, Z plane angle):

Hmc5883l three-axis electronic compass sensor connected with arduino


Screen Protector For Huawei

A TPU Screen Protector made of the super toughness of the honeycomb structure. Its unique ultra-soft properties allow it to cover the most complex curves and contours in a device.

The self-healing design of the Hydrogel Screen Protector can protect the display screen of the device from damage, leave no air bubbles, and maintain the sensitivity of the touch screen. Advanced anti-fingerprint and dust- and oleophobic overlays keep your screen smudge- and dirt-free. This overlay is also important in providing maximum touch sensitivity for improved high-speed glide and optimal touch response.

The optical transparency of the Hydrogel Film is more than 90%, showing you the most original screen color and bringing the most realistic visual experience.

If you want to know more about the product information of the Hydrogel Screen Protector for Huawei, please click the product details to view the parameters, model, picture, price and other information of the Huawei Screen Protector.
Whether you are a group or an individual, we will do our best to provide you with accurate and comprehensive information about Hydrogel Screen Protectors!


Screen Protector For Huawei,Hydrogel Film for Huawei,TPU Screen Protector for Huawei,Hydrogel Screen Protector for Huawei

Shenzhen Jianjiantong Technology Co., Ltd. , https://www.jjtscreenprotector.com