Monitoring the Health and Residence Conditions of Elderly People, Using LoRa and The Things Network

: The rapid development and widespread use of information and telecommunication technologies do not mitigate, in many situations, information exclusion, nor the physical isolation of people—mainly that of the elderly living in remote locations, whose mobile network coverage is deﬁ-cient or non-existent, preventing them from accessing health care, be it routine follow-up procedures or emergencies. Addressing this, we raise the question that guides our study: how can we monitor the elderly’s residence and health conditions, detect falls, and track their movement in the vicinity of their homes in a non-intrusive manner? To answer this question, we present a system prototype that uses affordable, low-cost, and low-energy equipment with media and data processing, supported by LoRa (Long Range) and ESP32 microcontrollers, coupling several sensors. As a result, it is possible to monitor sensors that predict and detect falls or other risk events for the user, e.g., ﬁre, with authorized persons and entities, family members, civil protection, and security forces accessing the gathered data, assuring their security. We conclude that the system could decisively improve people’s quality of life, particularly those of the elderly who live in remote places with greater vulnerability.


Introduction
The Internet of Things (IoT) is currently present in several domestic systems, be it in small devices for regular use, such as a blood pressure meter, or in more extensive equipment, namely, photovoltaic panels for energy production, household appliances, consumption, and energy efficiency controllers, among others [1]. The remote monitoring of people's health and physical conditions is one area that has benefited the most from this type of technology. It involves the use of miniaturized, non-intrusive, and pervasive devices, which go unnoticed most of the time and transmit and adapt their behavior according to the user's needs [2].
IoT terminology, which refers directly to systems permanently linked to communication networks, has revolutionized the way we use different technologies, enabling varied uses depending on the socio-economic conditions of populations and their digital literacy [3]. Today, we can connect heterogeneous devices, e.g., smartphones with a mobile network (3G/4G and, in the future, 5G), Bluetooth devices, wireless networks, and sensors, among others. It enables interaction between these various devices and creating synergistic technological systems, which improve people's quality of life. However, many populations and individuals, particularly the elderly, are prevented from taking advantage of this technological development, especially those living in small towns or isolated dwellings without families or continued institutional support.
Nevertheless, recent studies have shown that the world population that currently suffers or is likely to develop mental pathologies is growing exponentially. Therefore, it is urgent to associate and put the various communication and information technologies at the service of people, minimizing the negative impact that these pathologies have on their quality of life [4,5]. Based on this reality, the question arising as the starting point of the present work is the following: how can we monitor the health status of the elderly, detecting falls and monitoring their movement in the vicinity of their homes in a non-intrusive way?
Using concepts already framed by other monitoring and follow-up environments based on miniaturized sensors and telecommunications equipment, we present a system model solution involving several actors, families, the security forces, and social solidarity institutions. This monitoring and protection system model for the elderly is named IS4HMET-Information System for Home Monitoring and Elderly Tracking. It is targeted to populations without physical and mental disabilities residing in isolated or low-density communities, providing them with autonomy inside and outside their homes. Additionally, it should be noted that the inhabitants of rural areas still maintain their food gardens near the house, in areas without mobile communications signal coverage, or with a weak signal, as shown by the Portuguese National Communications Authority [6].
Coincidentally, there is a dispersed population with poor accessibility in these regions of Portugal that are currently installed the largest wind farms dedicated to energy production, particularly in the Caramulo mountain. The inclusion of entities related to these infrastructures in strategic partnerships will be enriched in the future, whether due to social responsibility or the installed technology. They can lend a decisive contribution since these infrastructures are monitored in real time, maintaining a permanent connection to the internet, either by satellite or mobile communications [7,8]. This social responsibility must be practical and serve the most affected populations with the installation of wind farms, as stated by Álvaro Pinto, president of the company responsible for managing the Caramulo wind farm. Looking ahead with an entrepreneurial and innovative spirit, he adopts the concern of contributing to a more sustainable future through the integration of the legitimate desires of the communities in which it operates with respect for the environment [9].
Therefore, we have set as the primary response to the question posed, to monitor, using information and communication technologies, the health status of elderly adults while moving within their homes and peripheries, living in areas away from urban centers. In this way, support institutions, family members, support teams, or other entities can follow and monitor, almost in real time, the state of health of these people. Furthermore, as the systems geared to monitoring and managing people's data are undergoing significant evolution, we hope to improve the quality of life of people, particularly the low-income elderly population. To do that, we propose using the LoRa (Long Range) communication networks and their interconnection to The Things Network (TTN). TTN is an open Internet of Things infrastructure supported by a global ecosystem of thousands of developers, IT integrators, hardware manufacturers, universities, and governments, supported by LoRaWAN, the secure messaging protocol, etc. [10]. On the TTN, we have registered a test application Available online [10].
Given the use of the proposed technology and system, which proves viable, we intend to establish a protocol with a private entity operating in the telecommunications area. We already have a partnership for a possible implementation of the supporting infrastructure. Of course, this entails the reorganization and redefinition of the electronic components. Thus, they become more adapted to real-life conditions, miniaturizing all the equipment used by the elderly in a non-invasive and non-intrusive way. Our focus is on validation, testing and complete development, and some machine learning models.
In addition to the introduction, the remainder of this paper is organized as follows. In the Section 2, we address studies developed in this area that we consider to be relevant. Next, we show the research and development method in the Section 3 and present the system support data model. Section 4 covers the materials and methods of system development, including the description of components, development boards and their characteristics, and the connectivity scheme of the developed models. The Section 5 discusses the results and shows how a machine learning model can detect abnormal events, using accelerometer data, quickly and in a simplified manner. Finally, Section 6 concludes the article.

