The direction of a moving target is an important piece of information in many wireless sensor network (WSN) applications, such as in boundary security, traffic flow control, etc. Due to its robustness, the magnetic sensor can be used to detect a passing ferromagnetic object. By using the orthogonality of two perpendicularly placed sensing units in a monomer magnetic sensor, a linear algorithm based on a magnetic dipole model to identify the ferromagnetic object's moving direction is introduced in this paper. It has been successfully applied in real WSN applications to reduce the numbers of nodes, and prolong the lifetime of the network. Both simulation and field experiments show it has strong noise immunity and more than 95% correction rate in direction detecting.