*Article* **Providing Fault Detection from Sensor Data in Complex Machines That Build the Smart City**

**Alberto Gascón 1, Roberto Casas 1,\*, David Buldain 1 and Álvaro Marco 1,2**

1 Aragon Institute of Engineering Research, University of Zaragoza, 50018 Zaragoza, Spain; algaroche@unizar.es (A.G.); buldain@unizar.es (D.B.); amarco@unizar.es (Á.M.)

2 GeoSpatium Lab S.L., Carlos Marx 6, 50015 Zaragoza, Spain

**\***Correspondence: rcasas@unizar.es; Tel.: +34-976-762-856

**Abstract:** Household appliances, climate control machines, vehicles, elevators, cash counting machines, etc., are complex machines with key contributions to the smart city. Those devices have limited memory and processing power, but they are not just actuators; they embed tens of sensors and actuators managed by several microcontrollers and microprocessors communicated by control buses. On the other hand, predictive maintenance and the capability of identifying failures to avoid greater damage of machines is becoming a topic of grea<sup>t</sup> relevance in Industry 4.0, and the large amount of data to be processed is a concern. This article proposes a layered methodology to enable complex machines with automatic fault detection or predictive maintenance. It presents a layered structure to perform the collection, filtering and extraction of indicators, along with their processing. The aim is to reduce the amount of data to work with, and to optimize them by generating indicators that concentrate the information provided by data. To test its applicability, a prototype of a cash counting machine has been used. With this prototype, different failure cases have been simulated by introducing defective elements. After the extraction of the indicators, using the Kullback–Liebler divergence, it has been possible to visualize the differences between the data associated with normal and failure operation. Subsequently, using a neural network, good results have been obtained, being able to correctly classify the failure in 90% of the cases. The result of this application demonstrates the proper functioning of the proposed approach in complex machines.

**Keywords:** fault detection; sensor data; industry 4.0; data reduction; feature analysis; feature selection; indicators; artificial neural network
