Node Detection and Tracking in Smart Cities Based on Internet of Things and Machine Learning

Ramyar A. Teimoor1, Aso Darwesh2

1Department of Computer Science, University of Sulaimani, Sulaymaniyah, Iraq; 2Department of Information Technology, University of Human Development, Sulaymaniyah, Iraq

Corresponding author’s e-mail: Ramyar A. Teimoor, Department of Computer Science, University of Sulaimani, Sulaymaniyah, Iraq. E-mail:
Received: 15-04-2019 Accepted: 14-05-2019 Published: 26-05-2019
DOI: 10.21928/uhdjst.v3n1y2019.pp30-38


It is essential to know that using technologies in an ethical manner will facilitate human life. Hence, internet of things (IoT) which has been used widely due to developments in information and verbal exchange technologies, with some of its most famous applications are used in the fields of identification, transmission, and health care. In those fields, IoT technologies are used to collect data, recognizing the problem, and proposing a solution for it. Exploiting Global Positioning System (GPS) systems seem to solve the development of node location detection systems. However, concerning a specific target, the accuracy and exactitude of GPS are not enough to satisfy the need for specific location-aware applications. Node detection and tracking system aim is to find an autonomous target using radio frequency identification, IoT tag, GPS location, and k-nearest neighbors (KNN) for detecting the actual zone of the target. We also want to find and predict the best pathway that the node needs to go or want to go through, even to create a system for collecting all the information about nodes and saving it in the cloud and then use it for different purposes. Finding and detection the actual zone of our users are done using KNN algorithm. We use 3NN because that model gets a better result in our dataset, for transmission depending on the users’ problem. We are using a new equation to find weights that are integrated with Dijkstra’s algorithm. The equation is to calculate the weight between any two nodes using traffic information and image processing for finding a load of the road by counting the number of vehicles inside the image that is collected from our readers. Dijkstra’s algorithm is used to find the best path between source and destination using weights between nodes. We tested this algorithm on 11,095 samples on a machine with the following properties; central processing unit (CPU): Core i7 – 4600M at 2.90 GHz (4 CPUs), RAM: 10 GB DDR3, and VGA: Intel HD Graphic 4600–2GB. A set of 7745 nodes used as a training set and 3350 as test sets. The accurate prediction was 3324 nodes, and the false ones were 26 nodes. The accuracy of 3NN algorithm with this configuration is 99.224%, in 11.605 s. After this step, detecting nodes’ zone takes only 0.012 s. Using our proposed system, we can detect the actual zone of any user that needs help and track any node that we want. For example, an ambulance in the city and also find the best path for the ambulance or police to travel in from source to destination this idea is used in healthcare but can be used in many other fields such as security, military and information, and communication technologies.

Index Terms: Detection, Global Positioning System, Internet of Things, K-Nearest Neighbors, Location, Node Tracking, Radiofrequency Identification


Internet of Things (IoT) as a system of reticulate computing devices, mechanical and digital machines, objects, animals or those who have area units with given distinctive identifiers (Unique Identification) and therefore the ability to transfer knowledge over a network while not requiring human-to-human or human-to-computer interaction, become more popular in the future and may control everything [1]. The IoT is recognized collectively of the foremost important areas of future technology and is gaining vast attention from a large varies of industries. The true worth of the IoT for enterprises will be fully accomplished once connected area unit devices are able to communicate with each other [2].

In IoT, we need the THING which is made up of a processor, sensors, and a communication module. This THING when it connects to the internet, it becomes IoT.

In this research, we present a new method for location detection using IoT. The idea is to use radio frequency identification (RFID) tags and machine learning algorithms to find the location of a mobile node and predict the best path to reach the destination.

RFID allows automatic identification and records capture, the use of radio waves, a tag, and a reader, the tag can store further Information than traditional barcodes. The tag incorporates records within the form of the electronic product code. In an international RFID-based object identification machine, three sorts of tags may be used for identification [3].

Passive RFID tags depend on radio frequency strength transferred from the reader to the tag to provide electricity to the tag; now, they may not be battery-powered. This type is used in supply chains, passports, digital tolls, and item-degree tracking [4].

1.1. Active Tags

