1 Introduction

Cancer remains the leading cause of death worldwide, with an estimated 10 million deaths in 2020. By shedding some light on cancer, it has been shown that early detection and early treatment reduces cancer mortality. To this end, population screening is carried out to identify potential cancer patients. These population screenings are carried out taking into account variables such as age and risk factors such as unhealthy eating habits, smoking, sedentary lifestyles and obesity [28].

In particular, for colorectal cancer (CRC), the third most common cancer in the world, its most frequent early detection tests are currently associated with many disadvantages, as they are painful, invasive, costly for the health system and sometimes even require patient conditioning and sedation [26, 29]. Fecal occult blood test (FOBT), colonoscopies, sigmoidoscopy, faecal immunochemical test (FIT), stool DNA tests and computed tomography colonography (CT colonography) [3] are some of the current early detection tests for CRC. Among them, FOBT is the test for excellence due to its low cost compared to the others. However, it is not enough because it requires a good infrastructure, a high amount of material and human resources such as administrative staff, nurses, specialists related to the digestive system and preventive medicine among others which end up raising the cost for the health system [21].

To overcome these limitations, on the one hand, the scientific studies on how the canine sense of smell is able to detect volatile organic compounds (VOCs) have been considered. These changes in VOCs detected in gases from the digestive system make it possible to identify patients with cancer in early stages [18, 22], as well as other diseases such as diabetes or Alzheimer’s disease [4, 5]. Moreover, the nowadays and increasingly prevalent Internet of Things (IoT) paradigm, which has demonstrated its extraordinary usefulness in the healthcare sector [2, 15, 23].

On the other hand, the Active and Assisted Living (AAL) paradigm will be taken into account, which proposes technologies to improve the quality of life, people’s well-being and health. Among its challenges are robust, accurate and non-intrusive data acquisition, which will also be found in this work [7, 8].

Sampling of stool temperature is highly relevant and, moreover, at a general level for disease diagnosis or monitoring of diseases [11, 17]. Therefore, this work focuses on the use of the thermal camera, which is integrated in an IoT system to monitor patients’ bowel movements at home with the aim of being a first prototype to detect any anomaly with the advantages of small size, low cost, non-invasive and low energy consumption. The IoT system consisting of development boards, sensors and actuators is placed on the toilet seat to collect gas and thermal images. Subsequently, this data will be collected wirelessly to a central node, which is responsible, on one side hand, for storing the data (in a cloud server) for persistence and, on the other side, for allowing the visualisation of the data from an IoT platform.

This work will have the following structure. Section 2 reviews the works that deal with thermal cameras and gas sensors and low-cost monitoring systems that include these devices, both thermal cameras and gas sensors, for the prevention or diagnosis of diseases in the context of AAL. Section 3 reviews the architecture of the system where all its components will be described and presents the information processing proposed for the collection of sensor data, the persistence in the cloud server and the visualisation of the data in the IoT platform. A use case for the IoT system is presented in Sect. 4. Afterwards, Sect. 5 presents the limitations of the study and future work. And finally, Sect. 6 exposes the conclusions.

2 Related Works

In this section we review the literature on thermal cameras, gas sensors and smart gas and temperature monitoring systems related to the diagnosis of diseases. To do so, we will first review those works related to thermal camera or gas sensor type devices and, subsequently, systems which use sensors of this nature in the context of AAL.

2.1 Gas and Temperature Monitoring Devices

Regarding the devices responsible for monitoring gases, there are works that provide keys to detect VOCs such as the one presented by Malagú et al. [14]. In this work, several MOX (Metal Oxide Semiconductor) type sensors are used, which are also low cost compared to other technologies developed on the market to detect gases [9].

Alternatively, Movilla-Quesada et al. and Hofstetter et al. [10, 16] in their works expose the use of MQ family sensors for gas collection in projects ranging from monitoring the concentration of ammonia in the environment and its possible adverse effects on poultry to monitoring greenhouse gas emissions in asphalt mixtures in recycled materials.

In terms of temperature monitoring, thermal cameras are an ideal choice, as well as being a good low-cost option, as their price is decreasing more and more in comparison to other technologies on the market. Other advantages of thermal cameras are their ease of use, the production of high resolution images in real time, making them a very useful device for a variety of applications, and, in addition, they are able to detect anomalies that are usually invisible to the human eye [20].

From the literature it was found that MOX-type sensors are the most suitable and cost-effective sensors for detecting VOCs. Likewise, thermal cameras are also an excellent low-cost option for monitoring temperatures and with adequate image resolution, while maintaining the anonymity of the user.

2.2 IoT System in the Context of Monitoring Diseases in AAL

Firstly, the literature reviews work with thermal cameras, such as Acharya et al. [1], which presents the use of these cameras for breast cancer detection using machine learning techniques. Likewise, Chekmenev et al. [6] present the use of thermal cameras but this time for the analysis of arterial pulse in a novel way. Another possibility is the combination of thermal and depth sensors as presented by Pramerdorfer et al. [19], which allows for person recognition and pose classification.Other authors have presented the use of the thermal camera in systems for the detection of accidents due to falls or unusual inactivity, which is an important tool for the independent living of people, especially the elderly [12, 24, 27].