Related Work
Several studies have been carried out in recent years on the use of low consumption and long-distance communication networks, mainly in the context of home automation [11,12] and agro-industrial applications [13], using LoRa networks and other similar technologies, namely SigFox [14], NB-IoT [15], LTE-M [16], and TV Whitespace [17], among others.
LoRa communication technology enables the interconnection of several-thousandbatteries-powered devices over long distances with reduced power consumption. The LoRa technology takes part in the LPWAN (Low Power Wide Area Network) group, particularly LoRaWAN, allowing communication over long distances, even in adverse conditions, with 15 km in open space or 7 km in urban areas [18]. Furthermore, low power consumption is essential in devices intended to be used for an extended time on a battery. LoRa technology uses the unlicensed frequency band, with 868 MHz in Europe, 915 MHz in North America, and 433 MHz in Asia [19]. The basic architecture of the LoRaWAN network is composed of several nodes (devices) and Gateways that can be connected to The Things Network (TTN). In addition, the data are stored in the cloud and later made available on interface platforms. These platforms contain dashboards that enable the interaction and availability of data on other platforms, using REST web services and access platforms by MQTT (Message Queuing Telemetry Transport), e.g., Node-RED. Figure 1 shows a Node-RED connection to the prototype system developed, using an MQTT Input object to obtain data from the apptesttemp application created in TTN. Node-RED is an IoT application development framework based on streams of visual programming initially developed by IBM to connect hardware devices, APIs, and online services [20].
In Node-RED, an MQTT Input is in a node that reads the submitted data to the TTN in real time, as shown in Figure 1, and one such node is connected to the apptesttemp application and lorattgo1_teste device. Thus, whenever data are submitted, their values can be analyzed in real time in the debug window or the dashboard application. Furthermore, the nodes are connected by flows, where the terminal nodes output can be a graphical representation, data in text, or registered in a database.
The authors of [21,22] present models of low-consumption and long-range networks for homes and industry automation, respectively, using LoRa (Long Range) communication technologies. These communication networks are essential if data are to be disseminated and analyzed, without necessarily resorting to the internet, collecting data from various sensors, and maintaining their activity for an extended time. As a result, the consumption of devices and sensors is reduced.
In work [23], the authors have evidenced the potentialities to monitor wind farms, using the LoRa and LoRaWAN (Long-range Wide Area Network) networks. The authors have shown that the use of LoRa networks allows efficient communication over long distances when monitoring non-critical situations. In addition, the connection to an external IoT platform produces some delay, and its use for real-time monitoring is somewhat compromised. In Node-RED, an MQTT Input is in a node that reads the submitted data to the TTN in real time, as shown in Figure 1, and one such node is connected to the apptesttemp application and lorattgo1_teste device. Thus, whenever data are submitted, their values can be analyzed in real time in the debug window or the dashboard application. Furthermore, the nodes are connected by flows, where the terminal nodes output can be a graphical representation, data in text, or registered in a database.
The authors of [21,22] present models of low-consumption and long-range networks for homes and industry automation, respectively, using LoRa (Long Range) communication technologies. These communication networks are essential if data are to be disseminated and analyzed, without necessarily resorting to the internet, collecting data from various sensors, and maintaining their activity for an extended time. As a result, the consumption of devices and sensors is reduced.
In work [23], the authors have evidenced the potentialities to monitor wind farms, using the LoRa and LoRaWAN (Long-range Wide Area Network) networks. The authors have shown that the use of LoRa networks allows efficient communication over long distances when monitoring non-critical situations. In addition, the connection to an external IoT platform produces some delay, and its use for real-time monitoring is somewhat compromised.
Work [24] proposes an advanced architecture, combining Edge computing, Fog computing, LoRa, and other IoT-based technologies to monitor patients in hospital settings. The proposed architecture can help overcome the limitations of existing IoT-based physical integrity monitoring systems, e.g., in detecting falls, evidencing the functionality of the architecture for this purpose.
In the context of smart cities-an area in which LoRa communications know a significant space of use-the authors of [25] show the efficient way to monitor urban buses, using the LoRa and LoRaWAN networks to estimate, in real time, the approach of the bus to the stop, allowing a global GPS view of the movement of the vehicles in their fleet. Work [24] proposes an advanced architecture, combining Edge computing, Fog computing, LoRa, and other IoT-based technologies to monitor patients in hospital settings. The proposed architecture can help overcome the limitations of existing IoT-based physical integrity monitoring systems, e.g., in detecting falls, evidencing the functionality of the architecture for this purpose.
In the context of smart cities-an area in which LoRa communications know a significant space of use-the authors of [25] show the efficient way to monitor urban buses, using the LoRa and LoRaWAN networks to estimate, in real time, the approach of the bus to the stop, allowing a global GPS view of the movement of the vehicles in their fleet.