Lively RFID tags have their own battery supply and can instigate communication with a reader. Active Tag can include outside sensors to monitor temperature, stress, chemical compounds, and other situations. Energetic RFID tags are used in manufacturing, health facility laboratories, and faraway-sensing asset management [4].

Semi-passive RFID tags use batteries to energize the microchip while speaking, while drawing power from the reader. Lively and semi-passive RFID tags are more expensive than passive tags [5].

Passive tags are the most widely used, as they are smaller and less high-priced to enforce. Passive tags have to be “powered up” by the RFID reader before then they can transmit information. Unlike passive tags, active RFID tags have an onboard power supply (e.g., a battery), thereby enabling them to communicate information at all times.

If we want to implement the system in a real city, we must use an active tag and a ultrahigh frequency (UHF) RFID reader because the reading distance is defined primarily based on the size and energy of the antenna. We have the diverse frequency ranges which include low frequency, high frequency (HF), and UHF; with their range covering from few centimeters to 100 m [6]. Hence, by the use of those hardware’s we can locate and identify our nodes in any road that we want.

Our proposed system is implemented by creating a small model that contains RFID reader, tag, and Arduino to detect and collect information about nodes or tags. We use passive tags, and a HF RFID reader that uses 13.56 MHz with a reading range between 5 cm and 1 m, to transfer information we create a closed network using 2.4G nRF24L01 Wireless Module w/power amplifier (PA) and low noise amplifiers (LNA) module, it uses the 2.4 GHz band and it can operate with baud rates from 250 kbps up to 2 Mbps. If used in open space its range can reach up to 1000 m (Fig. 1).


Fig. 1. 2.4 G nRF24L01 wireless module w/power amplifier long-range transceiver.

1.2. Features

  1. Voltage: 3–3.6 V (recommended 3.3V) V

  2. Maximum output power: +20 dBm

  3. Emission mode current (peak): 115 mA

  4. Receive mode current (peak): 45 mA

  5. Power-down mode current: 4.2 uA

  6. Sensitivity 2 Mbps mode in received: −92 dBm

  7. Sensitivity 1 Mbps mode in received: −95 dBm

  8. Sensitivity 250 kbps mode in received: −104 dBm

  9. PA gain: 20 Db LNA gain: 10 Db

  10. LNA Noise Fig. 2. 6Db

  11. Antenna Gain (peak): 2 Dbi

  12. 2 MB rate (Open area): 520 m

  13. 1 MB rate (Open area): 750 m

  14. 250 Kb rate (Open area): 1000 m.


Fig. 2. nrf24l01 tree topology network [7].

The module can use 125 different channels, which means that it has the possibility to have a network of 125 independently working modems in one place [7]. Each channel can have up to six addresses, or each unit can communicate with up to 6 other units at the same time for both transmission and receiving, so nRF24L01 can send and receive data and communicate with each other while connected in the network.

1.3. K-nearest Neighbors (KNN) Algorithm

KNN is a simple supervised learning algorithm [8] that stores all available cases and classifies new cases based on a similarity measure (e.g., distance functions). KNN has already been used in statistical estimation and pattern recognition since the beginning of the 1970s as a non-parametric technique [9].

In KNN a case is classified by a majority vote of its neighbors, with the case being assigned to the class most common among its KNN measured by a distance function. If K = 3, then the case is simply assigned to the class of its nearest neighbors.


We use Euclidean distance, and it should also be noted that the Euclidean distance measures are only valid for continuous variables [10].

The value of K is crucial; the large value gives more precision because it reduces the noise even though there is no guarantee. Choosing the optimal value for K is best done by first inspecting the data. Cross-validation is another way to retrospectively determine a good K value using an independent dataset to validate the K value, historically, the optimal K for most datasets has been between 3 and 7 [11]. In our case, we use 3NN because that model gets a better result in our dataset for detecting the actual zone of any user that needs help after a significant test that we have implied on the algorithm.


There are varies application domains which can be compacted by the emergence of IoTs. We categorize the applications into few domains, as in healthcare, Information and Communication Technologies, Transportation, Government, Public Safety and Military, smart home and sensible building, mobile technology, and smart business [12].

In this paper, our focus is on using node detection and tracking based on IoT for domains of health care and track monitoring.

2.1. Health Care

