Weird values from heading using QMC5883L or magetometer code

Hello everyone, I am trying to calculate the rough heading using the QMC5883L Magnetometer using this line of code (\Heading = atan2(y, x)* 180/PI;). I have not calibrated the magnetometer but the values aren't near completing a full 360-degree rotation when I fully rotate it. Here is my code: \#include <SoftwareWire.h>

SoftwareWire myWire(3,2);
// QMC5883L I2C address
#define QMC5883L_ADDRESS 0x0D

double heading;

// QMC5883L register addresses
#define QMC5883L_X_REG_L 0x00
#define QMC5883L_X_REG_H 0x01
#define QMC5883L_Y_REG_L 0x02
#define QMC5883L_Y_REG_H 0x03
#define QMC5883L_Z_REG_L 0x04
#define QMC5883L_Z_REG_H 0x05
#define QMC5883L_STATUS 0x06

void setup() {
Serial.begin(9600);
myWire.begin();

// Initialize the QMC5883L
myWire.beginTransmission(QMC5883L_ADDRESS);
myWire.write(0x09); // Write to the control register
myWire.write(0b00001101); // Set the measurement mode, data rate, and range
myWire.endTransmission();
}

void loop() {
// Read the raw data from the QMC5883L
myWire.beginTransmission(QMC5883L_ADDRESS);
myWire.write(QMC5883L_X_REG_L);
myWire.endTransmission();
myWire.requestFrom(QMC5883L_ADDRESS, 6);

int16_t x = myWire.read() | (myWire.read() << 8);
int16_t y = myWire.read() | (myWire.read() << 8);
int16_t z = myWire.read() | (myWire.read() << 8);

Serial.print("Heading: ");
Serial.println(heading);

heading = atan2(y, x) * 180 / PI;
}\\

When I rotate the sensor 360 degrees holding the sensor as flat as possible, here are my results in the 'txt' file:
RawMagValues.txt

What's wrong, or is this how a magnetometer works when the sensor isn't calibrated?

Magnetometers don't work as compasses "out of the box". See this excellent overview and tutorial to learn how to calibrate them.

Plot the true X and Y raw values as you move in a circle: the actual magnetometer readings, not the heading. If they do not form a circle centered on the origin, then the equation you are using for heading will not work.

But I have seen other people use this equation to find the (very rough) heading. In my case the heading is only changeing by like 3 when rotating it 360 degrees which just seems weird. Is this normal?

Perhaps "other people's" compasses weren't as hopelessly far out of calibration as yours appears to be.

No one will know until you make the plot suggested above.