IoT in Smart Cities: A Survey of Technologies, Practices and Challenges

: Internet of Things (IoT) is a system that integrates different devices and technologies, removing the necessity of human intervention. This enables the capacity of having smart (or smarter) cities around the world. By hosting different technologies and allowing interactions between them, the internet of things has spearheaded the development of smart city systems for sustainable living, increased comfort and productivity for citizens. The IoT for Smart Cities has many different domains and draws upon various underlying systems for its operation. In this paper, we provide a holistic coverage of the Internet of Things in Smart Cities. We start by discussing the fundamental components that make up the IoT based Smart City landscape followed by the technologies that enable these domains to exist in terms of architectures utilized, networking technologies used as well as the Artiﬁcial Algorithms deployed in IoT based Smart City systems. This is then followed up by a review of the most prevalent practices and applications in various Smart City domains. Lastly, the challenges that deployment of IoT systems for smart cities encounter along with mitigation measures.


Introduction
With a bulging world population and increasing urbanization which is set to grow by more than 10% in the next 30 years [1] resulting in a total of 70% living in cities by 2050, countries around the world are looking at equipping their cities to deal with the influx of people and the stress it will bring to current city systems [2].This is to be carried out keeping in view the UN Sustainable Development Goals 2030 [3].In this regard, Smart Cities have come out as a major initiative by various governments in making cities more navigable and welcoming to the expected population increase and providing city dwellers a better living experience, as is evidenced by the multiple projects ongoing on both the public and private level [4][5][6][7].In this survey, we provide a review of the use of IoT in Smart Cities and discuss how they facilitate such initiatives.However, since this topic is of high interest to researchers, while conducting the literature search, several surveys were found relating to this topic [8][9][10][11][12].The authors in [9] discuss challenges that IoT deployment faces in Smart Cities and look at their interrelation based on experts available to them and rank them.Our work is different from [9] in that our coverage of the challenges is blind to specific expert opinion and therefore not limited in scope to their application domain only, we provide an across the board discussion of the critical aspects that IoT designers in Smart Cities need to be vary about and go through practices addressing each of those aspects.The authors in [8] focus their discussion on the architecture and applications of IoT in Smart Cities and briefly describe the technologies used.Surveys in [10,11] provide an application oriented discussion for specific systems which have been developed for various smart city components and follow it up by case studies of cities with active smart city projects.In [12], the authors discuss the use of big data for cyber physical systems and discuss the different data generation mechanisms, collection, storage, analytics and security as well as steps to move to a greener deployment of such systems.They also talk about various application avenues of such systems.In contrast to the works of [8][9][10][11][12], we provide a detailed overview of the different core units and the technologies used in smart city implementations and discuss the current state of their usage/deployment.Figure 1 provides the structure of the survey.The main contributions of this paper are as follows:

1.
It lays out the structure of Internet of Things in a Smart City context, discussing its various applications, components and architectures.

2.
It provides a comprehensive survey of IoT technologies used at the different levels of the IoT architecture.

3.
It provides a discussion of the technical challenges that exist in the deployment of IoT in the Smart City domain and identifies potential solutions to those challenges.4.
It provides insight into current state of IoT usages and discusses different ways in which AI has been applied in the IoT for Smart Cities using the application of clustering, regression, classification etc.In addition, various applications, solutions and data used for implementing the overall framework of Smart Cities are discussed in detail.The discussion includes data sources, algorithms used, tasks performed, and types of deployment used by these proposed approaches.

5.
It suggests future recommendations regarding vital aspects of IoT implementation in Smart Cities.
It is hard to define a Smart City, in fact, cities claim to be 'smart' based on a variety of criteria, for, e.g., implementing novel e-governance schemes, creating social learning ventures and community engagement programs, focusing on sustainable living as well as the more typical application of Information and Communication Technologies for innovation [13].In this paper, we define Smart Cities to be the application of various information and communication technologies with the aim of creating a better living experience for a city's population.This encompasses use of these technologies in all the domains discussed previously, including governance, transport, housing, business, sustainable living, social learning, community engagement, providing opportunities and more.In an ideal sense, the idea of a smart city transcends the typically set boundaries of a traditional city's administrative and social structure by allowing interaction between the two, thereby enabling it to operate in a more cohesive and engaged manner.Smart cities offer several advantages (in terms of value) compared to a traditional city ecosystem: 1.
Climate goal achievement: Smart cities are at the forefront of pioneering technologies to help enable countries meet climate goals.Smart city focuses on smart energy management, smart transportation systems and city administration which aim to reduce the carbon footprint of cities and enable development and use of new technologies for cleaner living.

2.
Money value: Smart City ventures will be a market of USD 1 Trillion by 2025 [14], this provides a huge monetary incentive for not only governments but private companies to actively contribute to the development of technologies supporting smart city development.

3.
Societal impact: The centerpiece of the smart city project is to improve the quality of life of a city's inhabitants and help develop an inclusive society wherein every opinion is catered for and equal opportunity is provided.Information and Communication Technologies in the smart city context are a fundamental component to the provision of public services by facilitating interactions of citizens with the city environment and making life easier.

Smart City Components
A smart city is made up of several components which are illustrated in Figure 2. Smart city applications typically have four aspects associated with them, the first is the collection of data, the next is its transmission/reception, third is the storage and fourth is analysis.The collection of data is application dependent and has been a real driver for sensor development in the various domains.The second part is the exchange of data, this involves data transmission from the data collection units towards the cloud for storage and analysis.This task has been achieved in several manners, many smart city ventures have city-wide Wi-Fi networks, 4G and 5G technologies are being used, as well as various types of local networks which can convey data either on a local level or a global level.The third stage is storage in the cloud, different storage schemes are used to arrange and organize data so as to make it usable for the fourth stage which is data analysis.Data Analysis refers to the extraction of patterns and inferences from the gathered data to guide decision making.In some situations, simple analysis such as basic decision making and aggregating would work too.For more complex decision making, the availability of the cloud allows not only for heterogeneous data gathering/storage and processing but also analysis through the use of statistical methods as well as machine and Deep Learning algorithms in real-time [15].

Smart Agriculture
Food security is one of the most important parts of the United Nations Sustainable Development goals for 2030.With an increasing world population, worsening climate change causing erratic weather in food centers of the world, the race to ensure that food production is made sustainable and that dwindling resources such as water are utilized efficiently has been a high priority for countries around the world.Smart agriculture is the use of sensors embedded into plants and fields to measure various parameters to help in decision making and prevent/diseases, pests etc. [16].A part of the smart agriculture paradigm is precision agriculture, which involves sensors being placed in plants to provide targeted measurements and therefore allow for targeted care mechanisms to be deployed.Precision agriculture will be necessary for food security in the future [17] and therefore is an essential part of the fight for sustainable food production.The major applications of AI in IoT for agriculture are crop monitoring/disease detection and data driven crop care and decision making.

Smart City Services
Smart city services encompass the activities that sustain a city's population, these involve municipal tasks such as supply of water, waste management, environmental control and monitoring etc. Sensors for water quality can be deployed to continually provide an update about the quality of water being used in the city and detect leaks [18].One popular component of smart city initiatives is the management of waste, and it has been the part of many of the smart city initiatives mentioned earlier, from chutes in Barcelona to having bins equipped with sensors and connected to the cloud so as to not only inform the relevant authorities of the need to empty them but also using AI to determine the best route to reduce cost [19].Sensors can also be used to monitor the environmental conditions in a city to determine pollution levels [20] and guiding citizens to the next free parking space to save fuel costs [21].

Smart Energy
Typical electrical systems have one-way energy flow from a main generator source, usually a hydroelectric or fossil fuel based power plant.Power generation is controlled via feedback from the substations, however, since there is no information feedback from the consumer end, the power generation scheme used with these systems requires that the power being produced by these sources outstrips the demand by a large amount to ensure continuous supply of power.The process of detecting faults and performing corrective actions in such systems is also a time taking process.Moreover, with renewable energy technologies becoming cheaper, the consumer of today not only has a supply from the main utility but also performs their own generation.Smart Grids is the use of ICT technologies to make the current and newly installed grids more observable, allow for distributed energy generation, both at the consumer end as well as the utility end and introduce self-healing capabilities in to the grid.One aspect of smart grids is that real time power data is transmitted to utilities at different points on the grid throughout the supply lines till the customer.Since smart grids provide real-time data about consumer usage, it allows for better management of power generation using prediction models developed through acquired consumption data, integrating different energy sources as well as self-healing [22] of the network to ensure an uninterrupted supply.

Smart Health
Smart Health refers to the use of ICT to improve health care availability and quality.With an increasing population and rising costs of healthcare, this area has been of intense focus of researchers as well as healthcare providers.Current health systems are over burdened and therefore cannot cater to the increasing demand from the populace.In this regard, smart health aims to ensure that healthcare be available to as many people as possible through telemedicine services [23] and improved diagnosis assistance to doctors utilizing AI [24].With the ubiquitousness of mobile phones and health trackers [25] that can capture real-time data about peoples health (ECGs, temperature, body oxygen saturation and other biosensors) while also recording daily activity and detecting abnormal movements using inertial sensors, it has become possible to leverage cloud capabilities for processing this data to make better healthcare decisions.Thus, reducing the overall costs as well as burden on healthcare facilities.

Smart Home
One major component of Smart Cities is the Smart Home since it is the central to the life of the city's inhabitants.Smart Homes involve the use of sensing units installed throughout a person's home that provide information about the home as well as its occupants.These sensors might include user activity monitors such as ambient sensors, motion trackers and power/energy consumption.

Smart Industry
Industries around the world are busy in a continuous pursuance of being more efficient and increasing productivity while reducing cost.The industry 4.0 paradigm entails the vision of a connected factory where all its intermediary functionaries are seamlessly integrated, working in tandem with each other.This is made possible because of the internet of things [26].The use of IoT in manufacturing and production processes, cyber physical systems integrating workers and machines has led to several benefits to the industry such as faster and better innovation, optimization of manufacturing schemes (resources and processes), better quality of products and enhanced safety for factory workers.However, smart industries come with several challenges for IoT usage, working with a set of heterogeneous devices and machines has its own challenges and requires cyber physical systems to have flexibility in configuration, connectivity and quick implementation for use in IoT applications for Smart Industry [27].Artificial Intelligence has gone hand in hand with IoT to spur the development and deployment of industry 4.0 services.With sensors being embedded in machines and other processes in the factory, data from these sources provide an opportunity for using AI techniques to increase automation, perform business intelligence operations and more.In fact, researchers have suggested frameworks for integrating AI within IoT for Smart Industry [27][28][29].The major applications of AI in the industry are predictive maintenance, monitoring/fault detection (machine health) and production management.