In some cases, patients do not even have enough time to get to a hospital. One of the most obvious and popular applications of health care is sending an ambulance to transfer the patients to a hospital for treatment, so what is the best process for find the patient’s location at the briefest time and how we can track an ambulance in a city [13]. The idea is to find the patient’s location and guide the ambulance to take the shortest and/or fastest way.

2.2. Tracking and Monitoring

Real-time monitoring through connected devices can save lives, with real-time monitoring of the condition in place by means of a smart device connected to a system or smartphone app; connected devices can collect information and other required data and use a communication technique to transfer the collected information to a data center [14].

The IoT device in an ambulance can collect and transfer data: Like blood pressure, oxygen and blood sugar levels, weight, and electrocardiograms [15].

2.3. End-to-end Connectivity and Affordability

IoT enables interoperability, machine-to-machine communication, information exchange, and data movement that make service delivery effective [16].

2.4. Data Assortment and Analysis

Vast amount of data that an IoT device sends in a very short time due to their real-time application is hard to store and manage if the access to the system is unavailable. Even for field providers to acquire data originating from multiple devices and sources and analyze it manually is a tough bet [17].


Node tracking is used in many fields such as transportation [18] and military security [19]. Among the techniques used in this field, we focused on IoT using RFID technology for its simplicity and its performance in this field.

In this research, we use IoT and machine learning algorithms to detect nodes in a closed network. Then, find the actual zone of any node in a smart city.

After that, we suggest the best pathway to any destination depending on distance, speed, time, and traffic. Finally, we predict the path of any IoT node using machine learning techniques.


At the beginning, we should determine the location; in our case, its Iraq-Sulaymaniyah Governorate. Then, data collection about this area must be collected (Fig. 3).


Fig. 3. Iraq-Sulaymaniyah governorate.

We divided this city into 42 zones (Fig. 4) depending on the police stations, classified areas, main roads, and hospitals. Then, we group zones and decrease them into 27 zones (Fig. 5). To simplify and improve our dataset.


Fig. 4. Sulaymaniyah 42 zones.


Fig. 5. Case study inside city.

At this step, we work only on 27 zones, due to the mentioned reason above, for each zone, we collect 100–500 samples depending on the size of the area. The idea of choosing this region is for it has most of the hospitals and police stations inside it, availability of more accurate data comparing to other zones, and it is the most active part of Sulaymaniyah in terms of traffic and connected roads (Fig. 6).


Fig. 6. Training sample.

After determining our zones, for each sample in any zone, we get longitude, latitude, zone code, nearest hospital, and police station that is responsible for that zone and the nearest Fire Stations is an important attribute we collect for each zone, so for training set and testing set we need all attributes mentioned above. We use Google earth for samples collection. Our system implemented by java and some data structure algorithm is used for getting better performance.

4.1. First Step

First Step must provide the dataset to the system for training and testing to get a result and finding the actual zone of each node that the system can recognize.

4.2. Second Step

Number of instances in our dataset is 11,095 samples for 27 zones, we use 70% of our samples for training and 30% for testing (Fig. 7) and depending on these samples and using machine learning our system can find the actual zone for each of the users because Sulaymaniyah Governorate at least has 10 billion coordinates which is a large number amount of data. We take only 11,095 coordinates, and we can give the same results. We use two cross-validated methods for sampling, Hold-out and bootstrap sampling, but Hold-out has better accuracy than bootstrap in our work.


Fig. 7. Testing sample.

4.3. Third Step

We use KNN to find actual zone (Euclidian distance) is used to calculate the distance between two points.

4.4. Fourth Step

After building a model, we must test it in the real world, for that reason using two approaches we can test our system, one of them is IoT tag and RFID reader by detecting node and sending tag information and their location to our system for finding the zone and other attributes. Or for the second mechanism the user send information to the system through a mobile application using SMS that contain critical information for finding that the user and their information are valid to our system or not, the information that the user send contain longitude, latitude, phone number, and type of the help that s/ he needs like the need for an ambulance or police or Firefighter. After determining the problem, we go to the next step.

4.5. Fifth Step

For sending an ambulance or police or Firefighter to the user, our system must find the best and shortest path to those users that need help. we create a closed network node detection in our city, so using the user information system the algorithm can detect the source and the destination targets, then calculate all possible ways from source to destination depending on these factors: Distance, speed, Traffic in that path and roads load because we already know that in some roads may have a lot of traffic in some periods such as in the morning and evening (start and end of a workday).

