Enhanced Magnetic Wireless Sensor Network Algorithm for Traffic Flow Monitoring in Low-Speed Congested Traffic

Traﬃc ﬂow monitoring using magnetic wireless sensor networks in chaotic cities of developing countries represents an emergent technology. One of the challenges facing such deployment is the development of eﬀective detection signal-processing algorithm in low-speed congested traﬃc based on the Earth’s magnetic ﬁelds. The proposed algorithm is the performance improvement of the previous algorithm known as the Scanning and Decision Algorithm (SDA). The novel algorithm based on the moving-average model includes an addition of a two-pass moving-average ﬁlter to improve the signal-to-noise ratio after analog-to-digital conversion. The improved mathematical capabilities enable us to capture additional features of vehicular direction and clas-siﬁcation. Other outputs of the model include vehicular detection, count, speed, and travel time index (TTI). The performance evaluation of a proposed algorithm is conducted through on-site real-time experiments at the designated road segment. The results indicated that the roadside magnetic sensor improved vehicular detection, count, travel time index, and classiﬁcation during low-speed congested traﬃc state.


Introduction
Wireless sensor networks (WSNs) have been deployed in various sensing tasks in ambiguous conditions where wired sensors are not cost effective. Wireless sensor nodes are deployed along the designated road segment sensing traffic flow physical condition and extract corresponding data [1]. e physical condition represents the ambient Earth's magnetic field [2]. Each node operates autonomously to extract and transmit the traffic flow data to the traffic management center [3]. Due to the sensor's limited onboard resources, energy consumption trade-offs remain a significant concern for wireless sensor network designers.
Magnet WSNs for traffic flow monitoring utilize magnetic sensors that capture the ambient Earth's magnetic fields distorted by the passing vehicles [4,5]. e programmed signal-processing algorithm processes the distorted signal to obtain the desired data. e trade-off between the signal-processing algorithm, operation duration, and the node's total available energy is necessary [6]. e energy trade-off in traffic flow monitoring and sensor nodes is necessary since it has to operate continuously generating the traffic flow data for a road segment at all times [7]. e traffic flow data of interest include vehicular count, speed, type, and TTI.
Scanning and Decision Algorithm II (SDA-II) is a signalprocessing algorithm improvement of the SDA algorithm [4]. e new algorithm is based on a moving-average model operating in the time domain. It improves the signal conditioning and scanning by adding a two-pass moving-average filter, which eliminates high-frequency noises and smoothens and thus enhances the fidelity of the captured signal. In congested and slow-moving traffic, the proposed algorithm improves the process of separating distortions caused by the nearest vehicles. erefore, the addition of moving-average filters boosts and filters high-frequency noises of the input signal and hence smoothens the signal that simplifies the scanning and decision to generate required data.

Features of Related Work
In SDA, the algorithm lacked filters for eliminating highfrequency noises of the input signal. e said noise may become severe and cause errors in vehicular detection. e model validation performance on the simulation platform generated promising results. However, it underperformed in the real-time experiment. e algorithm used three magnetic sensors in three directions of x, y, and z to capture ambient Earth's magnetic fields in their respective directions. is research found that two directions are enough for the extraction of desired traffic flow data; hence, the energy consumption is minimized. e additional data outputs of the vehicular count, speed, type, direction, and TTI are desired to be extracted from the nodes. Table 1 compares some different parameters between SDA-I and SDA-II models.

Proposed Improvement of Novel Algorithm
e SDA-II algorithm shown in Figure 1, which is an improvement of the SDA, composes three essential parts. First, the conditioning state captures incoming analog signals, is amplified up to 500 times, converts to a 16-bit sigma-delta digital, removes high-frequency distortions, and smoothens the signal using a moving-average filter 1 (MAF-1) [8]. Second, the scanning state uses different equations to extract error signals, calculates energy signal, smoothens the energy signal using a moving-average filter 2 (MAF-2), scans for vehicular detection, and finds its highest energy level that depicts the signature.
ird, the decision state contains decision-making blocks that extract vehicular traffic flow data from the filtered signals. e proposed algorithm deploys two magnetic sensors in x and y directions [9,10]. e general orientation of the sensor is for a y-direction oriented parallel to the road segment and x direction oriented perpendicularly to the road. e subsequent sections discuss the building blocks within the model.

Signal Conditioning.
e input signals B x (t) and B y (t) of Earth's magnetic field are significantly weak. erefore, they are conditioned to give digital signals x[n] and y [n]. e 16-bit resolution digital sequences have rich data content, which enables better performance in subsequent processes.