Research Method
Portable sensors, such as the accelerometer, small in size, with low energy consumption, and with high precision, have been used in many tests in individuals with diseases that restrict their mobility, allowing to validate, in real time, the occurrence of falls [26]. Several authors have been working with these and other sensors, showing the advantage of using these small devices in tracking and monitoring people. One of the main problems affecting the elderly is the incidence of falls leading to their disability due to fractures. Aziz and Robinovitch [27] and Lustrek et al. [28] showed that the use of accelerometers made it possible to determine the cause of a fall through machine learning algorithms, exploring a hitherto under-worked strand, mainly in the field of adult monitoring. More recently, Shany et al. [29] showed that portable sensors have enormous potential to monitor people's movements and analyze the incidence of falls.
The current mobile communication devices, which we call smartphones, have several built-in sensors, including an accelerometer, gyroscope, and GPS, to mention a few. However, they are challenging to operate by the elderly population, who are unaccustomed to using this type of technology, sometimes with significant physical limitations, as reported by Vaportzis et al. [30]. Thus, we propose exploring and enhancing the use of these sensors, integrating them into a solution to monitor, in real-time, the movement of older people and their state of health, within and outside the home, with sensors incorporated in pervasive, non-intrusive devices.
Some authors have proven that the ESP32 microcontroller associated with the LoRa transceiver is suitable and adds LoRa and LoRaWAN protocol support. It is needed to act as Gateway for The Things Network [31], but also the Dragino Gateway LG01 could be used [32], which is more versatile and has many connection types, such as Wi-Fi, Ethernet, and 3G/4G. Another ESP32 module with LoRa support that includes GPS may be used in outdoor environments [33].
The low-cost ADXL335 accelerometer sensor [34] is ESP32 compatible and can be included for fall detection and systems driven by anomalous motion detection.
The body temperature [35], body humidity [36], and pulsation [37] sensors can be interconnected with the ESP32 microcontroller to control vital signs.

Data Model
From an application point of view, monitoring should occur in an environment controlled by official and authorized entities, including police and civil protection authorities. Therefore, it is necessary to have a database-supported system that allows real-time analysis of the data obtained and recorded in history. Figure 2 shows the conceptual schema of the database proposed for the IS4HMET system, which consists of several relations that allow obtaining the data through the TTN network, guaranteeing access only to authorized persons. In addition, the database will allow storing a history of the operations performed on the database, maintaining an ACL (Access Control List) for each type of user.  Table 1 presents the system tables and relationships in a simplified version, which is in response to the system requirements.   Table 1 presents the system tables and relationships in a simplified version, which is in response to the system requirements. Table 1. Data model relationships.

