I have a GY-273 which has HMC5883L chip (I guess). I am trying to get data. I find a few codes and library (I don't have enough information about HMC5883L) but always all serial port screen there are only one value. Here is my sketch:
#include <Wire.h>
#include "compass.h"
#define Task_t 10 // Task Time in milli seconds
int dt=0;
unsigned long t;
// Main code -----------------------------------------------------------------
void setup(){
Serial.begin(9600);
// Serial.print("Setting up I2C ........\n");
Wire.begin();
compass_x_offset = -48.23; //122.17;
compass_y_offset = 284.69; //230.08;
compass_z_offset = 59.87; //389.85;
compass_x_gainError = 1.07; //1.12;
compass_y_gainError = 1.09; //1.13;
compass_z_gainError = 1.01; //1.03;
compass_init(2);
//compass_debug = 1;
//compass_offset_calibration(3);
}
void loop(){
t = millis();
float load;
compass_scalled_reading();
Serial.print("x = ");
Serial.println(compass_x_scalled);
Serial.print("y = ");
Serial.println(compass_y_scalled);
Serial.print("z = ");
Serial.println(compass_z_scalled);
compass_heading();
Serial.print ("Heading angle = ");
Serial.print (bearing);
Serial.println(" Degree");
dt = millis()-t;
load = (float)dt/(Task_t/100);
Serial.print ("Load on processor = ");
Serial.print(load);
Serial.println("%");
delay(100);
}
And Serial port screen is:
Gain updated to = 1.22 mG/bit
x = -48.23
y = 284.69
z = 59.87
Heading angle = 99.62 Degree
Load on processor = inf%
x = -48.23
y = 284.69
z = 59.87
Heading angle = 99.62 Degree
Load on processor = inf%
x = -48.23
y = 284.69
z = 59.87
Heading angle = 99.62 Degree
Load on processor = inf%
x = -48.23
y = 284.69
z = 59.87

simulate this circuit – Schematic created using CircuitLab