Keywords

1 Introduction

With the rapid development of urbanization, the number of vehicles increases every year, causing difficulties in parking and increasing road congestion. As a core component of intelligent traffic, parking guidance system can provide real-time urban parking information, improve parking utilization rate of parking facilities, and solve urban parking difficulties, which has become a hot and difficult point in recent years.

Parking information acquisition plays an important role in a parking guidance system. The common parking detectors make use of induction coil, ultrasonic, infrared, and video detection [1, 2], but they are difficult in installation and maintenance, expensive and easy to be affected by the environmental factors such as wind, rain, snow, or fog. Magnetoresistive sensor has been proposed for vehicle detection because it is quite sensitive, small, and more immune to environment [3]. Many research works have been carried out to improve the detection accuracy [4, 5].

LoRa is the representative radio technology in the Low-Power Wide Area Network (LPWAN), and it used narrow bandwidth and spread spectrum modulation to support various Internet of Things (IoT) services with the aim of providing low cost and scalability.

This paper presents the design and implementation of a set of parking information acquisition system based on LoRa wireless network and geomagnetic sensor technology. The specific purposes of this study are to (1) describe the core hardware and software design of the acquisition system and illustrate its working, (2) propose the algorithm for output signal processing and vehicle states recognition, and (3) validate the approach with actual experiments.

The remainder of this paper is organized as follows: Sect. 2 describes the overall system architecture, including the parking space detection system composition and the operating principle. Sections 3 and 4 introduce the implementation of a prototype system in hardware and software development. Section 5 conducts an experiment to evaluate the system and present the results with a discussion. Section 6 makes a brief conclusion.

2 Principle and System Architecture

The mathematical model to describe the magnetic signature of a vehicle is a magnetic point dipole [6], with a magnetic moment \( {\text{M}} \) centered in the vehicle and parallel to the Earth’s field.

$$ {\text{B}} = \frac{{\mu_{0} }}{{4\uppi\,d^{5} }}\left[ {3\left( {{\text{M}} \cdot {\text{d}}} \right){\text{d}} - d^{2} {\text{M}}} \right], $$
(1)

where \( \mu \) is the permeability of free space and \( {\text{d}} \) is the distance from the dipole to the observation point.

Figure 1 shows working principle of the magnetic sensor. In order to obtaining the changes in the magnetic field, the sensor decomposes the Earth’s magnetic field and outputs individual components over the x-, y-, and z-axes relative to the local coordinate frame of a compass.

Fig. 1
figure 1

Working principle of the magnetic sensor

The field components \( B_{ix} \), \(B_{iy} \), \( B_{iz} \) produced by \( {\text{M}} \) are