Moving-Average Filter-1.
e digital sequence passes through the first moving-average filter (MAF-1). e filter removes high-frequency noise due to the Earth's magnetic field spike storms and smoothens the signals. e filter coefficients are calculated so as to avoid truncation harmonics caused by small moving vehicles. e filters carry out a significant role in separating the harmonics when a congested traffic flow occurs. e moving-average filter mathematical formulas are given by where x[n] and y[n] are the filtered current sensor readings in x and y directions, x[n − 1] and y[n − k] are the delayed sensor readings, b k is the filter coefficient, and L is a filter length.

Difference Equation.
e difference equation (Diff − Eqn) calculates the error signal from Earth's magnetic signal edges. e Earth's magnetic field is a complicated nonlinear signal with a fundamental frequency of 7.83 Hz [11] where its form changes over time due to different factors such as temperature drifts and magnetic storms.
e difference equation separates the incoming signal from the previously delayed signal resulting in error signals e x [n] and e y [n] in equations (3) and (4), respectively. e error signals indicate how the magnetic field strength changes in the time domain. e smaller the error, the better the quality of the model parameters. When vehicles are passing near the sensor node, they influence the error signals causing distortions:

Energy
Signal. e energy signal E y [n] represents the changes in the energy level of the error signal e y [n] and, hence, the overall changes in the captured signal. e characteristic changes in energy have an impact on the determination of vehicular detection. It is employed as a measure of the quality of estimation. e smaller the E y [n], the better the estimation. Notice that, in SDA-II, only one E y [n] in the y-direction is involved and calculated as shown in equation (5).
e calculated E y [n] is efficient for the vehicular detection algorithm: In the signal analysis, E y [n] is used to deduce vehicular detection and classification after passing through the second moving-average filter MAF-2 [12]. e analysis is then performed in the time domain because of the lower processor power demand and sensor node energy consumption [13]. When two or three vehicles at the instant are moving parallel to the sensor node, the false alarm detection happened. is effect is minimized when the multisensor nodes are deployed along the road link. e average of each traffic parameter is then calculated based on data from each node.

Moving-Average Filter-2.
e essential function of this second pass filter (MAF-2) is to recondition and smoothen the E y [n] generating the best-approximated signal for analysis. e MAF-2 formulation is shown by where E y [n] is the filtered current energy signal, E y [n − 1] is the delayed energy signal, b k is the filter coefficient, and L is the filter length.

Vehicle Detection and Maximum Energy.
Based on the vehicle energy signal, equation (7) calculates vehicular detection: where E y is the filtered energy signal and B TH is the fixed baseline threshold. e value of B TH is fixed and obtained from repeated physical experiment observations. e experiments showed that the energy of the error signal E y was typically less than B TH unless there are distortions due to the nearby magnetic or metallic object. e Earth's magnetic spike storms cause distortions that may exceed B TH but most of them occur in a very short time; therefore, they are not encountered as desired vehicular distortions. e SDA-II sampling is more than 2 MHz; therefore, the error signal would become very small if no detection occurred. Hence, the B TH fixed at 1 nT 2 controls the detection mechanism. Once the vehicle detected, the vehicular count block increases its value [14].
Maximum energy E y Max in equation (8) represents the highest energy level attained by a passing vehicle. In this study, it is used to indicate the vehicular type: where max Energy is the function used to mark the maximum energy magnitude of a passing vehicle.

Instantaneous Speed and Travel Time Index.
To calculate speed, it is assumed that the sensor observability zone length (L in meter) is constant and proportional to the vehicular size [15] when a vehicle travels across the sensor observability zone length and spends time (TT in mill-sec). erefore, the vehicular speed across the observability length is given by As ⟶ 0, we take the derivative on both sides, resulting in an instantaneous speed of the passing vehicle: where v(t) is the instantaneous speed, dL changes in distance, and dTT changes in time. e travel time index TTI is the ratio between the actual travelled time (TT) to the travel time at free-flow speed t ff . Alternatively, TTI is the ratio between the free-flow speeds to the actual vehicular speed as in equation (11), accounting for both recurring and incident delays such as traffic accidents. It determines how long it will take to travel during a peak hour and uses both main and arterial travel rates: where TT is the actual travelled time and t ff is the travel time at free-flow speed v ff .  Figure 2. A vehicle is passing near the sensor node at an average speed. Four main factors that influence the vehicular magnetic signal include (i) Vehicle position from the sensor node (ii) Temperature drifts (iii) Geographical location (iv) Magnetic spike storms e MAF-1 suppresses small harmonics and leaves high harmonics.

