Traffic congestion has become a critical problem in modern society. This problem brings low work efficiency and inconvenient travel for people. In order to solve this problem of traffic congestion, it is essential to collect a large number of traffic data because all of the traffic-related decisions depend on these raw data. Many methods of collecting traffic data have recently been proposed. But these methods are usually quite expensive and intrusive. In this paper, wireless sensor networks are used to sense the vehicle information and collect the vehicle flow data. The magnetic sensor Honeywell HMC5883L is adopted, and sensed magnetic information is sent to a control center by the wireless Zigbee protocol. Based on such sensing information, filtering algorithms and decision-making algorithms are given to calculate the final vehicle flow data. The system platform is illustrated, and the experiment results show that the method proposed is very reliable and high-precision. In addition, different from the work by University of California-Berkeley, magnetic sensor nodes are placed beside the road instead of in the middle of the road. Therefore, this paper provides a method to collect the vehicle flow data, which are non-intrusive to the transportation systems.