$$ \left\{ {\begin{array}{*{20}c} {B_{ix} = \frac{{\mu_{0} }}{{4\uppi}} \frac{{M_{x} \left( {2x^{2} - y^{2} - z^{2} } \right) + 3M_{y} xy + 3M_{z} xz}}{{d^{5} }}} \\ {B_{iy} = \frac{{\mu_{0} }}{{4\uppi}} \frac{{3M_{x} xy + 3M_{y} \left( {2y^{2} - x^{2} - z^{2} } \right) + 3M_{z} yz}}{{d^{5} }}} \\ {B_{iz} = \frac{{\mu_{0} }}{{4\uppi}} \frac{{3M_{x} xz + 3M_{y} yz + 3M_{z} \left( {2z^{2} - x^{2} - y^{2} } \right)}}{{d^{5} }}} \\ \end{array} } \right. , $$

where \( \mu_{0} = \mu \) (when in the air), \( M_{x} \), \( M_{y} \), and \( M_{z} \) are the magnetic dipole moments in x-, y-, and z-directions, respectively, and \( d = \sqrt {x^{2} + y^{2} + z^{2} } \).

The large amount of ferrous materials in a car body means that changes in the magnetic field are easily affected by vehicle entering or leaving, but also by nearby cars. A magnetic sensor close or below a vehicle will detect this change in the Earth’s magnetic field. \( Because\,\, changes\, of\;B_{iz} \) is behind \( B_{ix} \) and \( B_{iy} \), a magnetic z-axis sensor can sense the vertical component and detect its change when a vehicle passes or is parked over the sensor.

The proposed parking information acquisition system is shown in Fig. 2, which is composed of the geomagnetic sensors, LoRa gateways, and cloud server.

Fig. 2
figure 2

System composition diagram

The geomagnetic sensor is designed to detect the real-time intensity of the parking space magnetic field and to periodically acquire the signals of X, Y, and Z-axes of the variation in the geomagnetic field and to data process for recognition of vehicle states, including signal filtering and geomagnetic baseline correction. It is installed under the road parking space. LoRa gateway receives the parking information from the geomagnetic sensors and transmits cloud server to analyze and display the relevant information.

3 Implementation of Hardware

3.1 LoRa End Node Hardware Design

Parking data acquisition, analysis, and transmission process are working based on the hardware components. Figure 3 shows the parking information acquisition hardware structure design, which is composed of AMR sensor, micro control processor unit, battery supply, and a LoRa data communication module.

Fig. 3
figure 3

Parking information acquisition hardware structure design

Geomagnetic sensor HMC5983L and HMC5983R can detect the presence of vehicle and analyze the state of vehicles that is passing or parking. The detection mode of two sensors greatly enriches the variation information of geomagnetic field extracted.

When a vehicle passes, disturbances will be generated on the Earth’s magnetic field around it. HMC5983 sends the geomagnetic data to STM32L MCU, after smart algorithm processing and judgment, MCU transmits parking state data to SX1278 LoRa module.

The Honeywell HMC5983 is a temperature compensation three-axis integrated circuit magnetometer. Anisotropic Magnetoresistive (AMR) technology is the symbol of this chip. It contains a 12-bit ADC that enables 1° to 2° compass heading accuracy, and can achieve the resolution with 5 m Gauss in the magnetic field of ±8 Gauss. The IIC or SPI serial bus allows for easy interface. These characteristics enable it to be of low cost and with extreme sensitivity.

STM32 is an ARM cortex-M3 kernel specially designed for high-performance, ultra-low-power, and low-cost embedded applications. It has abundant internal resources and standard interface. In this design, STM32L151 is adopted to collect data of geomagnetic sensor in real time and judge the states of parking space.

3.2 Gateway Hardware Design

Figure 4 shows the gateway hardware design. The LoRa gateway uses a SIM900A General Packet Radio Service (GPRS) module as a communication device to transmit parking space data. GPRS is a packet-oriented mobile data service used in 2G and 3G cellular communication systems global system for mobile communications.

Fig. 4
figure 4

Gateway hardware design

The ARM Cortex-M4-based STM32F407 MCU series leverages ST’s NVM technology and ART Accelerator to reach the industry’s highest benchmark scores for Cortex-M-based microcontrollers with up to 225 DMIPS/608 CoreMark executing from flash memory at up to 180 MHz operating frequency.

4 Implementation of Software

4.1 Signal Filtering

The core of the vehicle detection algorithm is to extract effective vehicle information from the collected three-axial magnetometer sensor signals. Owing to the interference of high-frequency signals, it is necessary to filter and denoise before analyzing it. The sliding average filter has a good inhibiting effect on high-frequency interference and is highly smooth and easy to handle, this method is adopted in this paper to preprocess the signal. The calculation of the sliding average filtering is as follows:

$$ m_{i} \left( k \right) = \left\{ {\begin{array}{*{20}l} {\frac{{m\left( k \right) + m\left( {k - 1} \right) + \cdots + m\left( 1 \right)}}{k} } \hfill & {(k < N)} \hfill \\ {\frac{{m\left( k \right) + m\left( {k - 1} \right) + \cdots + m\left( {k - N + 1} \right)}}{N}} \hfill & { \left( {k \ge N} \right)} \hfill \\ \end{array} } \right., $$
(3)

where \( {\text{m}}\left( {\text{k}} \right) \) is the signal collected by the magnetoresistive sensor, and \( {\text{m}}_{\text{i}} \left( {\text{k}} \right) \) is the signal after sliding average filtering, and \( {\text{N}} \) is the window length of the sliding average filter.

4.2 Geomagnetic Baseline Correction

The Earth’s magnetic field varies with location and over time. Also, the change of temperature and the traffic of surrounding vehicles can have an effect on the geomagnetic signals. Therefore, baseline tracking must be carried out on the basis of sliding filtering to adapt to the changing baseline values. The main design idea of baseline tracking is to update the baseline values when there is no parking, while the baseline values are consistent with the previous state when there is a large disturbance.

The baseline adaptive update is achieved by the following weighting function:

$$ m_{base} \left( k \right) = \left\{ {\begin{array}{*{20}l} {m_{base} \left( {k - 1} \right) \times \alpha + m_{i} \left( k \right) \times \left( {1 - \alpha } \right)} \hfill & {\left( {No \,parking} \right)} \hfill \\ {m_{base} \left( {k - 1} \right) } \hfill & {\left( {Occupation} \right)} \hfill \\ \end{array} } \right., $$
(4)

where \( {\text{m}}_{\text{base}} \left( {\text{k}} \right) \) is the baseline value, \( \upalpha \) is the weighting coefficient, and \( {\text{m}}_{\text{i}} \left( {\text{k}} \right) \) is a filtered magnetic signal.

Obviously, the larger the weighting coefficient \( \upalpha \), the larger the baseline adjustment amplitude, and the faster the tracking speed. After repeated experiments, the weighting coefficient is equal to 0.05, and has good effect on baseline tracking.

4.3 LoRa Communication Protocol Design

The geomagnetic sensor node encapsulates the transmitted content into frames according to a certain format and sends it to the LoRa gateway. After that, the LoRa gateway analyzes the received data package according to the frame format and delivers it to GPRS by TCP/IP protocol.

LoRa frame format is shown in Table 1. The geomagnetic sensor uses a 20-byte frame to send information. Because every LoRa module is assigned a unique address and has 32 alternative channels, the destination address is assigned 15 bytes and the destination channel is assigned 1 byte. Forward Error Correction (FEC) is redundant information, which can enhance LoRa communication anti-interference ability.

Table 1 LoRa frame format

The frame load is the effective information to be transmitted, which is composed of the parking number and the parking status. The parking number uses the address of LoRa module itself and the parking status value in 0/1 means “Vacant” or “Occupation”.

In addition, since the entire LoRa network uses the same channel, multiple terminal nodes send data to LoRa gateway at the same time, resulting in data conflict. To avoid this situation, the sending/reply mechanism is adopted. That is to say, after receiving valid information, the gateway replies to the end node. If the end node does not receive the reply frame, it will randomly delay a period of time to send again until the transmission is successful.

4.4 Software Workflow of End Nodes

The magnetic sensor is controlled by stm32L microcomputer to measure the magnetic field. To keep the real-time detection and transmission, optimize the control workflow including data collecting, information processing, and data communication is required.

As shown in Fig. 5, the sleep–wake–sleep programming model makes the power consumption minimum. When the time slice is out, end nodes start geomagnetic acquisition and compare the sampling value with the baseline value signal. Once the difference exceeds the specified threshold value, the final judgment is made and the parking state data will be uploaded to the LoRa gateway. Otherwise, the end nodes continue sleeping until the next wake. (In this design, the time slice is set to 1 s.)

Fig. 5
figure 5

Time-slice-based algorithm to detect vehicle presence or absence

4.5 Software Workflow of Gateway

The gateway node runs the free RTOS operating system, which realizes the simultaneous execution of multiple tasks and ensures the long-term stable operation of the system. The workflow of gateway is shown in the following steps:

  • Step 1 System initialize when device powered on.

  • Step 2 Program come into RTOS process to create four tasks, which aim to receive and parsing the LoRa data package, upload data regularly in intervals, and wait to reply data request timely.

  • Step 3 Each task runs perpetually under the workflow logic control.

The task 4 is responsible for receives and parses the LoRa end nodes data package. Its code fragment is as shown below. LoRa module is initialized to RX mode. After then, the task goes into an endless loop.

figure a

4.6 Data Analysis

The system adopts Ali cloud server, which runs a socket monitor program to receive the data uploaded by GPRS and store it in the database.

The cloud server abstracts the packet forwarder UDP protocol running on LoRa gateways into JSON over MQTT. As is shown in Fig. 6, the information of the database has been presented in hexadecimal notation after the decoding of base64. It contains International Mobile Equipment Identity (IMEI), parking state data, current time, etc.

Fig. 6
figure 6

The information of the database

5 Experiment and Discussion

As shown in Fig. 7, a prototype system of parking space state information acquisition end node was designed and developed. The magnetic sensor is installed on the ground of parking space.

Fig. 7
figure 7

Prototype system

Table 2 is the data set sampled at free parking spaces and Table 3 is the data set sampled at occupied parking spaces.

Table 2 Data set sampled at free parking spaces
Table 3 Data set sampled at occupied parking spaces

It can be seen from the data in the table that when there is a car or no car in a parking space, the reading changes of X-axis and Y-axis are not particularly obvious, but the reading changes of Z-axis. It is only necessary to judge whether there is a car in a parking space based on the data of Z-axis.

6 Conclusion

In order to solve the questions of parking difficulties and improve urban traffic intelligence, an intelligent parking space states information acquisition system based on LoRa network and geomagnetic sensors are designed which are integrated with a variety of GPRS, Lora WAN, and Embedded system technologies. The actual installation test results show that the system has high detection accuracy and reliability. The system has a very important practical significance.