Smart Infrastructure
The infrastructure of a city is paramount to its living quality, city governments need to construct new bridges, roads and buildings for the use of its inhabitants and also perform maintenance for uninterrupted usage.Smart infrastructure helps cities in ensuring their infrastructure is in shape and usable by utilizing sensors for measuring building/bridge structural state for structural health monitoring using accelerometers [30] and smart materials [31].Data collected through these sensors allows for predictive maintenance of these essential units to maintain normal operation of the city.

Smart Transport
Many urban centers suffer from traffic problems, this includes congestion, pollution, scheduling and cost reduction issues for public transport.The rapid development and implementation of new Information and Communication Technologies, Vehicle-Infrastructure-Pedestrian communication has become commonplace.Whether it be Vehicle to Vehicle (V2V), Vehicle to Infrastructure (V2I), Vehicle to Pedestrian (V2P) or Pedestrian to Infrastructure (P2I), such technologies have made the design of smart transportation systems possible.With cars having a GPS device and the commonality of cellphones with every driver, many approaches use GPS data to track driver behavior and traffic patterns [32].This real-time data is already used for route mapping in applications such as Waze and Google Maps and used for trip scheduling in public transport.Parking systems equipped with sensors can also guide drivers to the nearest free parking spot.

Internet of Things for Smart Cities
At the heart of the Smart city initiatives is the internet of things (IoT), it is the enabling technology that has allowed for the pervasive digitization that gives rise to the concept of smart cities.The internet of things refers to the ubiquitous connection of devices to the internet, allowing them to send information to the cloud and potentially get directions for performing actions.IoT involves the collection of data and performing data analytics operations to extract information in order to support decision and policy making.It is estimated that by 2025 more than 75 billion devices will be connected to the internet [33], spearheading even more application development.Within the smart city context, IoT allows for sensors to collect and send data about the city's state to a central cloud, which is then mined or processed for pattern extraction and decision-making purposes.

Iot Architectures for Smart cities
The Internet of Things unifies the operations of data sensing, transmission/reception, processing and storage through the use cloud services.Based on technology, a generic IoT architecture consists of five layers where successive layers operate on the information from the previous layer as shown in Figure 3.It also shows the three different architectures that exist for IoT systems.The Sensing layer, also called the Perception layer consists of sensors that can get information about physical quantities of interest in any application as well as actuators which can act upon physical objects, such as RFID readers for reading RFID tags and other such devices.The data read by the sensing layer is passed onward to the Middleware layer using the networking layer through wireless network technologies such as Wi-Fi, cellular internet, Zigbee and Bluetooth etc.The Middleware layer provides a generic interface for the sensing layer hardware and the Application layer which uses the data through various API's and database management services to provide users with services.The Business layer is attached to the application layer and is used to develop strategies and formulate policies that help manage the complete system.
In terms of architectures, typically, IoT architectures are categorized based on the type of operation responsibilities allocated to parts of the IoT system, this categorization is based mainly on processing of data responsibilities.There are three architectures of IoT systems with respect to the stage of the IoT framework where processing of data can be carried out and these are Cloud, Fog and Edge Models.Table 1 lists the traits of each of three layers of the IoT system.It is important to mention that the three IoT architectures discussed here are not mutually exclusive, instead the aim of this hierarchy is to complement the higher layer by providing it only useful information which makes the system more productive and dependable.For any IoT system designer, the aim is to establish a balance between the capabilities of the three layers keeping in view system costs and requirements.This was the first proposed architecture for IoT systems and is based on the premise that processing of data from the various components in the IoT system should take place in the cloud.Cloud computing allows for the remote accessing of uninterrupted shared resources (computing, storage and services) over the network.It should be able to dynamically allocate these resources without human intervention, schedule or pool as necessary and be able to be accessed from a variety of different platforms [34].The cloud can provide both hardware as well as software services for smart city applications.It has the advantage that it provides a central management platform from which to observe, control the IoT system as well as to disseminate command actions based on the received data.Moreover, this centralization also allows for cloud systems to have sufficiently large computing and storage capacities thereby allowing them to perform complex tasks of data mining, pattern extraction and making inferences from sensor data in smart cities to make use of it in the best manner possible.However, there are a few disadvantages with using the cloud computing model for the IoT.First, transmitting all gathered data to the cloud increases network traffic, even though this may not be true for applications in which measurements are not very frequent, but in other cases, this could increase network costs.Moreover, data transmission overheads may increase due to the large amount of data that needs to be transmitted by the many sensors existing in the smart city scenario.Another disadvantage that the cloud computing model suffers from is data latency, since the sensing units exist at the sensing layer and the decision making/data processing takes place in the cloud, this gives rise to data latency in the transmission of sensing information, especially when many devices start sending data at the same time.Network reliability can be an issue when using this model, with the large volume of data traffic on the network, it might not be possible to enforce robust data transmission schemes as IoT systems get bigger.

Fog Computing Model
Since most of the information produced with in IoT takes place towards the sensing end of the IoT system, also called the edge, Fog Computing was proposed in [35] to overcome some of the problems of the cloud computing model for the IoT.Fog computing provides a more diverse distribution of responsibilities than are dictated by the cloud computing architecture by moving some of the processing to devices on the local network.Typically, Fog computing refers to data processing that is carried out by routers and other network devices within in the Network layer in the IoT.Since network devices nowadays increasingly offer better computational capabilities, one can leverage them to perform rudimentary operations on data.Operations such as aggregation and collection of sensor data, simple processing operations and decision-making can be performed to reduce the amount of information flow towards the higher cloud layer.Questions that need to be answered for the decision-making process include but are not limited to for, e.g., does the decision require the use of averaging for one quantity and instantaneous values of the other?Is it possible to extrapolate data received for one quantity and use the currently measured value for another one?Based on the previous data for a given period, can one provide higher layers with decision options rather than just data, thereby providing better quality information to the cloud layer thus resulting in better utilization of cloud resources.Fog layers can localize decision making since they have access to the local state of a given region [36].This would be helpful in implementing distributed decision making mechanisms which might be necessary in some applications.Moreover, they also allow for local networks to be established using non-internet technologies such as Zigbee, Bluetooth, RFID etc. where sensors and other end devices transmit data to the Fog node (also referred to as access points in such systems) which is connected to the cloud.Fog computing results in reduced costs for deployment of IoT systems, increases robustness as latency, data overhead and errors in transmission are reduced.This also improves the efficiency of the applications as quicker decisions can be made on the received data, which is important in critical decision-making situations.Moreover, Fog devices have the capability to not only receive data from similar devices at the edge but also collect it from many different types of devices.This capability to measure different parameters in the edge environment enable for an application neutral IoT system architecture to be developed.
Data sent upward by the Fog layer in the IoT hierarchy would be used to gain insights in to system behavior and to guide new rules of system operation, this will typically be carried out in the cloud.Devices in the Fog layer may be provided decision making guidance from the higher cloud layer to ensure smooth system operation.However, a balance needs to be struck as to the division of responsibilities between the cloud and the fog layer keeping in view the costs involved.

Edge Computing Model
The purpose of Fog Computing was to push some of the decision making towards the edge of the network.In recent years, with increasingly capable devices being developed that are attached to 'edge' nodes, simple decision making, and processing of data has been increasingly moved on to these devices so as to reduce network and device costs even further at the fog level and make for even deeper distributed decision-making schemes.Edge computing refers to data processing that is done at the "thing" level, i.e., by sensors and other devices in the IoT system [37].Another concept about Edge computing as discussed in [38] defines the Edge computing layer as an intermediary layer between the Fog and the 'things' (sensors) rather than edge nodes.The difference between them in this case is the Edge computing nodes act as aggregation and decision-making units on a smaller scale compared to fog devices which act to provide seamless connectivity and data integrity throughout the IoT network.The aim of the Fog and the Edge computing paradigms is to decentralize the IoT system for purposes of reducing cost, increasing scalability and increasing robustness.

IoT Challenges for smart Cities
The Internet of Things promises the digitization of all aspects of our lives.For smart cities, this digitization process entails the proliferation of sensing nodes in every domain of a city's operation mechanism.With an application scope this broad, the creation and subsequent deployment of IoT systems in smart cities carry enormous challenges that need to be considered.In this section, we provide a discussion of the challenges that IoT system designers face when making deployments in smart city applications.In this paper, we focus on the technological challenges that pertain to IoT use in smart cities and have been the focus of researchers.Figure 4 shows the different challenges which Smart City IoT system deployment encounters, namely Security and Privacy, Smart Sensors, Networking and Big Data Analytics.A summary of the discussion in this section is presented in Table 2.

Security and Privacy
Security, along with Privacy is the primary concern in smart cities. Smart cities involve having essential city infrastructures online, any aberration in the operation of the city's services will bring inconvenience to its citizens and put human lives and property at risk.Therefore, security is a big concern in smart cities.In today's age where cybercrime and warfare have become a tactic in world politics, smart cities are at an ever-greater risk of being the target of such malicious attacks.Encryption of data transmitted over the network is necessary in this scenario.For smart city projects to be successful, they require the trust and participation of citizens.The proliferation of sensors in smart cities, which continuously collect data about the activity of people may expose the daily activities of citizens to unwanted parties.Moreover, companies and corporations on the IoT network may use citizen data without their approval for things like targeted advertising and may perform acts such as eavesdropping etc. Solutions to this will require processes that anonymize data collection while retaining the integrity of the context of the measured task so that apt decision making is possible.Security and Privacy has been covered in detail in this paper.