System_User
The user who will have a specific type of access, reserved to security forces, family, or other entities, who will have access via a web application or mobile app UserACL List of operations allowed to each user ttn_Administrator The list that allows registering the data of the service administrator connected to the TTN for system administration purposes ttn_Gateway The operationalization of the system comprises several phases of implementation. The first phase concerns the definition of strategic sites for establishing Gateways, which will serve the populations and inhabitants of isolated agricultural regions and are essential to make the system effective. The next phase involves installing a pilot project consisting of a functional prototype, residential or personal, which allows assessing the quality of the service and the usability characteristics of the system. Finally, it is a fundamental step to invest in a solution that can increase the quality of life of the elderly population in isolated regions, where they are deprived of communication services or where mobile network coverage is deficient.
The following phases include in the pilot project the various entities that constitute interest groups, namely municipalities and companies with installed technological capacity (e.g., wind farms). In addition, it could create synergies with isolated populations and other local entities, such as fire brigades and security forces.

Application Scenario
In the example of application in the Caramulo mountain, we considered installing a LoRaWAN Gateway connected to the TTN in the residence in the nearest locality, which receives data from the LoRa nodes, dispersed and isolated.
Additionally, technological capacity installed in mountainous regions, mainly to produce wind energy, becomes an added value to the wind farms located in remote and isolated areas and parks with power generation towers, allowing Gateways to be installed with an internet connection. In the case of the mountainous region of Caramulo, here as a pilot project, this capacity is quite significant, being established in it one of the largest wind farms in Portugal ( Figure 3). The system consists of a web application that supports data management and incorporates an interactive dashboard that allows administrators to manage data and monitor system messages.
The application set of support for the elderly monitoring and follow-up system includes several modules, namely the following: • Data collection module for personal use, composed of an ESP32/LoRa microcontroller with the sensors specified above.

•
Housing status data collection module, comprising an ESP32/LoRa microcontroller with environmental sensors (temperature, humidity, carbon monoxide, gas, and smoke).
The LoRa Gateway is connected to the internet with an established connection to the TTN, receiving from the LoRa nodes the periodically sent data. As for LoRa nodes, they are divided into two distinct types, home and individual nodes, as shown in Figure 4. The system consists of a web application that supports data management and incorporates an interactive dashboard that allows administrators to manage data and monitor system messages.
The application set of support for the elderly monitoring and follow-up system includes several modules, namely the following: • Data collection module for personal use, composed of an ESP32/LoRa microcontroller with the sensors specified above.

•
Housing status data collection module, comprising an ESP32/LoRa microcontroller with environmental sensors (temperature, humidity, carbon monoxide, gas, and smoke).
The LoRa Gateway is connected to the internet with an established connection to the TTN, receiving from the LoRa nodes the periodically sent data. As for LoRa nodes, they are divided into two distinct types, home and individual nodes, as shown in Figure 4.

Proof-of-Concept
A survey of the material and equipment was carried out to test the model. Then, from the operational point of view, a single-channel LoRa Gateway was installed. Finally, a prototype was built, which functions as a LoRa node, composed of several sensors and equipment.

Proof-of-Concept
A survey of the material and equipment was carried out to test the model. Then, from the operational point of view, a single-channel LoRa Gateway was installed. Finally, a prototype was built, which functions as a LoRa node, composed of several sensors and equipment.
The LoRa Gateway comprises the following:  The TTGO ESP32 card comes prepared with an OLED screen and incorporates Wi-Fi, Bluetooth, and the LoRa transceiver, having the working frequency set to 868 MHz, which is the free spectrum frequency in Europe. Furthermore, using the DHT22 sensor is efficient because it allows the reading of temperature and humidity, requiring a small circuit to adjust its connections.
The SIM808 is a powerful device that incorporates Wi-Fi, GSM, and GPS, albeit of reduced dimensions. The main features of the SIM808 are as follows [39]:  The TTGO ESP32 card comes prepared with an OLED screen and incorporates Wi-Fi, Bluetooth, and the LoRa transceiver, having the working frequency set to 868 MHz, which is the free spectrum frequency in Europe. Furthermore, using the DHT22 sensor is efficient because it allows the reading of temperature and humidity, requiring a small circuit to adjust its connections.
The SIM808 is a powerful device that incorporates Wi-Fi, GSM, and GPS, albeit of reduced dimensions. The main features of the SIM808 are as follows [39]: The SIM808 prototyping plate has to be powered externally, requiring a complementary power source. As the highest power from the ESP32 is 5 V, it is necessary to correct the voltage so that it is between 3.4 V and 4.4 V, so the implemented circuit adjusts the voltage to 3.7 V ( Figure 5). In this way, we only need a battery as a power supply for the whole circuit. With this equipment, it is possible to obtain the GPS coordinates in real time, programmed to interconnect with the ESP32. Low energy consumption is critical, as the system should be as economical as possible. The GPRS connection functionality is still quite relevant in this device. However, all the work is thought of for regions where the mobile network signal does not exist or is very low. Thus, it is possible to program it so that, if a GPRS network exists, in an emergency, a risk situation warning mechanism may be triggered, using the mobile network. This way, an SMS message, which requires few communication resources, with the description of the risk event and the GPS location can be sent. This functionality was not implemented, being reserved for the future since it requires a telecommunications plan from an operator. The Bluetooth functionality was not used in this equipment because it is not part of the requirements.
The ADXL335 is a high sensitivity 3-axis (x, y, z) accelerometer, which allows real-time analysis of the object's position carrying it and is calibrated in the first use. After calibration, the mapping and adjustment to the Cayenne LPP format used is performed.