In our proposed system, we created a new algorithm for finding weights between nodes, and we can say that it is an improvement in finding weights between two readers or nodes in smart cities. Using (equation no. 2), we can calculate and find weights between any two nodes depending on (distance, speed, traffic, and some other parameters) and give that weight to Dijkstra’s algorithm [20] to find the best path between source and destination.



  • T = Time weight in (s)

  • D = Distanceab (m)

  • S = Speedab (m/s)

  • Tr = Traffic

  • Te = Traffic time

  • N = No. side

  • C = Car count in image

  • Tc = Traveled car in Traffic ~ 30


In the algorithm above, we have (C = Car count in image), when it comes to deep learning-based object detection algorithm, there are three primary object detectors you’ll encounter:

  • Regions-convolutional neural network (R-CNN) and their variants, including the original R-CNN, Fast R- CNN, and Faster R-CNN

  • Single Shot Detector

  • YOLO.

We use YOLO v3 [21] in our algorithm, in particular, YOLO trained on the Common Objects in Context (COCO) dataset [22]. The COCO dataset consists of 80 labels we use only those that are related to vehicles.

We are implementing YOLO v3 by two powerful languages python and java in our algorithm we created a specific java file that can send parameters and run the python file and return the number of detected vehicles inside the images and send it to our algorithm (Fig. 8).


Fig. 8. Vehicle detection in image using YOLO [21].

Number of images is equal to the number of RFID readers in that path; this process is repeated every 1 min because we need updated data from an updated image from any node.

We already know that the problem of image processing is memory consumption, we separated the work into two parts; the process of counting the number of vehicles in an image is separated from another process such as finding the actual zone and detecting the best path each of them run on a separate machine. A web service is used to communicate between them.

4.6. The Dijkstra’s Algorithm [20]

4.6.1. Step 1: Initialization

  • Assign the zero weights value to node s, and label it as permanent (The state of node s is [0, P]).

  • Assign to every node a weights value of ∞ and label them as temporary (The state of every other node is [∞, t]).

  • Designate the node s as the current node.

4.6.2. Step 2: Weights value update and current node designation update let i be the index of the current node

  1. Find the set J of nodes with temporary labels that can be reached from the current node i by a link (i, j). Update the weights values of these nodes. For each j ∈ J, the weights value dj of node j is updated as follows new dj = min{dj,di + cij} where cij is the cost of link (i, j), as given in the network problem.

  2. Determine a node j that has the smallest weights value dj among all nodes j ∈ J, find j∗ such that min j∈J dj = dj

  3. Change the label of node j∗ to permanent and designate this node as the current node.

4.6.3. Step 3: Termination criterion

If all nodes that can be reached from node s have been permanently labeled, then stop – we are done. If we cannot reach any temporary labeled node from the current node, then all the temporary labels become permanent – we are done. Otherwise, go to Step 2 [7].

Using the above algorithm, the system can find the best path from source to destination.


We use 3NN because it gives better results, as explained in Table 1. We divide our 11,095 samples into two-part training and testing by two famous sampling techniques in cross-validate sampling hold-out and bootstrap in the table below you can see the result of accuracy to find the actual zone of detected node.

TABLE 1 KNN results for both hold-out and Bootstrap


In each sample, we have a lot of attributes, but the important ones are longitude and latitude. Using KNN we calculate and find the 3, 5, and 7 nearest neighbors of each sample after that we find the means absolute error for all tests, as shown in Table 1 we have best accuracy (99.22388%) in hold-out at 3NN, the mean absolute error is 0.00776 which shows that our dataset and our implemented algorithm have a good result.

When a node has been detected, we calculate the zone based on their nearest neighbors as described in the third step. After that, we determine the destination (fourth step) then suggest the best path (Fig. 9). We describe the closed network area inside our city, the entire RFID reader’s node connected to each other. Each reader has a specific number, location, pathway that is connect to other nodes that node has traffic or not, nearest (hospital, police stations, and Firefighter), so if any reader detects the specific node, alert the system by sending some packet through our Wi-Fi network for notifying it that the node is here now, and system must choose the best path for it to travel to its destination in the first example the result is the best case because we do not have any traffic (Fig. 9).


