Compiling error for MAG3110 triple-axis magnetometer

Hi, we are using the triple-axis magnetometer MAG3110 with Arduino UNO to detect disturbances in the magnetic field. We are hoping you can help us with the following problems. We wired VCC to 3.3V, GND to GND, SDA to A4, SCL to A5. Are we missing any wiring in our circuit? (do we need to connect INT to VIN?)

For the program, which library do we use? (wire library?)

Here’s a copy of our program:

#include <Wire.h>

#include <Wire.h> // Import wire library
#define MAG_ADDR 0x0E //i2C Address 7Bit address

void setup()
Wire.begin(); // Start i2c bus this optional for master
config(); // Start MAG3110 on

void loop()

void config(void)
Wire.beginTransmission(MAG_ADDR); // Transmit to i2c device 0x0E
Wire.write(0x11); // control the register 2
Wire.write(0x80); // set to write 0x80 to enable auto resets
Wire.endTransmission(); // set to stop transmitting
Wire.beginTransmission(MAG_ADDR); // set to transmit i2c device 0x0E
Wire.write(0x10); // control register 1
Wire.write(1); // set to write 0x01 to enable active mode
Wire.endTransmission(); // set tp stop transmitting

void print_values(void)
serial.print("--------- 14CORE | MAG3110 3-AXIS TEST CODE ----------")
Serial.println(“Starting… “)
Serial.print(“X = “);
Serial.print(" Y = “);
Serial.print("Z = ");

int mag_read_register(int reg)
int reg_val;

Wire.beginTransmission(MAG_ADDR); //start transmit to i2c device address 0x0E
delayMicroseconds(2); //Delay for 1.3 to start and stop

Wire.requestFrom(MAG_ADDR, 1); // set to request 1 byte
while(Wire.available()) // set the slave may write less than requested
reg_val =; // starting reading the byte

return reg_val;

int mag_read_value(int msb_reg, int lsb_reg)
int val_low, val_high; //set variable to define the MSB and LSB
val_high = mag_read_register(msb_reg);
val_low = mag_read_register(lsb_reg);
int out = (val_low|(val_high << 8)); //concatenate the MSB and LSB
return out;

int read_x(void)
return mag_read_value(0x01, 0x02);

int read_y(void)
return mag_read_value(0x03, 0x04);

int read_z(void)
return mag_read_value(0x05, 0x06);

When we compiled it, it showed we have an error for:

serial.print("--------- 14CORE | MAG3110 3-AXIS TEST CODE ----------")

The program told us this:
exit status 1
‘serial’ was not declared in this scope

We are just confused at how to fix the error and if we are missing anything important. Any help is greatly appreciated, thanks in advance! :slight_smile:

Serial, not serial.

Edit: you've got a brief timeout to allow you to read the forum posting guidelines.