System Concept and Prototype
The prototype was built to test the proposed system as shown in Figure 6. We can observe the temperature, humidity, GPS location displayed on the screen, and the distance to the residence. In addition, the accelerometer data are also collected.

System Concept and Prototype
The prototype was built to test the proposed system as shown in Figure 6. We can observe the temperature, humidity, GPS location displayed on the screen, and the distance to the residence. In addition, the accelerometer data are also collected.
Naturally, the prototype in Figure 6 is not usable by an older adult as it is, with the prototyping boards requiring careful development and miniaturization work to avoid unnecessary energy consumption. However, it is the next step in technology transfer to a company interested in marketing the product. It is not our primary goal, so our focus is on demonstrating the capabilities of the components used and the software developed to achieve the goals. The collected data are sent via LoRa communication to the Gateway and the TTN. Data received by TTN do not remain on the system unless a Data Integration is configured. To store the data, we can set up a Data Integration connection on the TTN in a Data Storage account, which allows data to be stored temporarily for seven days in the free version. To have further access to the data, The Things Network access key authorization must be set to make queries to the storage system. The result is obtained in JSON format. For the data to be entered into the database developed to support the system, it is necessary to extract and convert the relevant data and subsequently insert them into the appropriate tables. Figure 7 shows the data obtained in the query executed over the Data Storage database, integrated with TTN. Naturally, the prototype in Figure 6 is not usable by an older adult as it is, with the prototyping boards requiring careful development and miniaturization work to avoid unnecessary energy consumption. However, it is the next step in technology transfer to a company interested in marketing the product. It is not our primary goal, so our focus is on demonstrating the capabilities of the components used and the software developed to achieve the goals.
The collected data are sent via LoRa communication to the Gateway and the TTN. Data received by TTN do not remain on the system unless a Data Integration is configured.
To store the data, we can set up a Data Integration connection on the TTN in a Data Storage account, which allows data to be stored temporarily for seven days in the free version. To have further access to the data, The Things Network access key authorization must be set to make queries to the storage system. The result is obtained in JSON format. For the data to be entered into the database developed to support the system, it is necessary to extract and convert the relevant data and subsequently insert them into the appropriate tables. Figure 7 shows the data obtained in the query executed over the Data Storage database, integrated with TTN. From this API (Application Program Interface), we can obtain the data in other applications by programming the connection to the database, periodically executing triggers to the database query to populate the global database for each user and each device.

Discussion and Results
The use of devices to monitor people using low-cost and long-range technology, including LoRa networks, as demonstrated here, allows specific sensors to be used for data collection and eventually the detection of abnormal events by users in their homes. Several authors have studied the use of these sensors. Still, we focused our attention on the security issues of the elderly in remote areas-places where mobile networks do not exist or have low coverage. This presents a solution that may use, for the benefit of affected populations, the technological potential installed in wind farms, making use of the internet connection for the LoRa Gateway connection, thereby ensuring the coverage of this type of communication network.
One of the sensors that we believe to be of great relevance, as mentioned in the chapter on materials and methods, is the accelerometer, which allows detecting falls or other events related to sudden movements. Thus, to analyze the accuracy of the ADXL335 sensor used, we performed the statistical analysis of the data obtained. A predictive algorithm was subsequently applied to predict, based on historical data, when an abnormal event of user positioning (for example, a fall) may occur.
To demonstrate that it is possible to apply machine learning techniques to the collected data, we created a model that we tested with a data set. The model is not robust enough to be used in a real context, but it serves as a proof of concept. It is possible to develop models with greater and better precision, drastically reducing the possibility of the occurrence of false positives and false negatives.
Training data were collected in a way that corresponds to the normal upright position From this API (Application Program Interface), we can obtain the data in other applications by programming the connection to the database, periodically executing triggers to the database query to populate the global database for each user and each device.