Fig. 9. Best case path detection.

In the second example, we have traffic between those two nodes (Fig. 10).


Fig. 10. Path detection depending on all attributes.

At any point in the city, we can collect new information and set new order when the node is recognized by a RFID reader so the system can detect a new path if eventually, some accident happens such as traffic accident or cartography like fire at some building. Hence, the system finds the best path depending on all attributes that we have mentioned before.

Hence, our work can be updated at any time so that the reader detects the tag and calculates the new information for tracking and detecting the path that the node must travel.

Seeing the flowchart above (Fig. 11) describes all steps from source to destination for finding the best path. At any reader that detects a specified node, those steps above are done and send new instruction to the node. Like ambulance, police, and firefighters to travel and also they can send the notification before each interconnection of roads and ask the system to determine the path for it and send an instruction to them.


Fig. 11. Path detection flowchart.

All the detection and information collected from readers and the system are automatically saved in an encrypted manner in a database on the server.


The character of IOT has changed the entire world. This has been finished through the help of introducing IoT devices, smartphones, and character automated collaborators within the health area, security, learning, traveling, and transmission. The framework we propose is fit for following self-governing node inside a closed network area depends on RFID innovation. In the end, using this system, we can detect any node at any position in our city and find the actual zone for it and choose the best path from the source node to the destination node depending on the type for transmission, for example, if the problem is to provide health care, the system detects the best path from the source to the nearest hospital or if the problem is to provide police services, detect the best path to the nearest police or a fire station. It calls the nearest firefighters station. We have tested our algorithms on a prototype implemented on a surface of 1 × 1 m2; the results obtained are excellent. Our goal is to implement the proposed system in a real city and validate the algorithm on real data. Using this system and dataset can help other researchers work in other areas that can help cities use technologies to improve their lives.


[1]. GI Global. Biometrics:Identification and Security. In:”Multidisciplinary Perspectives in Cryptology and Information Security”. IGI Global, Pennsylvania, USA, 2014.

[2]. M. S. Al-Ani and Z. A. Kakarash. “Future aspects of intelligent car parking based on internet of things”. UHD Journal of Science and Technology, vol. 2, no. 1, pp. 19-26, 2018.

[3]. M. S. Al-Ani. “Electrocardiogram waveform classification based on P-QRS-T wave recognition”. UHD Journal of Science and Technology, vol. 2, no. 2, pp. 1-6, 2018.

[4]. S. Impedovo and G. Pirlo. “Verification of Handwritten Signatures :An Overview”. 14th International Conference on Image Analysis and Processing. ICIAP, Modena, Italy, 2007.

[5]. Karouni, B. Daya and S. Bahlak. “Offline signature recognition using neural networks approach”. Procedia Computer Science, vol. 3, 155-161, 2010.

[6]. M. Arathi and A. Govardhan. “An efficient offline signature verification system”. International Journal of Machine Learning and Computing, vol. 4, no. 6, pp. 533-536, 2014.

[7]. M. S. Al-Ani. “Study the characteristics of finite impulse response filter based on modified kaiser window”. UHD Journal of Science and Technology, vol. 1, no. 2, pp. 1-6, 2017.

[8]. V. Malik and A. Arora. “Signature recognition using matlab”. International Journal for Research in Applied Science and EngineeringTechnology (IJRASET), vol. 3, no. 6, pp. 682-687, 2015.

[9]. B. M. Thuraisingham, L. Khan, M. Masud and K. W. Hamlen. “Data Mining for Security Applications”. Conference:2008 IEEE/IPIP International Conference on Embedded and Ubiquitous Computing (EUC 2008), Shanghai, China, December 17-20, 2008.

[10]. S. Soviany, S. Puscoci, V. Sandulescu and C. Soviany. “A biometric security model for mobile applications”. International Journal of Communications, vol. 3, 85-92, 2018.

[11]. M. Al-Ani. “Biometric Security”. In:Handbook of Research on Threat Detection and Countermeasures in Network Security. IGI Global, Pennsylvania, USA, 2015.

