## 1 Introduction  
A smart campus is an infrastructure similar to a smart city that makes use of Internet of Things (IoT) solutions [1; 2; 3; 4; 5; 6] to connect, monitor, control, optimize, and automate the systems of a university. Today, a smart campus represents a challenging scenario for IoT networks, especially in terms cost, coverage, availability, latency, security, power consumption, and scalability. The area covered by a campus varies substantially depending on the university, its location, the financial endowment, and the year of founding. For example, Berry College (Floyd County, Georgia, United States), is often considered the largest contiguous rural campus in the world: it covers 27,000 acres (109.26 km\({}^{2}\)) [7] of land. Other examples are the suburban/urban campuses of Duke University (Durham, NC, USA), which are deployed on 9350 acres (37.83 km\({}^{2}\)) [8], and the campus of Stanford University (Stanford, CA, USA), which covers 8180 acres (33 km\({}^{2}\)) [9]. Regardless of their initial surface area, it is common that campuses grow considerably as time goes by [10], hence institutions usually devise long-term sustainability plans to envision their growth in the future [11; 12; 13]. When a campus provides smart IoT services, it is necessary to provide communications connectivity to IoT nodes and gateways. Such a connectivity can be provided in a quite straightforward way indoors thanks to the use of popular technologies such as Wi-Fi, but, outdoors, technology selection becomes more complex, since it is not only necessary to provide good coverage and a cost-effective deployment, but also to decrease the communications energy consumption to maximize IoT node battery life. To tackle such an issue in wide areas, a set of technologies grouped under the term Low-Power Wide Area Network (LPWAN) seem to be a good selection, since, in comparison to other previous technologies, they provide a wider area communications range and reduced energy consumption. In fact, LPWAN technologies have emerged as an enabling technology for IoT and Machine-to-Machine (M2M) communications [14] mainly due to their capabilities related to range, cost, power consumption, and capacity. Examples of such technologies are NB-IoT [15], SigFox [16], Ingenu [17], Weightless [18] or LoRaWAN [19] (a detailed comparison of these and other LPWAN technologies is given later in Section 2.2). In the case of LoRaWAN, it is gaining momentum from both industry and academia [20; 21; 22]. LoRaWAN defines a communications protocol and a system architecture for the network. In addition, it uses LoRa for its physical layer [23], which is able to create long-range communications links and makes use of a Chirp Spread Spectrum (CSS) modulation that conserves the power features of Frequency Shifting Keying (FSK) while increasing its communications range. All these features make LoRaWAN a good candidate for providing wireless communications to outdoor IoT nodes in a smart campus. Traditionally, gateways connect the IoT nodes with the cloud and among them. The cloud is basically one or more servers with large computational power, communication, and storing capabilities that receives, processes, and analyzes the data collected from the IoT nodes by performing computational-intensive tasks. Although cloud-based solutions are appropriate at a small scale, when the number of IoT nodes grows significantly and, consequently, the network traffic they generate, congestion may lead to increasing latency responses and slower data processing. Among the different alternatives to confront this challenge and to guarantee a flexible, scalable, robust, secure, and energy-efficient deployment of IoT networks, the design and implementation of a fog computing architecture was chosen.