Discussion and Results
The use of devices to monitor people using low-cost and long-range technology, including LoRa networks, as demonstrated here, allows specific sensors to be used for data collection and eventually the detection of abnormal events by users in their homes. Several authors have studied the use of these sensors. Still, we focused our attention on the security issues of the elderly in remote areas-places where mobile networks do not exist or have low coverage. This presents a solution that may use, for the benefit of affected populations, the technological potential installed in wind farms, making use of the internet connection for the LoRa Gateway connection, thereby ensuring the coverage of this type of communication network.
One of the sensors that we believe to be of great relevance, as mentioned in the chapter on materials and methods, is the accelerometer, which allows detecting falls or other events related to sudden movements. Thus, to analyze the accuracy of the ADXL335 sensor used, we performed the statistical analysis of the data obtained. A predictive algorithm was subsequently applied to predict, based on historical data, when an abnormal event of user positioning (for example, a fall) may occur.
To demonstrate that it is possible to apply machine learning techniques to the collected data, we created a model that we tested with a data set. The model is not robust enough to be used in a real context, but it serves as a proof of concept. It is possible to develop models with greater and better precision, drastically reducing the possibility of the occurrence of false positives and false negatives.
Training data were collected in a way that corresponds to the normal upright position of the human body. First, the accelerometer was calibrated, using the sketch provided by the ADXL335 programming library, detecting the maximum and minimum values for each axis. Subsequently, the accelerometer was moved to simulate human walking in various directions, and the minimum and maximum limit values were determined for the three axes. They correspond to the possible positions of the body and are classified as "Normal position", "Fallen back", "Fallen front", "Fallen to the right", "Fallen to the left".
As for the test data, the accelerometer within the prototype inside a duly stowed backpack and pre-defined courses were followed with different falls simulations. Then, the obtained data were classified, and the column concerning the class was removed. In this way, we were able to correctly know which data corresponded to the respective category.

Predictive Model
The WEKA software [40] was used to create the predictive model for detecting user position, including falls. This software was used to develop predictive models, being relatively easy, intuitive to use, and proven to be robust and reliable in determining predictive models, using data mining.
The algorithm that best fit the study's objectives was the J48 (J48 is an open-source Java implementation of the C4.5), an algorithm of decision trees. The data obtained directly from the accelerometer represent integer values between a maximum (positive) and a minimum (negative) value for the x, y, and z axes, which generally require prior calibration as explained previously. However, the CayenneLPP format present in the TTN uses these values divided by one thousand. Therefore, in terms of database data representation, it is performed on the values obtained by TTN. Concerning the obtained values and because the decision process is carried out on the integer values processed in the MCU ESP32, the predictive model is received on this order of magnitude and not on the values divided by one thousand. The list of data prepared for the creation of the model is shown in Figure 8. three axes. They correspond to the possible positions of the body and are classified as "Normal position", "Fallen back", "Fallen front", "Fallen to the right", "Fallen to the left". As for the test data, the accelerometer within the prototype inside a duly stowed backpack and pre-defined courses were followed with different falls simulations. Then, the obtained data were classified, and the column concerning the class was removed. In this way, we were able to correctly know which data corresponded to the respective category.