[12]. M. Omar, N. M. Ghanem, M. A. Ismail and S. M. Ghanem. “Arabic-Latin Offline Signature Recognition Based on Shape Context Descriptor”. International Conference on Computer Vision Systems, ICVS:Computer Vision Systems, Berlin, pp 24-33, 2015.

[13]. R. Jana, R. Saha and D. Datta. “Offline signature verification using euclidian distance”. International Journal of Computer Science and Information Technologies, vol. 5, no. 1, pp. 707-710, 2014.

[14]. H. M. El-bakry and N. Mastorakis. “Personal Identification Through Biometric Technology”. AIC'09 Proceedings of the 9th WSEAS International Conference on Applied Informatics and Communications, Moscow, Russia, pp. 325-340, 2009.

[15]. S. Pal, M. Blumenstein and U. Pal. “Automatic off-Line Signature Verification Systems:A Review”. IJCA Proceedings on International Conference and Workshop on Emerging Trends in Technology. ICWET, Mumbai, vol. 14, 20-27, 2011.

[16]. S. Mushtaq and A. H. Mir. “N Signature Verification:A Study”. 4th International Conference on Computer and Communication Technology. ICCCT, 2013.

[17]. S. Bhatia, P. Bhatia, D. Nagpal, S. Nayak. “Online signature forgery prevention”. International Journal of Computer Applications, vol. 75, no. 13, pp. 21-29, 2013.

[18]. M. A. Maurello, J. A. Clarke and R. S. Ackley. Signature characteristics in contact calls of the white-nosed coati”. Journal of Mammalogy, vol. 81, no. 2, pp. 415-421, 2008.

[19]. V. A. Bharadi and H. B. Kekre. “Off-line signature recognition systems”. International Journal of Computer Applications, vol. 1, no. 27, pp. 48-56, 2010.

[20]. M. Tomar and P. Singh. “An Intelligent Network for Offline Signature Verification Using Chain Code”. International Conference on Computer Science and Information Technology CCSIT:Advanced Computing. CCSIT, Bangalore, pp. 10-22, 2011.

[21]. M. Radmehr, S. M. Anisheh, M. Nikpour and A. Yaseri. “Designing an offline method for signature recognition”. World Applied Sciences Journal, vol. 13, no. 3, pp. 438-443, 2011.

[22]. M. V. Kanawade and S. S. Katariya. “Signature verification and recognition case study”. International Journal of Electronics, Communication and Instrumentation Engineering Research and Development, vol. 3, no. 1, pp. 77-86, 2013.

[23]. H. Hiary, R. Alomari, T. Kobbaey, R. Z. Al-Khatib, M. A. Al-Zu'Bi and H. Hasan. “Off-line signature verification system based on DWT and common features extraction”. Journal of Theoretical and Applied Information Technology, vol. 51, no. 2, pp. 165-174, 2013.

[24]. M. V. Kanawade and S. S. Katariya. “Review of offline signature verification and recognition system”. International Journal of Emerging Technology and Advanced Engineering, vol. 3, no. 7, pp. 659-662, 2013.

[25]. Bhattacharya, P. Ghosh and S. Biswas. “Offline signature verification using pixel matching technique”. Procedia Technology, vol. 10, 970-977, 2013.

[26]. R. Doroz, M. Palys, T. Orczyk and H. Safaverdi. “Method of signature recognition with the use of the complex features”. Journal of Medical Informatics and Technologies, vol. 23, 1-8, 2014.

[27]. V. Malik, A. Arora. “Signature Recognition Using Matlab”. International Journal for Research in Applied Science and Engineering Technology (IJRASET), vol. 3, no. 4, 2015.

[28]. M. S. Al-Ani and M. M. Al-Saidi. “An improved proposed approach for handwritten arabic signature recognition”. Advances in Computer Science and Engineering, India, vol. 7, no, 1, pp. 25-35, 2011.

[29]. L. G. Hafemann, R. Sabourin and L. S. Oliveira. “Offline Handwritten Signature Verification Literature Review”. Computer Vision and Pattern Recognition, (cs.CV);Machine Learning (stat.ML), IPTA, 2015.

[30]. H. Hedjaz, R. Djemili and B. Hocine. “Signature recognition using binary features and KNN”. International Journal of Biometrics, vol. 10, no. 1, pp. 1-5, 2018.