Informatica 38 (2014) 223-227 223 Tiny Low-Power WSN Node for the Vehicle Detection Michal Chovanec, Michal Hodon and Lukas Cechovic University of Zilina Univerzitna 8215/1, 010 26 Zilina, Slovakia E-mail: michal.chovanec@fri.uniza.sk, michal.hodon@fri.uniza.sk, lukas.cechovic@fri.uniza.sk Keywords: wsn, node, low-power, msp-430, TDMA, magnetometer, open-source, gcc Received: November 20, 2013 In this paper, a tiny low-power wireless sensor network (WSN) node based on msp430 microcontroller is introduced. The node should be serving the needs of a special WSN used for traffic monitoring, or more precisely for the indication of vehicle's presence. The single vehicle detection is based on the utilization of magnetometer sensor, where the change of Earth's magnetic field, caused by the movement of passing vehicle, is measured. Communication subsystem of the node is based on the low-power sub-GHz transceiver cc1101 implemented together with the special, energy-efficient communication protocol in 868 MHz ISM band. In line with low-power architecture, environment friendly power consumption of the node was reached. It is equal on average to 300uA, when transmitting period is 1s and magnetometer data collection rate is equal to 20Hz. Povzetek: Opisan je novi senzor oz. senzorsko omrežje za zaznavanje prometa. 1 Introduction Traffic monitoring becomes very important with the growing number of registered motor vehicles. Based on [1], there are more than 250 million vehicles on the European roads and this number tends to increase. The higher this number is, the higher is the probability of accidents on the roads. Therefore, in modern society, both traffic monitoring systems that monitor different road networks and intersections, as well as other intelligent transportation systems (ITS) are implemented. These systems substitute the role of humans. Conventional methods utilized for the vehicle's detection are based on the use of video cameras or magnetic loops in roadway [2]. In [2], where these methods are described in detail, it is also pointed that disadvantages of these methods are not inconsiderable. Beside the fact that the camera systems are very expensive and the magnetic loops require roadway cut, both methods require external power supply because of their high power consumption. In [3], other disadvantages of such systems are depicted, from the ineffectiveness of magnetic-loops or camera-based solutions, up to uncertainties brought along with the new technologies, such as magnetometers or microradars. Moreover, if such systems are utilized for traffic data collecting on local roads, the costs connected with their installation are quite significant though dependant on the type of installation, either portable which offers short-duration counts (up to 48 hrs) or permanent which could work up to one year [4]. In this case, the cheapest solutions are the portable ones, though their acquisition costs are still high. According to [5], if the sensors are utilized for the traffic volume, vehicle's length and average speed classifications, video- and radar-based solutions provide the lowest average percentage errors. However, as it was already mentioned in [2], these solutions are quite energy demanding and thus not suitable for long-time measurements. It could be assumed that the special low-power variations of these technologies could bring the desired performance. Therefore, with respect to [6], other technologies come to the forefront allowing utilisation of such systems even at places without electricity. One of this low-power methods for correct vehicle detection is based on the utilization the Earth magnetic field disturbance [7]. As it was outlined in [7], a tiny three-axis magnetometer can be used for this purpose. With regards to [5], if only traffic volume is measured, magnetometric error-rate is really similar to the classification errors of other technologies. And since the magnetometric measures are really power-friendly, application of this technology for the purposes of the traffic volume monitoring, even at places without electricity, could be feasible. This assumption was successfully verified in [8] as well, where a kind of magnetometer-based vehicle classification method was introduced. Therefore, upon the findings mentioned, as well as with considerations of [9], the prototype of a special low-power sensor node was developed embedding magnetometer as the main sensing tool for the vehicle's presence monitoring. The node is a part of a special wireless sensor network (WSN), which was partly described in [10]. The WSN is based on the multihop principle, using multiple places for sensing and broadcasting information about vehicle's presence to the server station. This approach was chosen because of the high power efficiency as well as low computational requirements of the sensor nodes. In order to minimize the power consumption and maximize operat- 224 Informatica 38 (2014) 223-227 M. Chovanec et al. ing range of the network during communication, sub-GHz 868MHz ISM band was used as the communication frequency of the WSN protocol [11]. 2 Node hardware WSN network consists of several nodes communicating on 868MHz free ISM band. As a communication unit, a low-power sub-1 GHz RF transceiver TICC1101 unit was used. Power consumption of the receiver and the transmitter in operating mode is ca. 16 - 20mA, however when all clocks are stopped and the module is in the sleep mode, the power consumption is 0.7uA. As a main control unit, we used ultra-low power 16bit microcontroller (MCU) TI MSP430F2232 (16MHz, 8kB Flash, 512B RAM) with power consumption about 270uA@1 MHz in active mode, about 30uA when just ACLK is active (1024Hz), and 0.1uA in LPM4 mode where all clocks are stopped [12]. For the purposes of magnetic field detection, three-axis digital low power magnetometer (MAG) MAG3110 from Freescale was used. It is measuring the three components of the local magnetic field. All the mentioned modules comprise the main parts of the developed sensor node. A summary of the power consumption of all the node parts is provided in the table below. Device Active Mode Low-power [uA] Mode [uA] MSP430f2232 270 30 CC1101 16400-tx 18400-rx 0.7 MAG3110 137.5 @10Hz rate 2 Table 1: Node parts - power consumption The node has been designed so that the board space and power consumption were as small as possible (Figure 1). Keeping the node compactness, the device can be powered from a single cell Li-Pol battery, which has @ 1000mAh capacity and also relatively small dimensions. Considering the node design, MAG module was placed as far as possible from the transceiver so that the noise brought along with the magnetic field sensing could be reduced. MAG communicates with MCU via I2C bus @ 100kHz clock rate. It can trigger the data-ready interrupt, which can be used for the MCU waking up. For correct working MAG needs only three ceramic external capacitors. For correct functioning, the transceiver needs an output LC filter as well as a balun circuit for unbalanced Whip antenna. Additional band stop filter may be added to build an optional filter to reduce emission at 699MHz. For precise frequency synthesis the integration of 27MHz crystal is necessary. Figure 1: 3D model of the node MCU was in this application clocked on 1MHz. For the debugging purposes, two led diodes and the UART interface were hooked up. The hardware of the node is shown in the figure below. Figure 2: HW of the developed node - communication testing 3 Firmware The control software of the node manages the magnetometer data reading as well as single packet transmitting/receiving tasks. When we write this as an infinite while(1) { } loop, the power consumption will be noticeably high, since everything will be done in power-on mode. By this approach we also can not ensure the real-time processing of asynchronous incoming packets. The solution is to write the software as an event-driven, when the crucial tasks of the program are determined by the events. Nowadays microcontrollers have refined an event-driven support within the interrupts. Therefore, the firmware of the node Tiny Low-Power WSN Node for the Vehicle Detection Informatica 38 (2014) 223-227 225 was based on the implementation of the timer interrupts assuring execution of a certain event at a given frequency in the defined time intervals. This approach allows the nodes to fall into the sleep mode and hence save the energy considerably. The firmware was then implemented as follows: after MCU's GPIO initialisation, timer_0 was set to 1024Hz periodic interrupt. The frequency was divided from an external 32.768kHz crystal which was configured as ACLK clock. When the timer triggers, MCU reads magnetometer control registers and increments the software counter. When magnetometer control register sets the data ready, the data are read through I2C bus into the digital filter. The software counter counts from 0 to 1023 with the 1s time interval of one loop. There are few important time moments within the loop: 1023 - MCU wakes up the radio to receive; 0 - MCU waits for an incoming packet; 1 - power down radio; 16 - MCU wakes up the radio and trasmits the packet; other - in the other time slots MCU sleeps; The end of packet reception or transmission is reported via GPIO interrupt. MCU then does not need to poll and synchronously read CC1101 registers. Thus, the sleep time of nodes can be maximized. Moreover, due to the preservation of enough space for the received packet processing in the time slot 0, the packet transmitting was defined to be done each time in the 16th time slot. Thanks to this, every node knows when to ask for a data. 3.1 The synchronization of the nodes Since the system is functioning on an event-driven principle utilizing the triggering from the timer interrupt, TDMA method (Time Division Multiple Access) was used as the channel access method of WSN. As it was already mentioned, one program time loop takes 1 second and it is divided into 1024 time slots. Every time slot has then unambiguously defined specific task which should be done according to the implemented crystal frequency. In order to ensure the proper functioning of every node within the network, all nodes have to be synchronized so that they transmit/receive the data only when the neighbouring nodes are awaken. Therefore, in the network, there is always one master node, which is always synchronized with itself, and which is periodically sending packet to its antenna, so that other nodes could synchronize according to it. The address of the master node was set to 0x01. All other "slave" network nodes synchronize according to the previous node synchronization packet with the address node_adr-1. This means that the master node synchronizes the most close node, which synchronizes the following one, etc. When the synchronization packet is received, after the packet receiving is done, software counter of each node sets the time slot to 1. Next, in the time slot 16, it transmits the node synchronization packet to the next nodes. This approach allows the implementation of the master/slave tree network architecture. In our application a "string" network architecture was however used. This architecture implies placement of all nodes in one logical subnet, where the current node synchronizes only next node. Within this structure, the data from master can be shifted to the last node in the string. Network depth is in this case limited by clock precision, and receiving timewindow width. 3.2 Data filtering Whilst the sensors are planned to be deployed in a rush, noisy environment of traffic roads, the magnetometer data output needs to be filtered. In the vehicle-detecting application, only fast magnetic field changes just within X and Y axis have to be monitored. To prevent slow magnetic field fluctuations, sensor moving, or parameters floating in time, the long term magnetic field process has to be recorded. This can be done by using a low pass filter with a very long response time, e.g. 0.5 .. 2 seconds. For Z coordinate, a simple filter can be a written as Y (z) a(1 — z-1)X(z) 1 — az -l (1) where a is time constant in range (0, 1), X(z) is a filter input and Y(z) filter output. For field change, derivation (difference in discrete domain) can be used. After rewriting into time domain we have y(t) = ay(t) + a(x(t) — x(t — 1)) (2) We can see that slow changing signal will be zeroed, but fast signal change will produce high output amplitude for signal change duration, or low pass filter response time. The final output from N axis will be produced as: N m(t) = J2 iy(t)ii (3) where y(t) is a vector result from all three filtered axis of magnetometer. Vehicle presence is in this case defined as the threshold m(t) with a constant value. From the equations above it is obvious that the utilized filter is really simple, almost trivial. This approach was chosen because of the minimisation of the computational power of a node that is necessary for the signal preprocessing. Correctness of the filter was investigated in a set of measurements, where the straight movement of a common vehicle (in our case Skoda Octavia 1.9TDi) was monitored (Figure 3). The sensor was placed with the X-axis set in parallel according to the vehicle's movement, so the highest signal-change should be observed within the Y axis of the sensor, which was placed orthogonally. The vehicle then performed three two-way rides forward and backward (six in 224 Informatica 38 (2014) 223-227 M. Chovanec et al. Figure 3: Evaluation of the filter functioning Figure 5: Filtered result total), at constant speed ca. 20km/h along with the sensor. The drives were distanced stepwise 0.5m, 1m, 3.5m from the sensor. In the figures below, the output filter results of magnetometer car detection with a = 0.9 and 20Hz sampling frequency are depicted. The superposed DC value on all three axis - Earth magnetic field - can be observed too. The sensor node is used for the single vehicle detection, so its proper placement is the most critical task. As shown in test measurements @20km/h vehicle speed, magnetometer detection works well at the distance 1m. Therefore, it could be assumed that by its installation on the edge of the road, full coverage of one road traffic line could be assured. Retransmitting nodes work just like repeaters since they only re-send the received message to the next node. As it was shown in [10], nodes are synchronized and wake up only for a short time. When a node receives a message from another neighbour, it just modifies the packet destination address by its incrementing by one and resends the packet further. Because the linear network structure is applied, each node abut on two neighbours. The signal node is utilized for the signalling purposes to inform/warn other traffic participants about the presence of the vehicle. It can be implemented either as the LED road sign [10], or as the server/data-logger when sending the data into computer via UART interface. In this case, integration of UART to USB converter is mandatory. 4 Conclusion Figure 4: Magnetometer output 3.3 System architecture In the final implementation, there are three node types [10]: 1 Sensor node, 2 Retransmitting node, 3 Signal node. All three node types have the same hardware, they differ only by the firmware implemented within the main control unit. The tiny node for a vehicle presence detection, described in this study, represents a good solution for the data collection at the places without mains power. The main advantages of this solution are: low power consumption, tiny dimensions as well as a simple communication protocol. Small modification of the node, reached by the integration of other different sensing units, such as accelerometer or sensors for measuring temperature, humidity, pressure, etc., within the node's layout, allows the mutuation of its functioning according to the direct needs of the WSN. Therefore, apart from the transportation domain, it could be applied also within different other application domains, such as rails vibrations monitoring, building temperature/humidity sensing, shopping center's traffic monitoring, etc. However, the developed prototype has also some defi- Tiny Low-Power WSN Node for the Vehicle Detection Informatica 38 (2014) 223-227 225 ciencies. As far as the node layout is concerned, the node needs two crystals and many LC components for proper functioning. Utilization of an external antenna is also not an ideal solution, especially from the final price of the product viewpoint. Integrated PCB or ceramic antenna will be in this case better. Also, even though the software is written so as to minimize the time delay, its hardware dependency is still too high. Therefore, in the next releases the firmware will be rewritten more modularly. For the massive production, the best solution is to implement the node control unit within ASIC or FPGA integrated circuits, whilst the sensor signal processing can be implemented more effectively by using logic gates and parallel processing [13]. The ratio between computing power and power consumption will increase then. Utilization of alternative power sources, as these described in[14] or [15] is in this case worth considering. 5 Acknowledgement This publication was supported within the project Centre of excellence for systems and services of intelligent transport II. ITMS 26220120050 supported by the Research & Development Operational Programme funded by the ERDF. "Podporujeme vyskumné aktivity na Slovensku/Projekt je spolufinancovany zo zdrojov EÚ" References [1] ANFAC (Spanish Automobile Association) Latest Report on motor vehicles in use in Europe, 2010 Edition. [2] Ashish Dhar (2008) Traffic and Road Condition Monitoring System, M.Tech.Stage 1 Report, Roll No: 07305041. [3] Greg Davies Scottsdale Transportation Commission Report - Bicycle Signal Detection, Transportation Commission, July 18, 2013. [4] Transportation Research Synthesis Collecting and Managing Traffic Data on Local Roads, TRS 1207, Minesota Department of Transportation, September 2012. [6] Lawrence A. Klein, Milton K. Mills, David R.P. Gibson Traffic Detector Handbook, Third Edition—Volume I, Publication No. FHWA-HRT-06-108, October 2006. [7] Juraj Micek, Michal Hodon (2013) Wireless Sensor Networks for Intelligent Transportation Systems, IEEE CommSoft newsletter, No.2, 2013. [8] Ondrej Karpis Sensor for vehicles classification, Fed-CSIS: proceedings of the Federated conference on computer science and information systems: September 9-12, 2012, Wroclaw, Poland, IEEE, ISBN 97883-60810-51-4, pp. 785-789. [9] Dan Middleton, Hassan Charara, Ryan Longmire Alternative Vehicle Detection Technologies for Traffic Signal Systems: Technical Rreport, FHWA/TX-09/0-5845-1, Texas Transportation Institute, February 2009. [10] Michal Hodon, Michal Chovanec, Martin Hyben Intelligent traffic-safety mirror,In: Studia informatica universalis, ISSN 1621-7545, Vol. 11, no. 1, 2013, pp. 87 -101. [11] Mitko Tanevski, Alexis Boegli and Pierre-Andre Farine (2012) Firmware for Ensuring Realtime Radio Regulations Compliance in WSN, 7th IEEE International Workshop on Practical Issues in Building Sensor Network Applications - SenseApp 2012, Clearwater, Florida, page(s): 917 - 920, print ISBN: 9781-4673-2130-3. [12] Texas Instruments MSP430 Ultra-Low-Power Microcontrollers, http://www.ti.com /lit/sg/slab034w/slab034w.pdf. [13] Martin Hyben, Michal Hodon Low-cost command-recognition device, Teleinformatics Review (in press). [14] Michal Kochlan, Peter Sevcik Supercapacitor power unit for an event-driven wireless sensor node, Fed-CSIS: proceedings of the Federated conference on computer science and information systems: September 9-12, 2012, Wroclaw, Poland, IEEE, ISBN 97883-60810-51-4, pp. 791-796. [15] Peter Svcik, Oldrich Kovar Alternative energy sources for WSN node power supply, ITS 2013 = Intelligent transportation systems 2013, August 26-30, 2013,- ISSN 1339-4118, Zilina, ISBN 978-80-5540763-0, CD-ROM, pp. 146-149. [5] Michael Marti, Renae Kuehl, Scott Petersen Traffic Data Collection Improvements, Research Project Final Report 2014RIC51B, Minesota Department of Transportation, February 2014.