Predictive Model
The WEKA software [40] was used to create the predictive model for detecting user position, including falls. This software was used to develop predictive models, being relatively easy, intuitive to use, and proven to be robust and reliable in determining predictive models, using data mining.
The algorithm that best fit the study's objectives was the J48 (J48 is an open-source Java implementation of the C4.5), an algorithm of decision trees. The data obtained directly from the accelerometer represent integer values between a maximum (positive) and a minimum (negative) value for the x, y, and z axes, which generally require prior calibration as explained previously. However, the CayenneLPP format present in the TTN uses these values divided by one thousand. Therefore, in terms of database data representation, it is performed on the values obtained by TTN. Concerning the obtained values and because the decision process is carried out on the integer values processed in the MCU ESP32, the predictive model is received on this order of magnitude and not on the values divided by one thousand. The list of data prepared for the creation of the model is shown in Figure 8. For creating the training model, 2066 occurrences of readings of the direct accelerometer data applied in the prototype were used. Some rules were established initially, particularly the fact that the vertical position is represented by negative values close to the minimum and is naturally dependent on the position of the sensor in the electronic circuit.
The application of algorithm J48 after parameterization to maximize effectiveness produced the following decision tree model (Figure 9). For creating the training model, 2066 occurrences of readings of the direct accelerometer data applied in the prototype were used. Some rules were established initially, particularly the fact that the vertical position is represented by negative values close to the minimum and is naturally dependent on the position of the sensor in the electronic circuit.
The application of algorithm J48 after parameterization to maximize effectiveness produced the following decision tree model (Figure 9). To measure the accuracy of the model obtained, we can consider the statistical data obtained on the values of the training sample, whose separation between test and training To measure the accuracy of the model obtained, we can consider the statistical data obtained on the values of the training sample, whose separation between test and training was 50% ( Figure 10) with an accuracy of 99.73%, which is very relevant from the point of view of benchmarking and validating the model. was 50% ( Figure 10) with an accuracy of 99.73%, which is very relevant from the point of view of benchmarking and validating the model. Another tool that allows us to assess and validate the model is the confusion matrix ( Figure 11). The confusion matrix shows that all expected normal (vertical) position occurrences were correctly classified, with only three cases incorrectly classified, which is not very significant. Thus, it can be said that the model is quite well adjusted to reality. Later, the decision tree model was applied to a test group, with the unknown classification variable (represented by the symbol "?" in Figure 12), and very consistent results were obtained. Another tool that allows us to assess and validate the model is the confusion matrix ( Figure 11).
Electronics 2021, 10, x FOR PEER REVIEW 15 of 19 was 50% ( Figure 10) with an accuracy of 99.73%, which is very relevant from the point of view of benchmarking and validating the model. Another tool that allows us to assess and validate the model is the confusion matrix ( Figure 11). The confusion matrix shows that all expected normal (vertical) position occurrences were correctly classified, with only three cases incorrectly classified, which is not very significant. Thus, it can be said that the model is quite well adjusted to reality. Later, the decision tree model was applied to a test group, with the unknown classification variable (represented by the symbol "?" in Figure 12), and very consistent results were obtained. The confusion matrix shows that all expected normal (vertical) position occurrences were correctly classified, with only three cases incorrectly classified, which is not very significant. Thus, it can be said that the model is quite well adjusted to reality. Later, the decision tree model was applied to a test group, with the unknown classification variable (represented by the symbol "?" in Figure 12), and very consistent results were obtained.

Testing Data with the Predictive Model
After obtaining the predictive model, we can assess the accuracy with actual test data. For example, in Figure 13, we can observe part of the result of the model on the test data in which the classification is unknown at the outset, showing the precision obtained by the application of the predictive model. Most of the results are accurate between 99.9% and 100%, so the model is consistent with the actual data obtained. As a result, we can state that positioning sensors, such as the accelerometer, effectively detect the falls of people. Furthermore, its association with the GPS (SIM 808) and temperature sensors, among others, can contribute to improving the quality of life of people living in remote areas where there is no mobile network coverage. The combination of LoRa networks overcomes this lack of mobile network coverage, so the use of strategically placed Gateways can ensure complete coverage of those regions. Furthermore, it keeps people connected to the central system, which will be in Figure 12. Sample of the test data file.

Testing Data with the Predictive Model
After obtaining the predictive model, we can assess the accuracy with actual test data. For example, in Figure 13, we can observe part of the result of the model on the test data in which the classification is unknown at the outset, showing the precision obtained by the application of the predictive model.

