GY-273 module berdasarkan Honeywell HMC5883L IC low-field magnetic sensor dengan sebuah interface digital untuk aplikasi kompas dan magnetometry dengan biaya yang murah dan mempunyai akurasi 1° – 2° . Interface nya menggunakan protokol I2C serial bus sehingga praktis dan mudah untuk diaplikasikan.
Spesifikasi
- HMC5883L module (three-axis magnetic field module)
- Model: GY-273
- IC: HMC5883L
- Module Power supply : 3-5v
- Communication: IIC communication protocol
- Measuring range: ± 1.3-8 gauss
- Size: 13.9 x 18.5mm
Wiring Diagram
Kode Program
#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); }
Output Program
Output bisa dilihat pada Serial Monitor dan seharusnya tampak seperti berikut:
X Value: 200
Y Value: 191
Z Value: -356……. dst
Leave a Reply