Smart Sensors
Smart sensors are the hardware components that gather data in smart cities.These devices are manufactured by a host of different vendors that adhere to different sensing mechanisms, standards of measurement, data formats and connectivity protocols.Smart city deployment will require all these devices to exchange data, perform scheduling of tasks between them and be able to aggregate data together for making inferences.A solution to this issue is to develop and use open protocols and data formats that will enable manufacturers to create equipment that can communicate between each other, further spurring IoT system deployment.Another solution could be the development of 'standard' access point nodes for IoT systems that can communicate to devices using several different communication protocols and are able to decode the information received.Some manufacturers have, in fact, made their products compatible with other protocols as mentioned in [39].
Another challenge for smart sensors is reliability and robustness.Reliability and robustness refer to the dependability and correctness of the IoT system.IoT is the backbone of future smart cities and being imperative to their operation, the IoT system needs to provide a smooth experience to its users.This requires that service requests from users of the application receive an accurate and timely response.The quality of service needs to be ensured for every citizen in the smart city.Systems that deliver critical utilities such as transport, electricity etc. should be decentralized.The distributed connection points will allow for robustness and increase reliability.One such example is self-healing in Smart Grids [22].
Many current networking protocols are developed for infrastructure networked devices which have access to continuous power, however, sensors in smart cities will be mobile in many scenarios and thus be battery powered.Moreover, they will need to measure, transfer and in some cases save data they have collected.This requires the development of not only low power, low overhead data transmission schemes but also development of new memory and storage technologies as well as low power devices that extend battery life as much as possible.Storing this large amount of data would require development of compression algorithms which will be employed and database schemes that will need to be developed in the future as smart cities and IoT are scaled up.Solutions for power issues necessitate the development of new battery technologies and perhaps the incorporation of energy harvesting mechanisms in such devices to make long lasting service provision possible.

Networking
The IoT depends on the capability of sensing and other devices to be able to send and receive information to each other and the Cloud.With new smart city applications coming up, providing networking to these devices to remain connected is a big challenge.Current networking methods are not optimized to providing networking services for smart city components.Many devices in smart cities have mobility and data throughput requirements which need to be met to provide an acceptable quality of service.Different approaches have been suggested in terms of defining access points, local networks etc. to solve this problem.Another aspect of networking would be working on efficient and dynamic routing protocols that can serve IoT requirements capable of working with stationary as well as devices in motion, which many current protocols do not offer sufficiently [40].

Big Data Analytics
IoT connected devices generated 13.6 Zetta Bytes of data in 2018 and this is expected to grow to 79.4 Zetta Bytes till 2025 [33].To make use of this data and continuously improve the services that are delivered in smart cities, new data analytics algorithms need to be developed.With the myriad of the different parameters that are measured in smart cities, these algorithms need to be applicable to data of varying nature (both structured and unstructured), better data fusion techniques need to be developed as well so as to combine them in meaningful ways and be able to extract inferences and recognize patterns.Deep learning has been of interest in this area as it can leverage on this large amount of data to provide better results for different applications.Another important consideration would be to ensure that the developed algorithms are scalable in that they have enough generality and can be used through out the intended application.For, e.g., for the purposes of activity recognition, the authors in [41] found that a CNN trained for activity recognition on one dataset failed to perform well on others or in [42] where the deep learning network performs poorly when the color of tomatoes is different from what it was trained on.Concept drift is another issue of concern as with the continuous acquisition of data, the properties of data may change over time.Techniques such as incremental learning may be useful in this respect.Explainability is another important factor for Smart City analytics to be widely acceptable, specially in the area of smart health.There have been some approaches suggested towards this end, in [43] a hybrid deep learning classifier and semantic web technologies based solution is demonstrated for the application of flood monitoring.In [44], the authors present an explainable deep learning based healthcare system at the Edge for COVID-19 care based on a distributed learning paradigm with promising results.However, more work needs to be performed to incorporate explainability techniques such as distillation, visualization, and intrinsic methods into Machine and Deep Learning based smart city applications in order to increase smart city application proliferation.

Sensing Technologies
Sensing is at the heart of smart city technologies.Sensors provide the knowledge and data from which smart city innovations are created.With the vastly different nature of Smart City projects and its various components, there are numerous sensors which are used as part of these initiatives.The authors in [53] have provided a framework for the comparison of IoT sensors and have listed sensors they found in use for Internet of Things.We use their work to direct our survey of the sensing technologies used in smart cities. Sensors within IoT can be divided in to several groups, these are ambient, motion, electric, biosensors, identification, presence, hydraulic and chemical sensors as shown in Figure 5. Sensors are the key component in smart city IoT systems which provide the interaction between the smart city system and the city's inhabitants and allow for new services to be developed.One thing to note is that many of the sensors find applications in multiple areas as discussed.Furthermore, any given application will require measuring different physical quantities and will require the use of many different types of sensors.For, e.g., ambient, motion, electric, identification, position, chemical and hydraulic sensors have been found to be used in smart homes.As noted in the challenges, working with different sensors which might have different output data types is a task that needs to be dealt with when working with multiple types of sensors.Table 3

Ambient Sensors
Ambient sensors include sensors used to measure physical quantities indicating to environmental conditions such as temperature, humidity, light intensity and pressure.Ambient sensors are used in a variety of smart city applications including smart homes where they are used to regulate the comfort level, they are also used for smart city services.

Bio Sensors
Biosensors are used for measuring health parameters of living things.Biosensors in smart cities are used for monitoring patients for healthcare purposes.Such sensors include ElectroEncepheloGram (EEG), ElectroMyoGram (EMG), ElectroCardioGram (ECG), skin resistance, heart beat, breath sensors, pulse oximetry, blood pressure and more.

Chemical
Chemical sensors are used to measure chemical properties of materials, this includes gas sensors which can measure/detect carbon monoxide (CO), carbon dioxide (CO 2 ) and other gases for air quality monitoring, sensors for detecting smoke, pH and other sensors for water quality monitoring etc.

Electric Sensors
Electric sensors allow for the measurement of electrical power and are widely used in smart grids and smart homes to monitor the power consumption of consumers/appliances. Types include current transformers and voltage sensors to measure current and voltage, respectively.

Hydraulic
Hydraulic sensors refer to sensors used for liquid measurements such as level, flow, leak detection.These are used for measurement of liquid levels in tanks [54].

Identification
Identification sensors refer to RFID tags and Near Field Communication (NFC) devices.These sensors are used in applications involving payments, data exchange in the domain of smart transportation and smart city services.

Motion Sensors
Motion sensors refer to sensors that can be used for the detection of motion.Sensors for motion sensing involve inertial sensors such as accelerometers and gyroscopes.These sensors are used in smart health applications such as activity tracking as well as applications like vibration sensing in smart homes and industry.

Presence
Presence sensors indicate to the presence of a humans or objects.Passive InfraRed (PIR) sensors are very popular and are used to detect human motion, reed switches can be used on windows and doors for security purposes, inductive loop sensors which use electromagnetic induction can be used to detect presence in transport systems.Ultrasonic sensors are also used to determine the distance of objects.Capacitive sensors are also included in this type, these may be used to determine position.

Other Sensors
Various smart city applications make use of different sensing modalities such as audio or visual information or other signal measurement devices, for, e.g., bluetooth and Wi-Fi signal strength.Since the sensors for these modalities capture raw information about signals (visual, sound or signal strength etc.), the gathered data is typically processed further before it indicates to the target variable being measured.

Networking Technologies
The internet of things in smart cities depends on the aggregation of data measured by individual sensing units placed throughout the smart city environment.Systems that can use these measurements individually have long existed and provided automation for small projects.However, the 'smart' in smart city comes from the collective usage of the data from these individual sensing units to perform complex decisions while delivering services to citizens.The collective use of this data enables its analysis over a wider scope compared to individual levels so as to determine long term patterns and provide meaningful insights to support services.The number of such IoT devices currently present in the world [33] are multiple times that of the world population.To enable these devices to exchange data, wireless technologies need to be used as physical connections would, for one, be too costly (where ever they can be used), second, would not satisfy the mobility requirements that are typical of many smart city applications.The internet has provided connectivity to computers, smartphones and other electronic devices around the world with each other, allowing for instant transfer of information between them.However, for IoT the internet may not necessarily be the only communication method [67] as many applications do not possess edge devices that can connect to the internet.An application may consist of a local network of sensing units which can exchange data between them and rely on a multi-hop communication protocol to send data to a central node, hub or gateway.The gateway might be fixed and would be connected to the internet, thereby relaying any monitored data to the cloud for further processing or use.It might also be possible that devices within an application may use many different protocols with the central node having the capability to communicate with all of them, a common case for such architectures is the smart home where manufacturers produce devices using propriety or incompatible protocols for which a hub may be used, an example of such a system was provided in [68] and several hubs are commercially available.In this section, we discuss the network types, topologies and protocols used in the Internet of Things for Smart City applications as illustrated in Figure 6.We later provide a comparison of these protocols in Table 4.

Network Topologies
There are three IoT network topologies, point to point, star and mesh [69].The first type of topology is the point to point topology where devices are connected to each other sequentially in a point to point manner.Point to point networks introduce data hops for packets that need to be sent to other nodes as data needs to go through each node in the path of the two nodes wanting to exchange data.Point to point networks are not very popular in IoT systems as it ranks low on fault resiliency and will breakdown if there is a fault in any of the intermediate nodes.In Star topology, all units in a network are connected to a central node or gateway and cannot send data to each other directly.In order to perform an exchange of data among themselves, the devices need to send it through the central node.Star topology networks, with their central node structure provide a natural aggregation scheme for data collection within the internet of things, however, large networks consisting of many devices, which can be the case in most smart city applications, may result in high latency and possible bottlenecks in high information throughput scenarios.Star topology has been used in various applications including disaster management [70] and environmental sensing [71].The last type of network topology that is used in IoT is the Mesh network topology, mesh networks allow all individual devices to communicate between them.By enabling communication between the nodes in a network, mesh topology offers a larger range as data transmitted towards a certain node can make multiple hops through the network, this also increases the networks resilience as alternate paths could be used if packet delivery fails due to any node becoming faulty.In fact, such topologies have been used in smart homes [72] as well as in smart grids [73].There are other topologies which have not been mentioned, for, e.g., tree (which has multiple star networks connected in a point by point fashion).