Regarding of gas sensors, Liu et al. [13] present a system for diagnosing diabetes, whereby the breath of participants is analysed and the result is whether or not they suffer from this disease. Likewise, the analysis of VOCs for the early detection of cancer is addressed by Thriumani et al. [25], who present the use of an E-Nose, usually composed of an array of sensors, and machine learning classifiers to analyse samples of breast or lung cancer cells and healthy cells and identify them.

Therefore, the literature review demonstrates how gas and temperature sampling is very relevant. Therefore, our work aims to integrate both devices in a novel low-cost system which can be used at home without the need for medical staff or expensive installations.

3 Approach to Monitor Human Stool Behavior at Home

This section reviews the system architecture that will be composed of the different development boards, sensors and actuators in charge of collecting the key stool data from the toilet lid via the gas sensor and the thermal camera.

Fig. 1.
figure 1

Flowchart.

First of all, the flowchart (as shown in Fig. 1) which the system will realise is as follows:

  • When the toilet lid is opened, the ESP32 (master) sends a signal to the ESP8266 (slave) for connection to the Wi-Fi network, the MQTT server and the Thinger platform. And it starts collecting and sending data from the gas sensor only.

  • When the lid is closed, data collection and sending from the thermal camera starts and data collection and sending from the gas sensor continues.

  • After a set time the ESP32 sends the signal to enter Deep Sleep mode to the ESP8266 and stops collecting and sending data from the gas sensor and thermal camera.

In addition, another operating mode has been implemented for when the lid is not open and where the person to be monitored is not involved. The purpose of this operating mode is usually to monitor the values under “normal” or “abnormal” conditions, e.g. the use of toilet cleaning agents could cause data errors. For this purpose, it is started after a preset time and as long as the ESP8266 development board is in idle mode. From this point on, thermal images of the values captured by the gas sensor are captured.

The components that make up the complete system are reviewed below. The development boards to be used are:

Lolin32 Lite (ESP32) development board

This board will be the master of the NodeMcu V3. Its main function is to execute a signal that stops the Deep Sleep mode of the NodeMcu V3. In this way, power consumption is significantly reduced. It will also be responsible for activating the alarm signal from the passive buzzer and collecting and transmitting data from the thermal camera and accelerometer.

NodeMcu V3 (ESP8266) development board

This is the slave board and the need to use this board in the IoT system is due to the power supply of the gas sensor. The supply voltage of the gas sensor is 5V and this board has a pin with this voltage output. Like the previous one, it incorporates Wi-Fi, which allows the collection and transmission of data from the gas sensor.

Raspberry Pi 3 Model B+ development board

It is the development board in charge of managing the data flow between the ESP32 and ESP8266 development boards, its main advantage is its high computational capacity with respect to its small size.

In addition, the following sensors will be included:

MQ2 gas sensor.

This MOX-type sensor detects the concentration of various gases present in the environment. In particular, it can measure liquefied petroleum gas (LPG), smoke, alcohol, propane, hydrogen, methane and carbon monoxide. This makes it ideal for collecting gas samples in depositions. However, one disadvantage is its 150 mAh power consumption, although this may seem low, it is a variable to be taken into consideration as it is a battery powered system.

Accelerometer sensor MMA8451

Because it can detect movement, tilt and orientation it is used within this IoT system to determine when the person being monitored is using the toilet, and therefore determine the start and end of the action. Also, the collection of samples is increased and after a set time, the alarm signal (passive buzzer) is activated.

Adafruit AMG8833 sensor IR thermal camera

It is structured in an 8 \(\times \) 8 matrix of infrared thermal sensors. Its function is to obtain an image when the deposition has been performed. Its main advantage is that this type of thermal camera offers anonymity.

And finally, an actuator has been needed:

Passive buzzer.

The function of this actuator is to transform the electrical signals into very useful sound waves to warn the monitored person that the data collection has been completed and can flush the toilet.

This whole set will form the IoT system that will allow data to be collected and transmitted wirelessly to the central sink node. Regarding the protocol used for transmission between ESP8266, ESP32 and Raspberry Pi will be Message Queuing Telemetry Transport (MQTT) as this protocol is based on the publication and subscription being ideal for low-resource devices, as in the case of this project. Then, from this central node, the data will be stored in the cloud server for its persistence. Meanwhile, the information will be sent to the IoT platform for visualisation.

3.1 Database. MongoDB

In the database created in MongoDB, the data collected from the MQ2 sensor (in parts per million (ppm)), the thermal camera data, the data related to the lid opening and the raw data from the gas sensor (MQ2) will be stored. For this purpose, it was necessary to have four unrelated entities. For the transmission of the data, each data collection has been structured in its own way although they will have in common the fields, identifier (id), the name of the sensor, the measurement and the date of collection. An example of this is shown in the Table 1. The JSON format has also been used for sending, as this format allows the data to be easily understood, has a light data transmission and a high processing speed.