Reset Anisotropic Magnetoresistors (AMRs).
e Reset AMR block sets/resets the AMR sensor by a 1 kHz pulse just after detection is completed. e pulse recovers the sensor strongly remagnetized . e Earth's magnetic variations due to temperature drifts have lesser magnitude; hence, they are neglected. Variations due to sensor location away from the vehicle receive an enormous impact on the captured magnetic field; therefore, they are considered as an area for further research. is research considers vehicles travelling in the closest lane to the sensor node location. Filters help to eliminate the problem due to minute magnetic variations. erefore, this block demagnetized the AMR sensor and is reenabled to perform high sensitivity measurement Decision_00: no vehicular detected Decision_01: vehicular just detected Decision_11: vehicular detection is active Decision_10: vehicle at the end of the detection At Decision_10, the algorithm generates data outputs (TTI, type, and count) and initializes timer and a magnetic sensor.

Experiment
Data collection to evaluate SDA-II was conducted through on-site real-time experiments at the designated road segment with two wireless sensor nodes and a single sink node (KiliNode). KiliNode is a sensor node designed at the University of Dar es Salaam, integrated with powerful features such as a 16-bit PIC24fj128G006 MCU, a 16-bit Sigma-delta ADC, a 120 nT resolution AMR sensor, a CC2520 transceiver unit, a 0.6 W solar panel, and a 100F supercapacitor [16]. e data outputs were captured in different setups, with/without passing vehicles, at various speeds, and during normal or congested conditions. e vehicular manual count and type identification were used to evaluate the algorithm. Figure 2 shows the experiment setups, where two sensor nodes are localized on the sides of Journal of Electrical and Computer Engineering the road segment communicating wirelessly with a sink node. ey transmit traffic flow information to the sink node (gateway). Figure 2(a) shows a wide-view of sensor nodes, depending on the size of the passing vehicle. Each node sensed its nearest lane. Figure 2(b) shows a close view at the sensor node. Each node is installed 1 m away from the vehicle and 1 m above the ground. Figure 2(c) shows the sensor node hardware based on KiliNode and Figure 2(d) shows the sink node interfaced to a computer for storing real-time traffic flow data. e sensor nodes transmit traffic flow data wirelessly to the sink node. A small saloon car is used to validate the operation in various scenarios.

Experiment Observation.
ere were various experimental observations on data collected, used to plot the subsequence graphs. Figure 4 depicts Earth's magnetic fields before and after being filtered by a MAF-1 when no vehicle is passing by. e truncation of high frequencies from the filtered signal is evident. Figure 5 depicts Earth's magnetic field energy signal when no vehicle is passing by. e error signal is filtered by MAF-2. No filtered E y [n] greater than the baseline threshold is detected. Figure 6 depicts distorted Earth's magnetic field when a vehicle is passing by. e distorted signal shows that there is a vehicle passing. Figure 7 depicts E y [n] of a passing vehicle. It shows vehicular detection marking its start and end, E y Max, and travel time observed by the sensor node. e anatomy of the graph in Figure 7 illustrates the vehicular signatures that inter and leave the sensor zone. e sensor measured the travelled time TT and the maximum energy level E y Max of the vehicle.

Performance Evaluation of SDA-II
e energy consumption in SDA-II was dramatically minimized by 6-8%. is is achieved by the following two improvements: reduced number of sensing units to two in xy directions and reduced computational activities by implementing lightweight moving-average filters. Hence, the sensor node operation depends on energy harvesting. Magnetic field sensitivity increased due to the introduction of the set/reset magnetic sensor. e introduction of

Conclusion
is research proposes a novel vehicular traffic flow algorithm (SDA-II) based on magnetic WSNs. e work validated the vehicular detection by magnetic wireless sensor nodes installed on the roadside. e validation was performed by various real-time experiments. e proposed signal-processing algorithm captured the input signal and processed and generated vehicular traffic flow data. e novel algorithm is based on the time-domain moving-average model. Moving-average filters improved the SDA-II operations, especially during the low congested conditions. e research suggested that future work should be carried out in the frequency domain at the expense of high processing power and energy requirements. In general, when the vehicle is moving along the road, it disturbs the ambient Earth's magnetic field and its characteristic frequency resulting in frequency distortions. e frequency-domain analysis assumed to clearly show the distorted frequencies and power spectrum, which corresponds to the vehicular type. Frequency-domain analysis has additional advantages over time-domain analysis, due to the constraints such as processing power, huge memory, and digital signal processor requirement. erefore, it is considered for further research.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare that they have no conflicts of interest. Journal of Electrical and Computer Engineering 7