Network Architectures
Network Architecture refers to the structure of the network used for a given application.As discussed earlier, the 'things' in IoT may not necessarily be connected through the internet, in fact a distributed connectivity structure may be implemented with only one unit in the network being capable of sending data to the cloud depending on the requirement.Work in [67] mentions three types of network architectures that are used for smart cities based on IoT.These are Home Area Networks (HANs), Wide Area Networks (WANs) and Field/Neighborhood Area Networks (FANs/NANs).Home Area Networks are short range networks and are usually used to transmit information to a central node which is responsible for data collection before it is sent to the cloud.Communication within the network is performed using some low power communication protocol such as Zigbee, Bluetooth, Wi-Fi etc. HANs are very popular in smart homes where they are used to gather power consumption and times of operation data from a multitude of appliances which are then sent to a smart meter as part of a smart grid [74].The second type of network architecture is Field Area Networks (FANs), sometimes also called Neighborhood Area Networks (NANs).Field Area Networks have a larger communication range than HANs and are used to provide connection between a customer (for, e.g., in a smart grid) to the utility company.Wide Area Networks are used for network structures that require communication over large distances.These networks are not as dense as HANs or FANs and utilize technologies such as cellular services, wired connections such as fiber optics as well as a class of low power protocols designed for WANs themselves [75].WANs are used in a variety of smart city applications including Smart Grids where they are used to connect multiple substations together or exchanging data between the customer and the substation [76].