Testing Data with the Predictive Model
After obtaining the predictive model, we can assess the accuracy with actual test data. For example, in Figure 13, we can observe part of the result of the model on the test data in which the classification is unknown at the outset, showing the precision obtained by the application of the predictive model. Most of the results are accurate between 99.9% and 100%, so the model is consistent with the actual data obtained. As a result, we can state that positioning sensors, such as the accelerometer, effectively detect the falls of people. Furthermore, its association with the GPS (SIM 808) and temperature sensors, among others, can contribute to improving the quality of life of people living in remote areas where there is no mobile network coverage. The combination of LoRa networks overcomes this lack of mobile network coverage, so the use of strategically placed Gateways can ensure complete coverage of those regions. Furthermore, it keeps people connected to the central system, which will be in Most of the results are accurate between 99.9% and 100%, so the model is consistent with the actual data obtained. As a result, we can state that positioning sensors, such as the accelerometer, effectively detect the falls of people. Furthermore, its association with the GPS (SIM 808) and temperature sensors, among others, can contribute to improving the quality of life of people living in remote areas where there is no mobile network coverage. The combination of LoRa networks overcomes this lack of mobile network coverage, so the use of strategically placed Gateways can ensure complete coverage of those regions. Furthermore, it keeps people connected to the central system, which will be in operation with authorized entities for that purpose, namely, security forces, fire brigades, and families.
It should be noted that the SIM808 has an interface for a mobile SIM card. Thus, the system presented here is perfectly viable and functional when the current mobile network (2G/3G/4G) can be used. In addition, it can be used in LTE-M and NB-IoT technology (standard to be integrated into 5G), where mobile networks are used for communications, using low resources, even in low coverage locations. However, they always require a paid mobile communications plan, with increased costs for the user.

Limitations
The system was placed in a backpack and transported on some previously defined routes. It was tested by placing the equipment in this position for some time. The only position that was not tested with the prototype in the backpack was the fall backward, for obvious safety reasons. We fully understand that the prototype is not as robust as a consumer-grade product. Still, to demonstrate the approach's feasibility, we strongly argue that such a prototype serves its purpose.
This limitation forced us to reuse the prototyping boards that we have available, which are much larger than what would be necessary, such as ESP32 and SIM808. We only used GPS in the prototype; however, it considerably increases energy consumption. Therefore, everything will have to be adjusted with much more efficient components in a commercial product, even boards with ESP32, including a GPS and accelerometer.
The use of the protoboard allowed us to reorganize the components, making it easy to build a PCB board for soldering components. We also intend to look for the most adjustable sensors for human use to miniaturize the prototype for human use and monitor residences' habitability conditions. Our prototype covers these two parts, the accelerometer and GPS, being naturally disposable in homes, and it may have other sensors, for example, the detection of smoke or gas, among others.

Conclusions
This article addresses an area of application that is very relevant to society, considering the vast potential underlying long-range telecommunications equipment and devices (LoRa) that we currently have available on the market at a low cost. The widespread use of IoT has gained enormous potentiality in monitoring older adults and their homes, particularly with sensors that may detect floods, gas leakage, excess carbon monoxide, and fire, to name but a few. In housing, actuators may be incorporated that will trigger specific actions, such as cutting off gas, cutting off water and electricity supply, and the release of fire-retardant chemicals. Using the system here proposed, isolated inhabitants, primarily the elderly, can move freely around the outer spaces of their homes without feeling constrained in their privacy. In addition, a rescue mechanism may be triggered to inform support entities, family, or friends, who will have access to the GPS coordinates of their recent location in case they suffer some accident, fall, or change of vital signs. All calibration parameters and tolerances, including false positive and false negative occurrences, must be very well-validated to make the system efficient and practical, avoiding eventual unnecessary alerts and emergency calls that may misuse resources.
Another essential factor to be considered in the proposed system, which has not yet been used, is the possibility to integrate the technology installed in some remote regions. Local people increasingly use technology for wind energy production and clean energy with negative effects, such as the noise produced and interference in television reception signals, but whose value should be understood to be an asset.
To guarantee compliance with all ethical and data protection principles, the objectives of the system and its operation will be communicated to the National Data Protection Commission. Authorization to collect anonymous data will be requested for statistical purposes only, namely for academic and scientific research work.
Author Contributions: Conceptualization, methodology, software and hardware assembly, J.P.L.; visualization, validation, S.A.; writing-review and editing, J.P.L., S.A., I.M.P. and E.Z. All authors have read and agreed to the published version of the manuscript.
Funding: This work is funded by FCT/MEC through national funds and co-funded by FEDER-PT2020 partnership agreement under the project UIDB/50008/2020. This work is also funded by National Funds through the FCT-Foundation for Science and Technology, I.P., within the scope of the project UIDB/00742/2020. This work is also funded by National Funds through the FCT-Foundation for Science and Technology, I.P., within the scope of the project UIDB/05583/2020.