Table 1. Data collection for the entity THERMAL DATA

3.2 IoT Platform. Thinger.io

For the visualisation of the data in real time, the choice was made for an IoT platform due to its ease of use was Thinger.io. The dashboard generated (as shown in Fig. 2) in Thinger.io consists of three line graphs. The first line graph, located at the top left, represents the historical maximum and minimum temperatures collected by the thermal cameras, the second line graph, located below the temperature graph, presents the historical values collected by the MQ2 sensor and, finally, the third line graph, located at the top right, represents whether the toilet is being used or not. In addition, the two meters included, one of them represents the last raw value obtained by the MQ2 sensor and the other one shows the value but in ppm.

Fig. 2.
figure 2

Full dashboard

4 Case Study

This section presents the case study carried out to evaluate that the prototype of the low-cost IoT system for monitoring faecal gas is performing its function correctly. To do so, first, a user has to lift the toilet lid, make a bowel movement, close the toilet lid and when the alarm is triggered flush the toilet.

Table 2. Raw data obtained in active and resting state by the MQ2 sensor.

Table 2 presents the raw data for the gas sensor MQ2 when it is in active and idle state. From the data it can be seen that when the gas sensor is in the idle state the value obtained by the sensor fluctuates between the range of 160–190, while if the gas sensor is in the active state the value obtained by the sensor fluctuates between the range of 280–370. Therefore, it can be concluded that the gas collection when deposition is performed is correct.

Furthermore, Table 3 shows the data in ppm values for the MQ2 gas sensor when it is in an active state and when it is at rest. It can be seen that the ppm value is lower in the idle state and higher in the active state, as was the case with the raw data collected. For example, the resting value for alcohol is around 4.5 ppm while the active value is around 8.1 ppm. Similarly for propane, its resting state value is about 2.9 ppm while its active state value is about 4.66 ppm.

\(^*\)ESP8266 development boards will return a value (raw value) ranging from 0 to 1023 which is equivalent to a voltage range between 0 and 3.3V (voltage).

Table 3. Data obtained in active and resting state by the MQ2 sensor in ppm values.

Similarly, for temperature data collected by the thermal camera. On the one hand, in Fig. 3 it is observed that in the temperature map at certain points the temperature increases (maximum temperature of 29\(^{\circ }\)C) due to the presence of the gases produced after the participant performs the deposition.

Fig. 3.
figure 3

After deposition

On the other hand, in Fig. 4 it can be seen that in the temperature map the temperature decreases in general (maximum temperature of 26.5\(^{\circ }\)C) due to the elimination of these gases when flushing the tank.

Fig. 4.
figure 4

After flushing the tank

Therefore, it can be concluded from this evaluation case that the low-cost IoT system is able to correctly monitor the gas in the faeces through the gas sensor and the thermal camera. Limitations of the study and future work.

5 Limitations of the Study and Future Work

Although the case study demonstrates that the low-cost IoT device with thermal vision is capable of monitoring human bowel movements from home, some of the limitations that have been found through the case study of this system and its possible improvements could be the following.

The incorporation of different gas sensors to cover a wider range of gases and also to improve sensitivity and accuracy. Because MOX sensors can be affected by humidity and temperature. Although the case study was conducted in a controlled environment, this will not be the case in reality.

Furthermore, an improvement of the management of incoming messages will be realised. Currently, it is handled in a single processing thread and if the sample throughput per second is increased, it may no longer behave correctly.

In addition, a protocol for acquiring gas samples and thermal images from different users to monitor whether there are changes in behaviour. The data can then be processed for real-time classification using artificial intelligence techniques. In this way, characteristics such as the type of deposition could be studied and inclusion criteria for the experimental control group could be generated in conjunction with the medical oncology team.

Although this work presents a prototype that is still in the design phase, it would be interesting to evaluate the usability of the device in the future. And replacing the breadboards housing the different development boards, sensors and actuators with a printed circuit board would reduce the size and noise generated by the swarm of cables.

6 Conclusions

In this work, we present the evaluation of a case study to monitor stool behaviour in the home.

To do this, first, the flowchart that the system performs is shown. Then, the IoT architecture of the system has been reviewed, consisting of the development boards, ESP32, ESP8266, (responsible for collecting data and both housed in the lid of the toilet) and Raspberry Pi 3, responsible for being the central sink node, the MQ2 gas sensor, the thermal camera and the actuator, passive buzzer.

Subsequently, it has been exposed, on the one hand, the storage in the MongoDB database, providing the persistence feature to these data and, on the other hand, the visualisation of these data from the IoT platform, Thinger.io.

Next, a case study has been presented where the low-cost device is evaluated. This evaluation presents the data collected by both the gas sensor and the thermal camera and shows how there is clearly a difference between the data when gases are presents and when they are not, which would allow for easy and quick monitoring of stool from home.

Finally, the limitations which have been found through the case study of the prototype and the future lines which can be carried out, especially in order to make improvements to it, have been exposed.