Network Protocols
The type of network to use depends on the requirements of the application.It is imperative that the communication protocol used in a smart city application meet the desirable quality of service (QoS).Several protocols have been used in the internet of things for smart cities [11,[77][78][79], we discuss the traits of the most popular wireless networking protocols used in smart cities.

RFID
Radio Frequency Identification (RFID) utilizes radio frequencies to transmit and receive data.RFID communication consists of two types of devices, one device is the Reader and the other is called the Tag.The Reader is usually powered and once a tag comes in the vicinity of the reader, an exchange of information takes place after authorization as the tag harvests the energy from the reader.Such tags are called passive tags, there are also active tags which are do not depend on the reader for their power.Depending on the standard, RFID can operate on different frequencies in the radio frequency spectrum between 125 KHz to 928 MHz and can be used over short ranges.They are used in applications such as smart transport (toll tax collection, parking), smart health and more.

Near Field Communication
Near Field Communication (NFC) is very similar to RFID, however, the structure of NFC communication doesn't consist of tags and readers.Unlike RFID, both devices which want to communicate using NFC need to be powered and data tranmission/reception can take place in both directions unlike RFIDs.This enables the use of NFC to control and configure devices unlike the RFID which cannot be used for measurement or control tasks.NFC utilizes similar frequencies to RFID but is used for very short distances.NFC devices are popular for applications involving payment using smart phones and are also used in smart homes.

Bluetooth
Bluetooth is a low energy protocol popular in IoT applications as it can support an unlimited number of nodes [77].The protocol is designed for short range, low bandwidth communication in an arrangement where devices can easily exit or enter the network.Bluetooth natively supports the star topology as it has a master device at the center of the communication mechanism.It operates in the 2.4 GHz ISM band and can have maximum data rates of 2 Mbps.Bluetooth has been widely used in smart home due to it providing a direct connection interface to smart phones without the need for any intermediary hub device.

Z-Wave
Z-Wave or Zensys wave is a low power protocol developed to be used in home automation applications.It is a low speed protocol with a short range, operating in the frequencies of 868 MHz and 900 MHz.It operates in a master slave fashion where a master can have multiple slave devices which can respond to commands from the master node, therefore this is well suited for applications where a central control element is present and needs to gather data from multiple sensing units such as smart homes and smart healthcare systems.

Li-Fi
Li-Fi (Light Fidelity) uses visible light instead of radio frequency to exchange data.The advantage with using Li-Fi over RF communication is that it can utilize already present lighting systems which also results in conservation of power [80].It offers very high speeds of data transfer for short distances and has been used in parking systems.

Wi-Fi
Wi-Fi (Wireless Fidelity) operates using wireless frequencies in the 2.4 GHz and 5 GHz bands to provide high speed internet connectivity in a limited distance.Wi-Fi is popular in many smart city applications as it provides ready to use interface to smart phones, computers and other wearable gadgets.

Zigbee
The ZigBee protocol was developed as a low power low cost protocol for wireless sensor networks (WSNs) and has evolved to be used in the Internet of Things.The ZigBee protocol operates in the 868 MHz/915 MHz/2.4GHz band and offers moderate data transfer speeds with distances similar to Wi-Fi in a multi-hop data transfer scheme.Zigbee radios are low cost devices and therefore it is a popular protocol used by many manufacturers of smart home, smart healthcare devices.A ZigBee network will have three devices, one called the coordinator which is the controller of the network, the router which is responsible for moving data to other devices and the ZigBee end device (sensors and actuators).

Wi-SUN
The Wireless Smart Utility Network (Wi-SUN) is a network approved by IEEE and is used in field area networks for utility metering, automation of distribution for utilities such as electricity, gas etc. and also for demand response systems for utility-based applications.It supports IPv6 addressing and can be used in star or mesh configuration where it also allows for multi-hop communication [81].

Cellular
Cellular technologies refers to 3G, 4G and 5G communications.Along with Bluetooth and Zigbee, they are the most popular IoT enabling technologies.Cellular communication provides high data rate and supports more content rich applications compared to the other protocols.With the long range they provide, they are preferred for a variety of applications where power is not an issue.Depending on the technology, cellular bands range from 600 MHz to 80 GHz with very high data rates.

LoRaWAN
LoRaWAN stands for Long Range Wide Area Network (LoRaWAN) and it is a Low Power Wide Area Network (LPWAN) that consists of several gateways and multiple end devices with the gateways connected to a back-end network server.The back-end server provides connection to the cloud.End devices do not have a fixed association with a specific gateway and may send data to multiple gateways when it needs to transfer data to the cloud.6LoWPAN 6LoWPAN which is short for IPv6 over Low Power Networks was created by the Internet Engineering Task Force (IETF) specifically for internet of things applications with the aim of making it possible for providing internet connectivity to small devices.It is an IP based network and leverages IPv6 communication.This is a short-range network operating in ISM bands.

SigFox
SigFox is a proprietary standard developed by SigFox Inc., France.It uses unlicensed bands to perform ultra-narrowband bidirectional communication with low speeds [82].

Big Data Algorithms/Artificial Intelligence
The various sensors that make up the internet of things in a smart city relay information about the city's state to the cloud.However, measuring raw data is not enough, to utilize this data and to make the city 'smart', data analysis is key.Data analysis in smart cities has four layers, the first is Data Acquisition, which deals with the collection and storage of data, this is followed by the Preprocessing layer which performs operations (such as imputing missing values, scaling, removing erroneous data points etc.) on the data to ensure that data is of suitable quality to be used for the data analytics stage.The data analytics stage involves the application of data science techniques on the data to extract patterns and insights which would be used for policy making, planning and other actions in the Service layer.In this section, we focus our attention on the third stage of the data analysis process, i.e., data analytics.Data analytics in the Smart City based on the IoT involves the use of Deep Learning and Machine Learning on the gathered data.Figure 7 provides a summary of the AI discussion in this paper.It highlights the applications in which each AI domain finds for smart city components.We first mention the algorithms most commonly used in smart cities and follow it up with a discussion for the application for each component.

Machine Learning
Machine learning (ML) has been a crucial element of smart city application development [83], helping in prediction (classification), estimation (regression) and clustering tasks.Machine learning refers to the set of approaches through which computers can be used to learn from empirical data [84] and has been used in smart cities in various applications.Since there has been a lot of work in this area using ML algorithms, we focus on work in the last five years.It was found that most commonly used ML algorithms have been the Support Vector Machine (SVM), Random Forests (RF), Decision Tree (DT), Naive Bayes (NB), K-Means, K-Nearest Neighbor (K-NN) and Logistic Regression (LR).

Deep Learning
Deep learning is the use of successive layers of Artificial Neural Networks (ANNs) to learn patterns.The idea is that successive non-linear layers of interconnected artificial neurons can be used to learn patterns in data that simple machine learning algorithms might not be able to do.Deep learning architectures can process noisy data to provide output for classification and prediction tasks.This makes them very useful in the Smart City environment where the IoT enables the collection of heterogeneous sensor data which can be of varying nature.Data derived from sensors can be processed to extract features or can be fed directly to deep learning algorithms which can perform both feature extraction as well as classification/prediction. Deep Learning methods such as Recurrent Neural Networks (RNN)(Long Short-Term Machines (LSTM) and Gated Recurrent Units (GRU)), Convolutional Neural Networks (CNN), Deep Neural Networks (DNN) and Stacked Autoencoder Networks (SAE) were the preferred deep learning methodologies used for smart city applications and our discussion revolves around the utilization of these methods.

Smart Agriculture
The major applications of AI in IoT for agriculture are crop monitoring/disease detection and data driven crop care and decision making.Considering the scarcity of water, the authors in [85][86][87] develop irrigation systems which monitor and control the amount of water being used for crops, all structured around a cloud computing system.This problem has been devised both as a classification as well as a regression problem as in [88], who develop a closed loop water irrigation system using support vector regression and K-Means clustering.The authors in [89,90] propose cloud based greenhouse monitoring systems using images and a host of physical parameters from plants such as temperature, humidity and light using several machine and deep learning methods.Plant disease detection is also an important task within smart agriculture and has been worked on by the authors in [91][92][93][94] who present schemes for disease detection for various crops including tomatoes and potatoes.The proliferation of sensing systems in agricultural fields has also provided an avenue for data driven decision making and planning for farmers.This involves predicting various physical parameters which can affect crop growth like solar radiance [95] and temperature, humidity, windspeed [96][97][98][99][100] to help in decision making in terms of plant care but also classification systems for recommending crops to be sown [101,102].It is important to note that all of these implementations are cloud based.
There have been some suggested methodologies for bringing fog processing for AI in smart agriculture, for, e.g., in [103] a deep learning entrusted to fog nodes (DLEFN) algorithm is described to support efficient use of resources and reduce cloud resource usage.However, as noted in [104], who use an edge system for temperature prediction using an LSTM, edge device performance still lacks that of similar cloud systems but the inclusion of DL capable hardware does provide opportunities for further innovations.Previous work by the same author [105], where they aimed to monitor crops for frost signs and trigger anti-frost measures, compared edge and cloud computing systems for outlier detection and determined that cloud implementations to provide much better performance.However, they do note the potential for edge systems to provide highly responsive data analytics in smart agriculture.More applications can be envisaged for AI deployment in smart agriculture, for, e.g., monitoring of crop growth, selection of the fertilizer and the timeline for it to be used as well as targeted application, pest detection and intelligent pesticide spraying so as to reduce harm to the environment, environmental monitoring to track the effects of climate change and more.Some of these applications have potential to be deployed as edge computing systems.A summary of the use of IoT based AI in Smart Agriculture is presented in Table 5.  [97] DNN [99] RNN (GRU) [98] DNN [95] Regression-Prediction of solar radiance RNN (LSTM) [104] Edge /Cloud Regression-Temperature forecasting Data driven crop care and decision making (Crop recommendation) DT [101] Cloud Classification-Different crops Homogeneous (Temperature) DT [102] Classification-Soil fertility and type, Regression-Prediction of soil toxicity Heterogeneous (Soil moisture, Temperature, Humidity, PH, Soil nutrient content/fertility)

Smart City Services
A popular component of smart city initiatives is the management of waste and involves having bins equipped with sensors and connected to the cloud to not only inform the relevant authorities of the need to empty them but also using AI to determine the best route to reduce fuel consumption.The use of IoT systems for waste management has been observed in the works of [106] who utilize IoT systems to help reduce energy wastage in waste collection by municipalities.Hussain et al. [107] develop a waste management system that not only determines if bins are full and need collecting (using data from various sensors placed in the bin) but also predicts the air quality around it using RNNs.The sensing modalities in each of these applications is pretty similar in that they indicate to whether a waste bin is full or not which is then used for route planning.Considering the requirements of such a system, in terms of implementation, all of these systems are cloud based.Sewer monitoring has been performed in [108] in a cloud based system, they use sewer water level and rain gauge data along with a RNN to perform sewer overflow monitoring.The RNN is used to predict sewer overflow ahead in time.Water quality has monitoring has been the focus of [109][110][111] where the authors use multiple sensors measuring pH value, chloride, nitrate content and hardness of water to determine whether it is fit for drinking or not.In [112], Liu et al. use data from water monitoring stations along the Yangtze river to predict water quality.Like the classification-based systems, they use multiple chemical measurements from the water such as oxygen, pH, turbidity etc. Apart from air quality, smart city monitoring systems are an important application within the smart city services domain.This includes urban noise, which has been the focus of researchers in [113,114] as well as other more comprehensive monitoring systems as proposed in [115,116].All these systems are cloud based and use a combination of sensors for sound and/or image data for performing noise monitoring/detection and various smart city dashboard applications.In Table 6, we summarize the type of deployments, applications task and data for smart city services applications.It is noted that most of the applications relating to city services such as air quality monitoring and prediction, sewer monitoring, waste collection have been proposed as cloud systems as data needs to be collected from nodes at various points in a city.It is envisaged that due to the nature of the applications, many smart city services would still rely on cloud or fog architectures as the decision-making taking place in such situations isn't possible on only a local level.It is also observed that most of the applications required data from multiple sensors and therefore utilized heterogeneous data to carry out the task at hand. ) RF [118] RF [119] RNN (LSTM) [120] Regression-Prediction of air quality levels Water quality monitoring NB [109] Cloud Classification-Determine if water is fit to drink or not Heterogeneous (Chlorides, Nitrates, Total dissolved solids, pH and Hardness, and other chemical properties) SVM [110] DNN [111] RNN (LSTM) [112] Regression-Prediction of water quality Sewer Overflow Monitoring RNN (GRU, LSTM) [ [116] Cloud Application-Dashboard (object identification etc.) Heterogeneous (Various sensors, Urban video and sound data ) CNN [115] Smart Energy Load/energy consumption forecasting is an essential task for monitoring and control of electrical power supply in the electricity grid and ensure appropriate demand side management.It has been performed by the authors of [121] who use data collected from consumers in a smart grid to determine load for up to 24 h in advance.They treat this as primarily a clustering problem where they form clusters of similar load profiles and then use distance functions to determine energy consumption for the future.The authors in [122] also use a cloud based clustering approach, using historical power data, they use K-Means clustering to determine the closest historical records and then combine them to predict energy consumption 24 h in advance.The load forecasting problem has been dealt as a regression by [123] using a SVM and by [124] through an RNN using electricity power data.A regression approach is also followed by [125,126] who use electricity consumption in addition to environmental data for load forecasting using deep learning methods (DNN and a combination of Autoencoders and RNNs (GRU)).Edge based systems have been suggested by the authors of [127][128][129] for load forecasting for household consumers, Ref [129] use federated learning to train a RNN.In addition to load forecasting, smart grid management/monitoring is also a necessary application in this domain.The authors in [130] use decision trees in a cloud based system to classify between different faults in a smart grid.In [131], the authors use power consumption data from consumers in China to determine electricity theft in a cloud based system.They use wide and deep convolutional neural networks to capture the periodic and nonperiodic components from electricity consumption data and show their network to be suitable for electricity theft detection.The authors in [132] present a framework for edge computing based monitoring of the smart grid.Edge computing in the smart grid has several advantages as it reduces delay and secure in terms of data privacy.A summary of the use of IoT based AI in Smart Energy is provided in Table 7. Regression-Predict consumption of electricity ahead of time SVM [123] RNN (LSTM) [124] DNN [125] Heterogeneous (Electric power, Temperature, Humidity, Time, Holiday SAE + RNN (GRU) [126] CNN [128] Edge RNN (GRU) [127] Homogeneous (Electric power) RNN (LSTM) [129] Smart Grid line event classification (fault etc.) DT [130] Cloud Classification-Different powerline events Homogeneous (Electric power) Electricity theft detection CNN [131] Cloud Classification-Theft detection for abnormal patterns of consumption

Homogeneous (Electric power)
Smart Health There are two major applications of IoT with AI in health, these are activity recognition/fall detection and disease diagnosis/health monitoring, a summary of the IoT based AI systems used in Smart Health is presented in Table 8.Activity recognition involves the use of movement sensors such as accelerometers, gyroscopes and magnetometers with the aim to help provide the user with feedback on their health in terms of them having enough physical exercise or not, used for sports therapy, fall detection and for monitoring of different diseases such as Parkinson's or other motor degenerative ailments.The most popular sensor for activity recognition are inertial sensors which have been used by [133,134] in a cloud based setting using various deep and machine learning algorithms.In [135], Castro et al. include vital sign data in addition to movement information for human activity recognition in a cloud environment, they utilize the DT as their classifier.In [136],, the authors propose an edge-based system to perform activity recognition for people by recording their movements using the accelerometer and gyroscope present on the phone.They use a SVM as their classifier and differentiate between six different activities of daily living.Fall detection has been performed by [137,138] in a fog and edge environment, respectively, using an accelerometer, Santos et al. [137] use a CNN while Yacchirema et al. [138] use RF with both approaches showing promising results.
Equipped with the power of AI in IoT, Smart Health systems facilitate the provision of telehealth services as well as real time monitoring of patients, giving doctors and patients feedback on their health.Health monitoring systems and real time disease diagnosis have been one of the most important applications of IoT technology.The authors in [139][140][141][142][143][144][145][146][147][148][149] develop cloud based health monitoring systems for detecting various types of diseases, such as heart (stroke [140], irregular sound [142], irregular rhythm [144,146]), epileptic seizures [145], Parkinson seizure [149] and multiple disease diagnosis systems [147,148].In [147,148], the authors formulate the problem of disease diagnosis as a classification problem and utilize medical data such as ECGs, EEG, heart rate, blood pressure, blood sugar, heart sound, blood glucose, liver health along with various machine and deep learning methods to achieve this task.Fog and edge based health monitoring/disease diagnosis systems have also been suggested by a number of researchers.The authors in [150] present a fog based system using a deep neural network to detect heart disease from a patients vital signs (blood oxygen, heart rate, respiration rate, EEG, ECG, EMG, blood pressure, glucose) and activity data.In [151], Devarajan & Ravi work on a fog computing based Parkinson detection system using a persons speech.Moreover, an edge computing system is presented in [152] which utilizes EEG signals to determine seizures in patients.[133] Homogeneous (Accelerometer) CNN [134] RNN (LSTM) [153] Fog Edge Heterogeneous (Accelerometer, Gyroscope, Magnetometer) CNN [137] Fog RF [138] Edge Heterogeneous (Accelerometer and Gyroscope) SVM [136] Patient health monitoring DT [139] Cloud Classification-Recommendation about diet etc.

Smart Homes
Ambient assisted living is a huge component of Smart Homes.This is especially needed for the elderly and is typically achieved by the use of ambient sensors, Wi-Fi and radio frequency systems in smart homes.In this work, we include all monitoring methods that depend on sensors placed in the home/within the smart home domain.In [155], Pirzada et.al use a network of reed switches connected to the cloud to monitor the activities of elderly people as a clustering problem.They use the K-NN algorithm to determine anomalies in the daily activities which can then be used to send medical or other help requests to assist people.A similar setup for activity recognition for ambient assisted living has been presented in [156][157][158] where they use data from a number of different sensors including motion, presence, water float, temperature etc to determine various activities being performed in a home.In [159], a cloud based assisted living system for the deaf has been developed that performs haptic conversions for sounds detected in a home.An array of sensors are used to monitor environmental sound and the authors use RNNs for detecting the sound event before its passed on to the haptic vibration producer.Another task within in monitoring is localization of people, this part of smart homes is also applicable to smart infrastructure in that such systems are used in smart buildings as well.Applications of localization include security, i.e., detecting unauthorized presence and people monitoring in general (for, e.g., locating elderly people in homes) etc.The authors in [160] perform localization using a grid of Wi-Fi units that measure signal strength to determine peoples locations indoors for buildings.They formulate this both as a classification problem as well as a regression problem.The classification problem being formulated as coded locations (for, e.g., a given room no) while the regression case estimating the location of the user in a coordinate grid.Their system is cloud based and they use a deep neural network to perform this task and have found suitably good results.Occupancy detection has been performed by the authors of [161] making use of various ambient measurements (temperature, humidity, pressure etc.) and passing them to a cloud before using a deep neural network to classify between the various number of people present in an indoor environment.In [162], Zimmermann et al. also make use of ambient sensors for the occupancy problem and use a naïve bayes learner to determine both the presence of occupants as well as their number.Home automation is another application that the IoT finds application within the Smart Home domain.The integration of AI has helped develop smart home automation systems that aim to reduce energy consumption in homes as well as maintain user privacy, security.Chowdhry et al. [163] use a combination of visual data and motion sensing to perform home automation for security using a SVM.An interesting use of AI in home automation is presented in [164] who develop a cloud based home automation system, they take measurements from various ambient sensors and control appliances and use a Naïve Bayes classifier to determine which technician to call whenever sensor measurements appear aberrated.The problem of Intelligent consumption of energy has been considered by [165] who develop an energy disaggregation system on the appliance level in smart homes using stacked denoising autoencoders.They achieve this using power data for individual appliances as well as the total power consumed in the home and send it to a local cloud.Data are then disaggregated for various appliances to provide feedback to the user.More work providing energy intelligence to consumers has been performed by [166][167][168].Konstantakopoulos et al. [168] pose this as a regression problem, they propose a cloud-based system utilizing both ambient sensor data (lighting, temperature etc) and appliance power data to forecast resource usage for consumers using a RNN.They show a reduction in energy consumption for their users using this information.
Eventhough applications covered in smart homes have been cloud based systems, there have been recent proposals for frameworks that combine edge and cloud processing as in [169] who discuss a hierarchical control system for smart homes through a edge microgrid and a cloud power grid.Due to the nature of smart homes in that the sensing scheme is present within a finite space (within the home), edge and fog computing based systems are expected to be increasingly incorporated smart home applications.A summary of the use of IoT based AI in Smart Homes is presented in Table 9. SVM [163] Cloud Classification-Intrusion detection Heterogeneous (Images + Sound) SAE [165] Regression-Disaggregation of appliance power data Homogeneous (Appliance power consumption) RNN (LSTM) [168] Regression-Forecasting occupant resource usage Heterogeneous (Appliance power consumption, Luminance, Vibration, Temperature, Humidity, Accelerometer [fan]) SAE for disaggregation and RNN(LSTM) for forecasting [167] Classification-Energy disaggregation, Regression-Load forecasting Heterogeneous (Temperature, Luminance, Humidity, Proximity switches, Ultraviolet light sensors, Power consumption) NB [166] Classification-Determine appliances that are on Homogeneous (Appliance power consumption)

Smart Industry
One of the major applications of AI in the IoT powered smart industry is towards fault detection in products and anomaly detection in industrial processes.This has seen the use of both Machine Learning (SVM [170,171], RF [172,173] as well as Deep Learning (DNN [174][175][176], CNN [177]) methods using a cloud computing structure to perform anomaly detection /product inspection and monitoring using a variety of heterogeneous and homogenous data sources such as inertial sensors for machines, images for products and processes and other process specific variables.Other approaches suggested in [178,179] propose a fog computing method along with edge computing systems suggested in [180,181].An edge computing system for anomaly detection is presented in [182] where edge devices collaboratively train a deep anomaly detection model.Production management is another application that has found usage of AI in IoT based smart Industry.For, e.g., the authors in [183][184][185][186][187] use cloud based data driven systems along with machine and deep learning algorithms to help with task dispatching, performance analysis as well as worker activity recognition utilizing a variety of sensing modalities.The work of [186,187] are especially interesting as they aim is to not only perform production management but also propose data for various health related analysis to create a safer working environment on the factory floor.A fog system for production management has been presented in [188] who use activity data to determine resource allocation locations to contribute to management of a production operation.Furthermore, product inspection, which is a common application of instrumentation systems in a factory, has been performed by [189,190] who utilize images and sensor data in a cloud based system to monitor product quality.
A factory has a multitude of machines and equipment working round the clock manufacturing goods.Maintenance is an important aspect of this operation where regular checks are performed on the equipment to ensure that no breakdown occurs during the production process, which might result in monetary loss or loss of life.However, with the data gathered by various sensors on these machines, it is often more beneficial to take an active approach rather than a passive one by using this data for predictive maintenance purposes.Predictive maintenance utilizes data from the daily operation of machines in an industry to optimize the manufacturing operation [191] and is one of the main uses for AI in the industry.In [192,193], the authors suggest a predictive maintenance scheme using SVMs utilizing data from accelerometers measuring vibration in a crane motor and data from various sources in a semiconductor manufacturing process, respectively, both work in a cloud environment as evidenced from the architecture.Prediction of failure can also be a regression operation, as was demonstrated by [194] who use RNNs to predict future values of a physical parameters of a pump using a number of heterogeneous sensors used to monitor it.As with the other two systems, this system also had a cloud architecture.The authors in [143] also present a regression based health prognosis system for the industry using a CNN on machine data (Images, stress, temperature, vibration, position and electromagnetic signal measurements).The use of IoT based AI in Smart Industry has been presented in Table 10.[175] Classification-Different damage stages of a 3D printer Heterogeneous (Accelerometer, Gyroscope) RF [172] Classification-Normal and abnormal operation in wind turbines Homogeneous (Accelerometer) SVM [170] Classification-Different wind turbine health conditions SVM [171] Classification-Normal and mixed cement Homogeneous (Images) RF [173] Classification-Different fault types in steel manufacturing Heterogeneous (Various sensors, dimensional measurements) Classification-Normal and arcing Homogeneous (Current) CNN [177] Classification-Defected product or not Homogeneous (Images) CNN [178] Fog Classification-Different types of defects Homogeneous (Images) CNN [179] SVM [180] Edge Classification-Abnormal and normal pressure Homogeneous (Water pressure) CNN + RNN (LSTM) [182] Classification-Abnormal and normal time power patterns Homogeneous (Electrical power) RNN (LSTM) [181] Classification-Faulty and normal state of a machine Homogeneous (Accelerometer) Production management SVM [183] Cloud Regression-Prediction of the slotted coefficient in a hydraulic press Heterogeneous (Various measurements from a hydraulic press) ConvLSTM + SAE [184] Regression-Forecasting machine speed to make production more efficient Homogeneous (Speed of machine [rotary]) DNN [187] Regression-Bottle neck prediction in time Heterogeneous (RFID, movement sensors) CNN [185] Classification-Different activities in an assembling factory Heterogeneous (IMU, EMG) SVM [186] Classification-Different activities in a meat processing plant evaluate worker performance Heterogeneous (Accelerometer, Gyroscope) RF [190] Classification-Bad or good product quality Heterogeneous (Various sensors from a production floor in a factory) CNN [189] Classification-Prediction of temperature, Carbon content in steel Homogeneous (Spectrogram Images) RF [188] Fog Classification-Determine Room ID, used for system disruption Heterogeneous (Activity data, Location) Predictive maintenance CNN [143] Cloud Regression-Predict health index for machines Heterogeneous (Images, Temperature, Vibration, Position, Electromagnetic signal measurements, Strain gauge) SVM [192] Classification-Abnormal or normal vibration data (from electric motor in a crane) Homogeneous (Accelerometer) RF + SVM [193] Classification-Failure prediction Heterogeneous (Multiple sensors from SECOM dataset) RNN (LSTM) [194] Regression-Predicting data from sensors Heterogeneous (Different sensors [Pressure, Temperature, Vibration etc.])

Smart Infrastructure
An application within smart infrastructures also involves monitoring of civil structures for structural health.The authors in [195] take a clustering approach to perform health monitoring of a bridge using vibration data in a cloud setting.They use clustering to determine clusters of abnormal behavior in accelerometer measurements from a bridge.In [196][197][198], accelerometer signals have been used where as [199] have used piezo electric transducers for performing structural health monitoring of bridges formulated as a classification problem between different damaged states of a bridge.The prime sensing modality for monitoring has been measuring vibration using accelerometers, however, other sensors such as fiber optic gratings can also be used to measure stress.
The second avenue for AI applications in IoT for smart infrastructure is the use of IoT devices for building environment control and energy management as well comfort aware control.This involves the prediction of building energy usage based on environmental data (such as temperature, humidity) and electrical power data.The authors in [200] and [201] use electric power data and heat flow information in a building to predict the energy requirements in the future so as to better manage energy consumption.Ambience control of a museum has been performed in [202] where the authors use deep learning algorithms to predict the CO 2 and humidity levels for the care of exhibits.Comfort aware energy management has been performed in [203] where the authors use a CNN to regulate thermal comfort in a building using various physical quantities.It can be noted that all of these mentioned systems have been deployed in the cloud, this is due to the nature of the application.However, there have been efforts for developing fog/edge systems for smart infrastructure.The authors in [204] describe a framework for deploying edge and fog computing services in smart buildings and demonstrate their systems effectiveness for the case of energy management.Table 11 summarizes the use of IoT based AI in Smart Infrastructure.K-NN [199] Classification-Different damage states Homogeneous (Piezo electric sensors) DNN [196] Homogeneous (Accelerometer) CNN + RNN (LSTM) [198] SVM [197] Energy and Environment management SVM [200] Cloud Regression-Forecasting electrical power usage Heterogeneous (Power and environmental data) SAE [201] Regression-Energy predictions for buildings Homogeneous (Heat flow data in RNN (GRU, LSTM) [202] Regression-Prediction of environmental variables (CO 2 , Humidity etc.) Heterogeneous (environmental data such as CO 2 , Humidity, Air velocity) CNN [203] Regression-Comfort level

Smart Transport
Major smart transportation applications involve smart parking and transportation management.Smart parking aims to solve the problem of helping users finding parking spots in order to save time as well as reduce gas emissions and is therefore a muchresearched topic for AI deployment towards smart transportation.Solutions to this problem have been formulated both as a regression problem as well as a classification one, both utilizing imaging and/or other occupancy sensing modalities.Regression solutions [205][206][207] are typically used to predict a parking lots occupancy levels in the future whereas classification systems [208][209][210] involve guiding drivers according to the shortest distance as well as used for user localization purposes within such lots.In addition to cloud based approaches, edge computing systems for smart parking have also been devised as suggested in [211,212] who deploy CNNs on edge devices for occupancy detection and user localization, respectively.Another application of AI IoT for smart transportation involves determining traffic flow as well as prediction of traffic flow for traffic light control and other management tasks such as accident detection.In this regard, video cameras are popular for detection of vehicle density on roads for traffic congestion determination.However, with most cars having a GPS device and the commonality of cellphones with every driver, many approaches use the data from the GPS along with weather and generic traffic flow information to determine traffic prediction.The nature of traffic flow prediction using sensing modalities such as GPS require systems to be operated as cloud-based systems as is the case in [213][214][215][216].Of these, Wangyang et al. [215] and Xiao et al. [216] use deep learning based sequential modeling approaches to predict traffic flow ahead of time where as Aung & Naing [213] and Yunxiang Liu & Wu [214] solve this through a classification formulation.A traffic management system for public buses has been proposed in [32,217] where GPS data is used to predict bus arrival times for public transportation systems.Accident detection has been performed using car position and velocity information in a VANET environment by the authors of [218] in a cloud based system that can use this information to predict whether an accident has occurred or not.Apart from typical sensing modalities, with smart phones and user participation in social media, smart transportation systems are expected to increasingly include more sensing modalities [219] fused together for use in decision making for traffic management purposes.Mukherji et al. [220] use Wi-Fi signals to determine commuter traffic a subway station.They do this by using the measured signal strength of the Wi-Fi signals along with a Random Forest classifier in a cloud-based setting.Their system is able to determine if a person is on the train or on the platform which can be used to help with planning train times and routes.A summary of IoT based AI for Smart Transport has been given in Table 12.K-Means [205] Regression-Future occupancy prediction Heterogeneous (Occupancy, Location, Time) RNN (LSTM) [207] LR [206] Homogeneous (RFID data from cars) DNN+ CNN [208] Classification-Different positions based on beacons installed Homogeneous (Radio frequency signal strength) DT [209] Classification-Recommendation of parking lot based on distance Heterogeneous (Parking information, Time) CNN [211] Edge Classification-Detection of empty parking space Heterogeneous (LIDAR, Images) CNN [212] Classification-Different user locations localization Homogeneous (Bluetooth received signal strength) Transport management (Public transport management) K-Means [32] Cloud Regression-Transport delay prediction Heterogeneous (GPS, Ticket information, Time, Arrival, Departure information etc. ) K-Means [217] Regression-Arrival time prediction RF [220] Classification-Localization, as on platform or train Homogeneous (Wi-Fi signal parameters) Transport management (Traffic flow) NB [213] Cloud Classification-Different traffic states Homogeneous (GPS data, current and historical) RF [214] Heterogeneous (Weather, Road data) RNN (LSTM) [216] Regression-Traffic flow prediction Homogeneous (Traffic flow data [vehicle speed count etc.]) RNN (LSTM) [221] SAE + RNN (LSTM) [215] Transport management (Traffic Accident detection) RF [218] Classification-Accident or not Homogeneous (Velocity, Position) Artificial Intelligence is the prime enabler of Smart City service provision as it facilitates the use of the data collected in a smart city.A summary of the discussion about AI use in IoT for Smart Cities in this section as well as the observations made are summarized in Table 13.

Security and Privacy in Smart City IoT
Smart Cities involve the transmission of sensing data, control information through the internet as well as local networks.Moreover, several components in smart cities tend to critical aspects of a citys operation and are being highly intertwined with the social and private life of its citizens.Consequently, security and privacy in Smart Cities is of great importance and has been of high interest to researchers [46,[222][223][224][225][226].The topic of Security of IoT has been covered in [227] who deliberate upon the challenges faced in the different architectures of the IoT and present issues and solutions.We cover security for IoT in smart cities so as to highlight issues that are pertinent to in the Smart City context and to complete our discussion on this topic.
Smart Cities are enabled by collecting data through sensors within a city as well as its populace, process it and then mine it to provide a better quality of life to the people living.These sensors can provide an estimate about the internal state of a city's components such as transportation, power system, building condition/state, human mobility and more.All these data are sent to the cloud where it is processed and mined.However, there are several issues that pertain to how these data are sent and used and raises questions about integrity, protection and the confidentiality of this process.In fact, this concern is not unwarranted for, in 2015 an attack on the Ukranian power grid which left 225,000 people without power [228] opened the worlds eyes to the very real threat posed by cyber attackers.Data gathered in Smart City applications can be used to perform many undesired acts, GPS devices that are present in every phone and most vehicles are susceptible to providing information about a persons location, habits as well as lead to privacy issues as discussed in [225], power consumption and ambient sensor data from a building may indicate to occupancy [229] and even indicate to the individual identities [230].This information may be used by bad actors to carry out unlawful acts causing risk to life and property.
To secure the Internet of Things for Smart Cities, typical security schemes might not be as effective in many cases and new methods will need to be developed to cope with the security and privacy issues in IoT for Smart Cities.In order to provide a standardized framework and terminology for discussing security attacks, we adapt the standard attack incident taxonomy [231] suggested by the Computer Emergency Response Team (CERT) which was established by DARPA for use towards IoT for Smart Cities.This is shown in Figure 8.There are different types of security and privacy issues in IoT in Smart Cities, they exist on each of the three levels of the IoT architecture, application software layers, network layer and the perception layer along with some system issues, a discussion is provided for each of them.Furthermore, Table 14 provides a summary of the security and privacy issues in IoT for Smart Cities and the counter measures that one can take to mitigate them.
3.6.1.Application Software Layers (Middleware, Application and Business Layer) Security and privacy in the application software layers tend to issues relating to storage of data and its usage.These are data visibility, access and injection.

Data Visibility/Identification
Once data is gathered, it is sent to the cloud where it is stored and mined to make inferences.Since the cloud would be used by multiple entities with different standards of security protocols and practices, it is extremely important that data stored in the cloud is encrypted so as not to allow its exposure to unwanted entities.Any data stored in plain form would be a risk to not only user privacy but also company rapport.

Data access/Secondary Use
Access control is also a major issue in smart city data.Most Smart City applications rely on the usage of data from different applications to provide smart services, thus resulting in the gathered data to be used by many different enterprises.To allow this to take place smoothly while preserving privacy, suitable access control schemes will need to be devised to allow for responsible access to users of this data.A well-defined hierarchy of data users will need to be developed and implemented to limit access only to intended authorized personnel.Information flow control should also be employed that can track data flow as access to it is made and to detect any violation of access or usage rules.Moreover, data mashups that will occur in the cloud where multiple entities merge their data to work on some common goal, should be carried out with proper oversight.Data anonymization may also be required in such a scenario where specific values may be converted in to a range perhaps ( e.g., using k-anonymity [224]) and unwanted data be deleted as necessary.Blockchain has been suggested to be used for access control as well as access tracking of users in IoT applications where each user access to a service or an application ends up as a transaction to form the applications IoT trail [232].
Data Injection/Data Integrity Data injection refers to the injection of false information or modification information about a user in the system after gaining access.Since data is typically stored in databases, SQL injection involves an attacker inserting queries to modify data or make false data insertions into the database.This can have far reaching consequences for smart city applications such as patient record manipulation as well as manipulation or deletion of government records.SQL injection prevention schemes involve the validation of data before using it [233] such as positive pattern matching.It also involves limiting database access based on the user requirements and performing penetration testing.

Network Layer
Like other networks, the IoT in Smart Cities are also susceptible to network attacks such as Denial of service, Eavesdropping, Man in the middle attack, Side Channel and spoofing attacks [234].We discuss these attacks and discuss remedial actions that should be taken to prevent them.

Man in the Middle Attack
Man in the middle (MITM) attack refers to the interception of data on the network by faking the identity of a network node or device.This is carried out by appearing as the intended recipient to the sender and the original sender to the recipient by unauthorized actors.To prevent this, the exchange of data between two entities should employ cryptographic protocols which can ensure secure communication.Many public networks do not make use of encryption when exchanging data, this endangers user data and can give access to unwanted persons to user information [224].Policies need to be devised to allow for suitable data communication standards for such networks while keeping the user as well as commercial interests in mind.

Eavesdropping/Sniffing Attack
Eavesdropping refers to the listening of data on the network.In eavesdropping an unauthorized entity joins the network and can listen to the data that is being exchanged between the devices on the network.To avoid this, strategies include the use of authenticate always protocols which initiate authentication steps whenever devices need to communicate with each other.This will ensure that no unwanted users are allowed access to network traffic to prevent such attacks.Moreover, industry standard security protocols such as the TLS, WPA2 should be used for authenticating remote access.Furthermore, remote sessions should have time-outs implemented to ensure that mistakes are not made by forgetful employees.

Side Channel Attack
Side Channel Attacks refer to the extraction of information by observing operation characteristics of the implemented computer algorithms or systems such as power consumed, time taken, traffic analysis, fault analysis, acoustic analysis [235].Side Channel attacks don't give nonpermitted parties access to the data within the network but may allow them to determine important information about the system, such as the protocol used, or allow them to drop packets so as to degrade performance of the network.One solution to counter network traffic side channels attacks is to saturate network bandwidth to prevent patterns from being observed.Another popular method of preventing side channel attacks is to make use of masking [236].

Denial of Service Attack
Denial of Service (DOS) or Distributed DOS attacks involve an entity getting access to the network and using legitimate nodes within it to flood the target with unnecessary requests to consume network bandwidth and degrade quality of service.With a smart city depending on sensors to provide it with a 'view' of the city, DOS attacks can make the smart city system blind which can lead to loss of property and life.Countermeasures for DOS attacks involve anomaly detection by monitoring of network data to check for any irregular behavior.Artificial Intelligence has found applications in this area as noted by [237], for, e.g., it has been used to identify abnormal data in smart grids [238] as well as detecting attacks [239,240].

Spoofing Attack
In a spoofing attack, an attacker adds itself to the network by appearing to be a legitimate device on the network, thereby allowing them to send irregular or abnormal data to upset normal operation of a smart city system.Due to the varying nature and types of IoT devices having different levels of built-in security, spoofing is a particularly dangerous attack for IoT systems.Methods to prevent spoofing are the use of cryptography, hybrid encryption [241] as well as the use of blockchain [242] to validate data exchange and as well as authenticate devices.

Perception Layer
Perception layers attacks refer to physical attacks on an IoT based smart city system.This requires the physical presence of an attacker near the sensing elements in an IoT system.We cover these attacks to provide a holistic assessment of the security and privacy issues in IoT Smart Cities.Tempering and Radio Interference (jamming) are attacks which can affect the performance of smart city systems.Tempering may occur during the development or the manufacturing process while jamming can take place due to a generation of radio frequencies which interfere with the frequencies used by devices on the network to exchange data.To circumvent this, policies may be incorporated into software which alert businesses and other Smart City partners to missing or abnormal data from sensing devices.

System Wide Issues Data Leakage
Data leakage refers to the unintentional conveyance of information about subjects in smart cities.The many data sources in smart cities may contain information related to a user's identity, health, quality of life etc.Smart City application managers use this data to improve their services and provide a better user experience, however, it is possible that this data might be shared with third party entities.It is therefore necessary to anonymize data before such assignments are taken.Data leakage can also take place when devices within a network perform discovery tasks and may provide personal information to rogue nodes in the network.In Smart Grids, power consumption data should be anonymized by considering the data on a neighborhood level rather than on the individual level, moreover, systems could be installed in homes using batteries to modify the demand response signal.Data aggregation is an important tool in preserving individual privacy and preventing data leakage.Moreover, data should be encrypted when sending it over the network so that any unauthorized access is avoided.Another strategy would be to use data minimization.Typically, sensors used in smart cities will gather data of less 'interest' in addition to data of interest.For, e.g., navigation systems many times record location information even when not in use or video applications such as facial recognition systems typically record other activities apart from being activated whenever a face is observed in the video.This extra information increases the risk of data leakage.Data minimization can be employed in such cases to limit the data that is being gathered on the user.

Trustworthiness
Apart from the technical steps that need to be taken to provide a secure usage experience of smart city applications and to encourage its use, it is important that smart city users be provided clear policy guidelines to how companies providing them these services will manage their data.Transparency in this regard will help increase user trust and the feedback will enable companies to develop better data privacy mechanisms.Another way trust could be developed would be for the companies to provide customers who are vary of data collection, certain options in policies where they could choose which parts of the data collection are acceptable to them and which aren't.

SWOT Analysis
To complete this discussion, we perform a Strength Weaknesses Opportunities Threat (SWOT) analysis on the use of IoT for Smart Cities that discusses the strengths that IoT offers for Smart cities, the weaknesses in the current implementation scenario, the opportunities which exist for future work in this area as well as the threats that IoT application to smart cities faces, a summary of our discussion has been given in Table 15.IoT smart city strengths are the fact that they provide an improved quality of life for a city's population along with reduction of costs in terms of operation and also enable cities to be sustainable.IoT enables sensors and devices to be deployed throughout a city to give an overview of the state of the city's main functions such as transportation systems, electric, water and gas distribution as well as crime monitoring to name a few.This real time information helps city administration, businesses and other stakeholders to provide better services to people, increase the effectiveness of those services and reduce the cost through efficient operation.
On the technical side, IoT data has made possible to use data analytics to gauge various aspects of the multitude of services which are being provided in the city as well as to determine interactions between them and utilize that information for better decision making to make life easier for citizens.Furthermore, the distributed nature of IoT systems and the flexible architectures which enable fluidity through movement of sensing units is easily scalable thereby requiring little additional cost to upgrade and expand currently deployed systems.Moreover, this distributed architecture also makes such systems very robust to faults thereby increasing reliability of deployments and offering self-healing in applications such as electricity systems.

Weaknesses
IoT in Smart cities do suffer from some weaknesses in terms of technology, for, e.g., the current deployment scenario has a myriad of different technologies relating to networks, hardware platforms and software frameworks which do not often work together very well as discussed in the paper.Different standards' bodies such as the Internet Engineering Task Force (IETF), European Telecommunications Standards Institute (ETSI), the Institute of Electrical and Electronic Engineers (IEEE) and other organizations have been contributing with standards for communication, network discovery, identification, management of devices etc.However, the sheer number of 'standards' with many of them not being compatible with each other has not fully solved the interoperability problem and this can cause hurdles for expansion of IoT systems without a significant overhaul of system components.Another problem currently facing IoT systems is the lack of data policies and legislation.The concern here is that data policies are not mature enough to regulate how data is handled in IoT systems, as has been discussed previously.This is a major problem given the growing issue with user data privacy in a connected world.

Opportunities
IoT in Smart cities presents many opportunities to researchers and businesses alike in lieu of mitigating the weaknesses and also in the provision of new city services.The data gathered by the sensors in IoT systems has the potential to provide a holistic overview of the city's state allowing for the use of big data algorithms to develop new applications and services.For researchers in the data analytics domain, this heterogenous data provides a wonderful opportunity for the development of new data science algorithms for service delivery.There is a large monetary value towards the development and usage of computationally cheap encryption techniques, efficient data storage methods and networking technologies to make IoT deployment easier and cheaper.Development of new sensor technologies is another opportunity for researchers in IoT for smart cities.The development of newer, efficient, low-cost sensors would aid to the creation of IoT services and enable even wider usage.

Threats
With a connected system, there are several threats that come with IoTs for Smart Cities involving trust issues among users, privacy concerns due to network attacks, potential data theft etc. Privacy and security are the most important concerns of IoT applications, with such a personalized interaction mechanism between people and devices as is the case of smart cities, the risks for privacy breaches, data theft and leakages are high and this is a constant concern for service users as well as providers.Numerous attacks on Smart City systems have exposed the vulnerability of this technology to cyber attacks and also demonstrated the consequences that it has on the population.Traditional security procedures and methods such as access authentication, routing and networking might not be enough or possible in many IoT deployments due to IoT devices typically not having sufficient computing capabilities, this has exacerbated the privacy and security concerns for IoT stakeholders.This can also feed to a lack of trust by customers to participate in smart city applications.

Conclusions
This paper presents a broad coverage of the Internet of Things in Smart Cities.Providing a detailed discussion of Smart Cities and its different domains, we present IoT as a vital enabler of smart city services and discuss the various smart city architectures and the challenges that are faced in the deployment of smart city applications.We follow this up with a review of the sensing and networking technologies used for such applications and discuss the usage of AI in smart cities.For each of the applications discussed for the various components, we have deliberated upon the type of deployment based on the technologies and architectures discussed to present an overview of the current research scenario in IoT based Smart Cities.Finally, the security and privacy issues faced by IoT based Smart Cities are discussed and a SWOT analysis is provided.It is envisaged that this survey will assist researchers by providing a comprehensive starting point to the use of IoT in Smart Cities.Table 16 provides a mapping of the papers cited in this survey to the survey outline provided in Figure 1.

Future Recommendations
From the discussion in this paper, there are several suggestions that can be made when using IoT for smart city projects.A major research area is in the security and privacy of IoT in smart cities in terms of encryption techniques, authentication protocols, data anonymization techniques and other methods to prevent unvalidated access to the IoT network.As mentioned before technologies such as blockchain could help introduce access tracking and control, secure device discovery, prevention of spoofing, data loss while ensuring that end to end encryption is also used.
Of the data transfer standards developed till now for IoT, most are not compatible with each other.Work needs to be carried out in this regard to enable intercommunication of sensor nodes using different protocols while utilizing low power, which is imperative for sensor nodes in the network.
Another area to work on, is the development of efficient storage techniques and low power hardware which can reduce operational costs.From a deployment perspective, decentralized systems have been proposed as the best solutions to increase reliability of the application.Techniques such as federated learning allow for decentralized DL system deployments.
The area of AI has a large scope for potential work too.This includes the development of data fusion techniques that can make the use of heterogeneous data sources easier, intelligent data reduction/feature selection methods to ensure that redundant or 'uninteresting' data is not part of the AI development pipeline.This will help in a quicker turnaround time as well as improved performance of deployments.Current methods need to be used as well as new ones be researched for making ML and DL algorithms more explainable to suit the various applications in a smart city.

Figure 1 .
Figure 1. Outline of the survey paper.

Figure 4 .
Figure 4. Challenges for IoT in Smart Cities.

Figure 6 .
Figure 6.Network Technologies for IoT Smart Cities.
data control policies -Improved quality of life -Laws need to be developed -Efficient city operations -Interoperability of networks -Well suited for big data algorithms -Incompatible sensor standards -Scalability of applications -Myriad of different application frameworks -Real-time/fast response due to distributed IoT structure -Reduced costs -Robustness -Enable heterogenous system connectivity Opportunities Threats External -Development of new sensor technologies.Trustworthiness issues among users -Development of low power and higher speed communication schemes -Network attacks -Development of Encryption techniques for storage and data exchange -Data theft -Development of Data processing for privacy preservation techniques -Data leakage -Development of new city services -Development of scalable, explainable AI 4.1.Strengths

Table 1 .
Comparison of Cloud, Fog and Edge Computing Models.
Farthest away from the edge and therefore decision making can be slow and latency is high Being the closest unit to the edge, the Fog layer can respond much more quickly to the data being sent from sensors and other devices, as it can aggregate the information sent Quickest decision making possible; however, decisions will be based on local states

Table 2 .
Smart City IoT Challenges and Mitigation.
[10,47,52]Memory: Energy harvesting, Low power sensors, New database storage systemsNetworkingLow power networks, Network schemes that ensure fluent mobility and routing[40,47]Big data analytics New algorithms which work with different natured data, Develop scalable and explainable AI[10,47,52] presents a summary of the sensors used in each smart city component.

Table 3 .
Sensing Technologies for IoT Smart Cities by Smart City Component.

Table 4 .
Comparison of Network Technologies for IoT Smart Cities.

Table 5 .
AI use for Smart Agriculture

Table 6 .
AI use for Smart city Services.

Table 7 .
AI use for Smart Energy.

Table 8 .
AI use for Smart Health.

Table 9 .
AI use for Smart Homes.

Table 10 .
AI use for Smart Industry.

Table 11 .
AI use for Smart Infrastructure

Table 13 .
AI applications for IoT Smart Cities.

Table 14 .
Security and Privacy issue for IoT Smart Cities.

Table 15 .
SWOT Analysis for IoT in Smart Cities.

Table 16 .
Mapping of Survey Sections to References.