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
Serial.begin(9600);
config(); // Start MAG3110 on
}

void loop()
{
print_values();
delay(5);
}

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
delay(15);
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("======================================================")
Serial.println(“Starting… “)
Serial.println(””)
Serial.print(“X = “);
Serial.print(read_x());
Serial.println(”--------------”);
Serial.print(" Y = “);
Serial.print(read_y());
Serial.println(”----------------");
Serial.print("Z = ");
Serial.println(read_z());
}

int mag_read_register(int reg)
{
int reg_val;

Wire.beginTransmission(MAG_ADDR); //start transmit to i2c device address 0x0E
Wire.write(reg);
Wire.endTransmission();
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 = Wire.read(); // 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);
delayMicroseconds(2);
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.