A magnetic sensor device comprising a first magnetic sensor, a second magnetic sensor, and a signal generator, wherein
- the first magnetic sensor is configured to detect, at a first detection position in a first reference plane, a first detection-target magnetic field and to generate a first detection signal that varies in magnitude according to a direction of the first detection-target magnetic field, wherein the first detection-target magnetic field is a magnetic field component parallel to the first reference plane,
- the second magnetic sensor is configured to detect, at a second detection position in a second reference plane, a second detection-target magnetic field and to generate a second detection signal that varies in magnitude according to a direction of the second detection-target magnetic field, wherein the second detection-target magnetic field is a magnetic field component parallel to the second reference plane,
- the signal generator generates a third detection signal by using the first detection signal and the second detection signal,
- the first detection-target magnetic field includes a first magnetic field component and a second magnetic field component,
- a strength of the second magnetic field component varies whereas none of a strength of and direction of the first magnetic field component and a direction of the second magnetic field component vary, wherein the first magnetic field component is a component of a first magnetic field at the first detection position, the component of the first magnetic field being parallel to the first reference plane, and the second magnetic field component is a component of a second magnetic field at the first detection position, the component of the second magnetic field being parallel to the first reference plane,
- the second detection-target magnetic field includes a third magnetic field component and a fourth magnetic field component,
- a strength of the fourth magnetic field component varies whereas none of a strength and direction of the third magnetic field component and a direction of the fourth magnetic field component vary, wherein the third magnetic field component is a component of a third magnetic field at the second detection position, the component of the third magnetic field being parallel to the second reference plane, and the fourth magnetic field component is a component of a fourth magnetic field at the second detection position, the component of the fourth magnetic field being parallel to the second reference plane,
- the direction of the third magnetic field component is opposite to the direction of the first magnetic field component,
- the direction of the fourth magnetic field component is opposite to the direction of the second magnetic field component, and
- a variable range of the first detection signal includes a first reference value, and a variable range of the second detection signal includes a second reference value, wherein the first reference value is an average value of a maximum value and a minimum value of the first detection signal when the direction of the first detection-target magnetic field varies over a range of 360°, and the second reference value is an average value of a maximum value and a minimum value of the second detection signal when the direction of the second detection-target magnetic field varies over the range of 360°.