Spatio-Temporal Optimization of Perishable Goods’ Shelf Life by a Pro-Active WSN-Based Architecture

The waste in the perishable goods supply-chain has prompted many global organizations (e.g., FAO and WHO), to develop the Hazard Analysis and Critical Control Points (HACCP) protocol that ensures a high degree of food quality, minimizing the losses in all the stages of the farm-to-fork chain. It has been proven that good warehouse management practices improve the average life of perishable goods. The advances in wireless sensors network (WSN) technology offers the possibility of a “smart” storage organization. In this paper, a low cost reprogrammable WSN-based architecture for functional warehouse management is proposed. The management is based on the continuous monitoring of environmental parameters (i.e., temperature, light exposure and relative humidity), and on their combination to extract a spatial real-time prediction of the product shelf life. For each product, the quality decay is computed by using a 1st order kinetic Arrhenius model to the whole storage site area. It strives to identify, in a way compatible with the other products’ shelf lives, the position within the warehouse that maximizes the food expiration date. The shelf life computing and the “first-expired first-out” logistic problem are entrusted to a Raspberry Pi-based central unit, which manages a set of automated pallet transporters for the displacement of products, according to the computed shelf lives. The management unit supports several commercial light/temperature/humidity sensor solutions, implementing ZigBee, Bluetooth and HTTP-request interfaces. A proof of concept of the presented pro-active WSN-based architecture is also shown. Comparing the proposed monitoring system for the storage of e.g., agricultural products, with a typical one, the experimental results show an improvement of the expected expiration date of about 1.2 ± 0.5 days, for each pallet, when placed in a non-refrigerated environment. In order to stress the versatility of the WSN solution, a section is dedicated to the implemented system user interfaces that highlight detecting critical situations and allow timely automatic or human interventions, minimizing the latter.


Introduction
About 1.3 billion tons of food (i.e., 1/3 of the overall food for human use) and $35 billion per year (in the US) [1], are some of the numbers that characterize the socio-economic losses caused by the global problem of Food Losses and Waste (FLW) [1]. FLW concerns the whole food-chain, but it is important to distinguish between the "food losses" that refer to the pre-consumer losses and the "food waste" that is a post-consumer reality. While in this latter case, the improvement depends largely on consumers' sensitization and common sense, in the former one the food losses minimization is entrusted to a protocol, known as Hazard Analysis and Critical Control Points (HACCP) [2], legislated by an agreement between the Food and Agriculture Organization (FAO) and the World Health Organization (WHO). This protocol follows the perishable goods supply-chain and identifies critical points in the • Continuous monitoring of the goods, with the possibility to follow the pallets during the transit. • Implementation of a specific pallet's SL prediction model extended all over the storage site. It guarantees the identification of the storage location, inside the warehouse, that optimizes the specific SL. Integration on the central control unit of a Quality Controlled Logistic (QCL) algorithm. It implements a first-to-expire first-out (FEFO) warehouse management [9]. • Pallets' automatic displacement according to the SL prediction model and QCL algorithm outcomes. • Easy re-programmability of the platform by in loco operations or by remote actions. • Low cost, easy installation and operation.
The Environmental Monitoring Unit consists of L/H/T sensors that acquire statically the data from a specific position of the storage room, sending them to the Central Unit via ZigBee. The Central Unit uses these data to realize a heat map of the storage site.
The Storage Unit is composed of the pallet to be monitored and a dedicated L/H/T node placed on the surface. It communicates via ZigBee with the Central Unit. The dedicated node is used to precisely define the product shelf life, because the use of parameters derived mathematically from the Environmental Monitoring Unit, can lead to an avoidable propagation of errors [16].
The Central Control Unit collects data from the Storage and Environmental Monitoring units and implements a predictive SL computing on the chosen pallet. The calculation, repeated on each available position, is useful to identify the optimal site for a specific pallet. Once this place is identified, the control unit opens a Bluetooth communication channel with a dedicated pallet transporter (Displacement Unit- Figure 1).
The transporter is driven step-by-step in its navigation by the RPi-based control unit along a pre-set virtual lattice. The transporter embeds a dedicated hardware programmed for the automatic movements, curves handling and motors power management.
Each node also provides a battery level indication and a working state flag. If the battery level is under the 5%, or the working flag is set to '0', the central unit stops acquiring from the specific node and derives mathematically the data in that uncovered point. Simultaneously a warning is sent to the system manager (human component) asking for intervention.
As a proof of concept, the WSN-based monitoring and management system has been implemented in a real-life context by using ten ZigBee nodes, equipped with temperature, relative humidity and light exposition sensors. Two of these were applied on the pallet to be monitored (Storing Unit- Figure 1), while the remaining eight were bonded on the storing room walls (Environmental Monitoring Unit- Figure 1). The nodes that compose the Environmental Monitoring Unit are placed in such a way as to create a 5 × 5 array: 2 for each available wall edge (right, left, up and down considering a room cross-section). The Storage Unit is composed of the pallet to be monitored and a dedicated L/H/T node placed on the surface. It communicates via ZigBee with the Central Unit. The dedicated node is used to precisely define the product shelf life, because the use of parameters derived mathematically from the Environmental Monitoring Unit, can lead to an avoidable propagation of errors [16].
The Central Control Unit collects data from the Storage and Environmental Monitoring units and implements a predictive SL computing on the chosen pallet. The calculation, repeated on each available position, is useful to identify the optimal site for a specific pallet. Once this place is identified, the control unit opens a Bluetooth communication channel with a dedicated pallet transporter (Displacement Unit- Figure 1).
The transporter is driven step-by-step in its navigation by the RPi-based control unit along a pre-set virtual lattice. The transporter embeds a dedicated hardware programmed for the automatic movements, curves handling and motors power management.
Each node also provides a battery level indication and a working state flag. If the battery level is under the 5%, or the working flag is set to '0', the central unit stops acquiring from the specific node and derives mathematically the data in that uncovered point. Simultaneously a warning is sent to the system manager (human component) asking for intervention.
As a proof of concept, the WSN-based monitoring and management system has been implemented in a real-life context by using ten ZigBee nodes, equipped with temperature, relative humidity and light exposition sensors. Two of these were applied on the pallet to be monitored (Storing Unit- Figure 1), while the remaining eight were bonded on the storing room walls (Environmental Monitoring Unit- Figure 1). The nodes that compose the Environmental Monitoring Unit are placed in such a way as to create a 5 × 5 array: 2 for each available wall edge (right, left, up and down considering a room cross-section). The implemented Displacement Unit consists of an acrylic car prototype, equipped with Arduino UNO and HC-05 (Bluetooth). A dedicated and easy reprogrammable (via USB) script was uploaded on the ATmega328 microcontroller, containing the servomotors direction for the steering (PWM management) and the DC motor activation, depending of the tasks provided by the Central Control Unit. Even if in the areas in which the automated robots operate, no obstacles are typically present, the automatons are equipped with ultrasonic sensors (e.g., HC-SR04), to avoid crashes with human components or pallets out of their correct place.

Sensing Platform
The chosen L/H/T sensor consists of an NXP JN5164 microcontroller (NXP Semiconductors Netherlands B.V., Eindhoven, The Netherlands) interfacing a 10-bit resolution ADC, for sensor data and digitization, and a Digi XBee 802.15.4 RF module for ZigBee protocol data transmission. The implemented Displacement Unit consists of an acrylic car prototype, equipped with Arduino UNO and HC-05 (Bluetooth). A dedicated and easy reprogrammable (via USB) script was uploaded on the ATmega328 microcontroller, containing the servomotors direction for the steering (PWM management) and the DC motor activation, depending of the tasks provided by the Central Control Unit. Even if in the areas in which the automated robots operate, no obstacles are typically present, the automatons are equipped with ultrasonic sensors (e.g., HC-SR04), to avoid crashes with human components or pallets out of their correct place.

Sensing Platform
The chosen L/H/T sensor consists of an NXP JN5164 microcontroller (NXP Semiconductors Netherlands B.V., Eindhoven, The Netherlands) interfacing a 10-bit resolution ADC, for sensor data and digitization, and a Digi XBee 802.15.4 RF module for ZigBee protocol data transmission.
The ZigBee protocol is preferable respect e.g., Bluetooth, when the primary importance specifications concern: (i) the low power consumption (Battery Life-ZigBee: >1 year, Bluetooth: 1 week), (ii) the number of nodes to be monitored (ZigBee: 65,000, Bluetooth: 8), (iii) the flexibility in the network topology [7,[17][18][19]. Despite these advantages, the data rate of the ZigBee is low, 250 kb/s (best case @ ISM 2.4 GHz), but it is enough for our application.
Each sensor node uses three 1.5 AA batteries and, complete of a plastic shell, has the size: 6.85 cm × 6.35 cm × 3.30 cm for a total weight of 160 g. The transmitting power stays under 1 mW, allowing the node to be powered for 1.5 years if the read-sleep cycle is: 1 reading/30 s, and 2.5 years if read-sleep cycle is: 1 reading/60 s.
Finally, an adaptive calibration process has been done on the temperature readings, identifying a measures-based correction factor variable around −4 • C, matching the sensor producer reading guidelines [20]. Table 1 summarizes the performances of the node sensors and the dedicated modules described above. Figure 2 shows the described architecture components. In particular, Figure 2a shows a single the L/H/T sensor equipped with ZigBee Modules and the plastic shell footprint. It also shows the Central Control Unit (Raspberry Pi 2 Model B+) equipped with ZigBee and Bluetooth devices. It is notable that the RPi is connected to a router via Ethernet cable (HTTP-Request). The prototype car used for the proof of concept is showed in Figure 2b. The ZigBee protocol is preferable respect e.g., Bluetooth, when the primary importance specifications concern: (i) the low power consumption (Battery Life-ZigBee: >1 year, Bluetooth: 1 week), (ii) the number of nodes to be monitored (ZigBee: 65,000, Bluetooth: 8), (iii) the flexibility in the network topology [7,[17][18][19]. Despite these advantages, the data rate of the ZigBee is low, 250 kb/s (best case @ ISM 2.4 GHz), but it is enough for our application.
Each sensor node uses three 1.5 AA batteries and, complete of a plastic shell, has the size: 6.85 cm × 6.35 cm × 3.30 cm for a total weight of 160 g. The transmitting power stays under 1 mW, allowing the node to be powered for 1.5 years if the read-sleep cycle is: 1 reading/30 s, and 2.5 years if read-sleep cycle is: 1 reading/60 s.
Finally, an adaptive calibration process has been done on the temperature readings, identifying a measures-based correction factor variable around −4 °C , matching the sensor producer reading guidelines [20]. Table 1 summarizes the performances of the node sensors and the dedicated modules described above. Figure 2 shows the described architecture components. In particular, Figure 2a shows a single the L/H/T sensor equipped with ZigBee Modules and the plastic shell footprint. It also shows the Central Control Unit (Raspberry Pi 2 Model B+) equipped with ZigBee and Bluetooth devices. It is notable that the RPi is connected to a router via Ethernet cable (HTTP-Request). The prototype car used for the proof of concept is showed in Figure 2b.

Communication Management
Three main communication networks have realized the proof of concept for the proposed architecture as sketched in Figure 3. They manage the Environmental Control, the Storage and the Displacement Unit, respectively.
The Environmental Control Unit is managed through a multipoint ZigBee-based network (Figure 3a-Red lines) in which the Central unit acts as Coordinator, while the L/H/T sensors act as End Devices. As shown in Figure 3a, the Central Unit interrogates the sensor data with the prescribed timing and waits for the response. No interactions between sensors are allowed by the Coordinator as reported in Figure 3a. Here, the red lines represent the connection between the End Devices and the Central Unit, which manages the Environmental Control Unit nodes. In order to cover all the communication possibilities, in Figure 3b the Storage Unit communicates with the Central Unit (brown solid lines) through a commercial standalone routing gateway (e.g., Digi ConnectPort X4 H Nema). The gateway locally operates as Coordinator, but globally it can be considered as a Router. The gateway connects two L/H/T sensors placed on the pallets that work as End Devices. The router acquires the data from the sensors and sends them to a personal cloud website. The Central Unit acts as global Coordinator capturing the data via HTTP-request, using reserved credentials on the dedicated Digi site (Figure 3b-Orange lines).
Finally, a point-to-point Bluetooth-based network handles the Displacement Unit ( Figure 3b-Blue lines). In this case, the Central Unit operates as End Device communicating, when asked by the network Coordinator, a string that contains: (i) the address of the transporter selected for the displacement and (ii) the destination position. In this net, all the robots act as Coordinator, asking to the Central Unit the transmitted string content respecting a time multiplexing.

Communication Management
Three main communication networks have realized the proof of concept for the proposed architecture as sketched in Figure 3. They manage the Environmental Control, the Storage and the Displacement Unit, respectively.
The Environmental Control Unit is managed through a multipoint ZigBee-based network (Figure 3a-Red lines) in which the Central unit acts as Coordinator, while the L/H/T sensors act as End Devices. As shown in Figure 3a, the Central Unit interrogates the sensor data with the prescribed timing and waits for the response. No interactions between sensors are allowed by the Coordinator as reported in Figure 3a. Here, the red lines represent the connection between the End Devices and the Central Unit, which manages the Environmental Control Unit nodes. In order to cover all the communication possibilities, in Figure 3b the Storage Unit communicates with the Central Unit (brown solid lines) through a commercial standalone routing gateway (e.g., Digi ConnectPort X4 H Nema). The gateway locally operates as Coordinator, but globally it can be considered as a Router. The gateway connects two L/H/T sensors placed on the pallets that work as End Devices. The router acquires the data from the sensors and sends them to a personal cloud website. The Central Unit acts as global Coordinator capturing the data via HTTP-request, using reserved credentials on the dedicated Digi site (Figure 3b-Orange lines).
Finally, a point-to-point Bluetooth-based network handles the Displacement Unit ( Figure 3b-Blue lines). In this case, the Central Unit operates as End Device communicating, when asked by the network Coordinator, a string that contains: (i) the address of the transporter selected for the displacement and (ii) the destination position. In this net, all the robots act as Coordinator, asking to the Central Unit the transmitted string content respecting a time multiplexing.

Shelf Life Prediction 1st Order Kinetic Model
The Central Control Unit has the role of processing the environmental parameters, aiming to identify critical conditions for the SL management.

Shelf Life Prediction 1st Order Kinetic Model
The Central Control Unit has the role of processing the environmental parameters, aiming to identify critical conditions for the SL management.
In particular, the control unit implements a reprogrammable algorithm for the SL assessment focusing on fresh-cut vegetables parameters (e.g., tomatoes).
In this context, it has been proven [3,20] that the food quality is affected by several physical, chemical and microbiological reactions that can be related, through mathematical models, to the food color and firmness, that are themselves linked to temperature, humidity and light exposition, via empirical function/constants known as kinetic parameters.
The empirical law [21,22] that describes the temperature dependence in a simple chemical reaction is the Arrhenius law. It has been proven to be very worthwhile in chemical kinetics and relates the rate constant k of a reaction with the absolute temperature T, through the following equation: with W: pre-exponential factor, Ea: activation energy and R: gas constant. The Ea can be evaluated as the energy barrier that the molecules need cross, in order to be able to react, while W represents the rate constant at which all the molecules have sufficient energy for the reaction.
Since the Arrhenius law parameters are typically determined with non-linear regression of empirical data, such as the one in [6,21,22], in the following, we will insert the kinetic parameters, provided by a tomatoes-centered study, in a general formula for k rate derivation, suitable for any temperature: with k ref : k value at the dedicated reference temperature T ref .
According to [22] for climacteric fruit, the initial firmness is considered as a good indicator of the products ripeness and it is recommended in the shelf-life assessment of fresh-cut tomatoes as stated by several works in the field [21][22][23][24].
For this reason, this proof of concept bases its functioning on the tomatoes' firmness as the only parameter for the quality level determination [22]. However, the here implemented kinetic model is suitable for the parallel evaluation of other kinds of indexes, such as color, dehydration (loss of weight) and microbial contamination.
In the firmness evaluation context, the extracted data, analyzed in the following, were inspired to the standardized measurements in [22], where the force necessary to cause a deformation of 3 mm (with a speed of 0.02 mm/s) was recorded using a Zwick Universal Testing Machine. The extraction of the decay rate k is operated on empirical basis as stated in [24].
A first order approximation about the product quality is given by Equation (3): where c is the measured quality factor, c 0 is the initial quality value, c eq is the quality factor at a specific equilibrium value, t is the storage time and k is the rate determined by Equation (2). Then, known a specific quality factor c at a given time t, the SL can be calculated as: Together, Equations (2)-(4), allow calculating the products' remaining life, estimating with a first order model its degradation in the presence of temperature changes. A compendium of the parameters implemented in the proposed monitoring system, extracted tomatoes-centred studies [6,21,22], are shown in Table 2. Quality factor at the equilibrium (N) 3 Figure 4 shows the change in firmness (N) of tomatoes stored at three different (and controlled) temperatures: 20 The data that compose the plot have been acquired each 60 s, but are reduced to 1 read/500 s for plotting purposes.
The initial shelf life, imposed by the kinetic parameters in Table 2, is about 8 days, but all the nodes show lower SL: 6.9 days for the Node120 • C, about 3 days for the Node2 @ 30 • C SL and a remaining life of about 1.5 days for the third node at 40 • C.
The model used to describe a food quality parameter, such as the firmness, is generic and remains valid for every kind of product and quality parameter (e.g., color, weight loss, enzymatic activity, etc.). The only difference concerns the empirically derived kinetic parameters, which characterize the specific product.
It is notable that the implemented prediction model exhibits a certain degree of approximation, showing a linear degradation of the SL. Since the temperature sensors shows an accuracy of ±2 • C, the degradation rate k can assume, according to the Equations (1) and (2), values between k − (T 1 ) and k + (T 2 ) with T 1 = T + 2 • C and T 2 = T − 2 • C. For the same reason, the SL ranges between SL − (k(T 1 )) and SL + (k(T 2 )) according to Equations (3) and (4).  Quality factor at the equilibrium (N) 3 Figure 4 shows the change in firmness (N) of tomatoes stored at three different (and controlled) temperatures: 20 °C ± 2 °C (blue line), 30 °C ± 2 °C (red line) and 40 °C ± 2 °C (yellow line). The data that compose the plot have been acquired each 60 s, but are reduced to 1 read/500 s for plotting purposes.
The initial shelf life, imposed by the kinetic parameters in Table 2, is about 8 days, but all the nodes show lower SL: 6.9 days for the Node120 °C , about 3 days for the Node2 @ 30 °C SL and a remaining life of about 1.5 days for the third node at 40 °C .
The model used to describe a food quality parameter, such as the firmness, is generic and remains valid for every kind of product and quality parameter (e.g., color, weight loss, enzymatic activity, etc.). The only difference concerns the empirically derived kinetic parameters, which characterize the specific product.
It is notable that the implemented prediction model exhibits a certain degree of approximation, showing a linear degradation of the SL. Since the temperature sensors shows an accuracy of ±2 °C , the degradation rate k can assume, according to the Equations (1) and (2), values between k − (T1) and k + (T2) with T1 = T + 2 °C and T2 = T − 2 °C . For the same reason, the SL ranges between SL − (k(T1)) and SL + (k(T2)) according to Equations (3) and (4).

Implemented Monitoring and Control Protocol
As described in Section 4.1, the implemented SL algorithm is focused on the temperature effects, but a series of control flags are set according to the guidelines of the psychrometric [6,19] (effect of the relative humidity on a specific perishable good) and light exposure effects on the product quality decay [19]. Figure 5 summarizes the main steps of the implemented monitoring and control protocol, on a single product (e.g., pallet, or stack of pallets [3]). They consist of: 1. Upload, on the system interface, the T/H/L reference values and sensors accuracies. The initialization phase will derive the kref [21] (according to Equation (1)) and the initial shelf life (Equation (4)). 2. Start the computation in the while cycle, driven by the condition: SL > 0. The while repeats the computation with a fixed sampling time (ts). In this example ts = 300 s (e.g., 1 read/5 min).

Implemented Monitoring and Control Protocol
As described in Section 4.1, the implemented SL algorithm is focused on the temperature effects, but a series of control flags are set according to the guidelines of the psychrometric [6,19] (effect of the relative humidity on a specific perishable good) and light exposure effects on the product quality decay [19]. Figure 5 summarizes the main steps of the implemented monitoring and control protocol, on a single product (e.g., pallet, or stack of pallets [3]). They consist of:

1.
Upload, on the system interface, the T/H/L reference values and sensors accuracies.
The initialization phase will derive the k ref [21] (according to Equation (1)) and the initial shelf life (Equation (4)).

2.
Start the computation in the while cycle, driven by the condition: SL > 0. The while repeats the computation with a fixed sampling time (ts). In this example ts = 300 s (e.g., 1 read/5 min). If the recommended conditions are respected, the system uses k ref as k(T) in Equations (3) and (4) for calculating quality parameter c and computing SL, respectively. If a threshold, or more than one, is surpassed (potentially incorrect storage conditions), the rate k is calculated according Equation (2), the quality parameter c and the SL are derived, respectively, via Equations (3) and (4). Then, the values that overcame the respective thresholds, activate a dedicated flag for an external intervention request.
The warnings provided by the system appear in the frontal panel of the RPi-based central control unit. Automatic corrective actions for the conditions recovery in terms of humidity and light exposition are not yet integrated in the present system and are left to the human component.
Differently, in the temperature control context, a fully automatic environment management has been implemented, ensured the SL maximization of all the pallets inside the smart warehouse.  (3) and (4) for calculating quality parameter c and computing SL, respectively. If a threshold, or more than one, is surpassed (potentially incorrect storage conditions), the rate k is calculated according Equation (2), the quality parameter c and the SL are derived, respectively, via Equations (3) and (4). Then, the values that overcame the respective thresholds, activate a dedicated flag for an external intervention request.
The warnings provided by the system appear in the frontal panel of the RPi-based central control unit. Automatic corrective actions for the conditions recovery in terms of humidity and light exposition are not yet integrated in the present system and are left to the human component.
Differently, in the temperature control context, a fully automatic environment management has been implemented, ensured the SL maximization of all the pallets inside the smart warehouse.

Quality-Controlled Logistic Algorithm
The algorithm described in Sections 4.1 and 4.2, in the presented form, allows the monitoring and the control of each pallet (or pallet stack) independently by the surrounding conditions. It is suitable in static situations, in which a pallet cannot be moved from its initial position [6,19], but it is not able to provide a prediction of the position, inside a storage room, that maximizes its lifetime. For this aim, the proposed Central Control Unit embeds a quality controlled logistic (QCL) algorithm that exploits the data provided by the L/H/T sensors from the Environmental Control Unit, to realize a heatmap of the whole storage room. Then, in principle, considering a single pallet to be preserved, it is assumed to virtually place the same in all the possible sites. Then, since the temperature is mathematically derived for each available site, for the same a certain number of SL values are derived (number of available storing sites minus 1). The resulting-linked SL matrix provides a quantifiable effect of the potential displacement on the product remaining life. Maximizing all the SL for all the

Quality-Controlled Logistic Algorithm
The algorithm described in Sections 4.1 and 4.2, in the presented form, allows the monitoring and the control of each pallet (or pallet stack) independently by the surrounding conditions. It is suitable in static situations, in which a pallet cannot be moved from its initial position [6,19], but it is not able to provide a prediction of the position, inside a storage room, that maximizes its lifetime. For this aim, the proposed Central Control Unit embeds a quality controlled logistic (QCL) algorithm that exploits the data provided by the L/H/T sensors from the Environmental Control Unit, to realize a heatmap of the whole storage room. Then, in principle, considering a single pallet to be preserved, it is assumed to virtually place the same in all the possible sites. Then, since the temperature is mathematically derived for each available site, for the same a certain number of SL values are derived (number of available storing sites minus 1). The resulting-linked SL matrix provides a quantifiable effect of the potential displacement on the product remaining life. Maximizing all the SL for all the pallets within a warehouse it is possible to implement a first-to-expire first-out (FEFO) management system. The QCL algorithm working principle can be briefly summarized in five main steps:

1.
The algorithm virtually derives, on the storage room surface, an M 1 × M 2 lattice (the dimensions are arbitrary, in this case M 1 = M 2 = M = 5 as shown by the background matrix in Figure 3). The N p pallets to be managed (with N p < M 2 − 3) are placed on N p row-column different intersections. 2.
The system identifies each pallet with a number (ID) and derives an encumbrance matrix (EM) used to define the navigation path of the selected pallet to be moved. It allows pre-calculating the path in order to avoid collisions with other pallets. 3.
The system extract two M × M matrices, named T ref and T amb . The former, T ref ∈ R M,M , consists in a matrix that contains the temperature reference value [6,19,20]. For sake of clarity, in the following T refi,j will identify the element in the i-th row and j-th column. The second matrix, T amb ∈ R M,M , contains the temperature values acquired by sensors and the mathematically derived ones. In the proposed example, eight values of T are directly extracted by the sensors, according to the end devices in Figure 3a: {T amb1,2 , T amb1,4 , T amb2,1 , T amb2,5 , T amb4,1 , T amb4,5 , T amb5,2 , T amb5,4 }. The other matrix elements are mathematically derived by a contiguous elements average, as proposed in literature [25].

4.
The temperature matrices lead to the definition of N p overlapped 2D quality matrices, which constitute a 3D matrix C ∈ R M,M,Np , with C i,j,p the quality that a specific p-th would have, if it were in i-th row and j-th column position.
The algorithm controls sequentially all the pallets and analyzes the effective C i,j,p value (row and column indexes of real position of the pallet) of the considered pallet. If C i,j,p of the monitored product shows a firmness decrease between two consecutive measurements, of C th = 2.68 × 10 −5 N/s (10 min @ 24 • C), the system activates the displacement operations. The quality factor threshold C th is reprogrammable and two thresholds are preset by default: 10 min @ 26 • C → 3.184 × 10 −5 N/s and 10 min @ 24 • C → 2.68 × 10 −5 N/s.

5.
Since the algorithm has the C and T amb matrices, it can derive the shelf life 3D matrix SL ∈ R M,M,Np with SL i,j,p the shelf life of a specific p-th pallet would have, if it were in i-th row and j-th column position. The displacement operations ask for identifying (with the right order) the pallets movements that maximize the overall shelf life in the warehouse.
For the sake of clarity, the routines on which the algorithm is based are schematically reported in Figure 6, considering the displacement of four pallets. During the 1st subroutine (Subroutine 1- Figure 6): (a) Firstly, the pallet with ID = 1 is selected and the coordinates (x 1 , y 1 ) that maximize the SL of the first pallet are identified on the SL p=1 map. (b) The coordinates (x 1 ,y 1 ) are excluded from the computation, and the point (a) is repeated on the SL p=2 matrix. Then, the algorithm has identified the maximum SL for the pallet with ID = 2 and the coordinates that ensure it. In this case the first ID is 2, and the last ID is 1. The routine defines the SLs 2 . Then the iterations are repeated considering as first ID the 3, and as last the 2, and so on ( Figure 6). (e) After 20 iterations the system has four values of SLs: {SLs 1 , SLs 2 , SLs 3 , SLs 4 }. Then, it sorts these values in a decreasing order. The highest overall SL (e.g., SL s2 in the example) identifies the "best pallet" to be displaced.
After the displacement, the moved node is excluded by the computing, and a similar subroutine (Subroutine 2) repeats the working principle from the point (a) to the (e), but operating on three IDs. After 12 iterations the second "best pallet" is identified. Overall after 39 recursive iterations, all the pallets are disposed in regions that ensure the maximum overall shelf life.
For the sake of clarity, the routines on which the algorithm is based are schematically reported in Figure 6, considering the displacement of four pallets. During the 1st subroutine (Subroutine 1- Figure 6): (a) Firstly, the pallet with ID = 1 is selected and the coordinates (x1, y1) that maximize the SL of the first pallet are identified on the SLp=1 map.

Displacement Unit Management
When the Central Control Unit defines all the coordinates according to the QCL algorithm, it also identifies a step-by-step path for a specific pallet in order to avoid collision with other pallets. The system drives in each displacement the pallet by using a specific string mounted on a Bluetooth transceiver in receiver mode (End device-Section 3.2 Figure 3b). The string is composed of: with 89, 90, 91 random separators, add _ btT is the address of the selected transporter, while add _ btP is the address of the selected; init _ coord are the initial coordinates and final _ coord are the final ones. The separators uniquely define the parts of the messages, avoiding errors in the communication.
When the QCL algorithm ends the computation and the Central Control Unit has defined the paths for the pallets displacement, the Raspberry Pi commutates its system role from Coordinator in a ZigBee Network to End Device in a Bluetooth one. Then it sends in "broadcast" a message of READY, and then waits for the coupling.
The first transporter operates a pairing with the RPi-connected HC-05 and reads the string. If add _ btT field contains a different address, the transporter closes the communication with the control unit, otherwise reads the remaining string. In the first case, the second transporter acts as Coordinator, asking for add _ btT field.
When the needed transporter is found, an on-board Arduino UNO script analyzes each part of the string identifying the pallet initial position and the "final coordinates". Since the transporter movement are fully driven step-by-step on the virtual lattice, the final coordinates provided by the control unit are simply the next coordinates to be reached and thus differ by one point on the x-axis or y-axis. It allows one to fully define all the available movements as summarized by the following pseudocode and Figure 7:    Figure 7 shows the unified movement circuit that takes into account all the available movements and initial direction of a selected transporter (via add _ btT). A blue square represent the instantaneous starting point, while the orange ones represent the available target positions. It is clear that all the suitable positions differ of a single step along the x or y axis. Figure 7 shows that the implemented algorithm is suitable for all the final direction of the transporter (e.g., red or black arrow). The final direction determines the servomotor and DC motors driving bits (SM0, SM1, DCM0, DCM1).

Results
The system described above has been fully implemented and analytically validated, realizing a proof of concept in an empty University Lab room with size [6.3 m × 6.7 m], virtually divided into a 5 × 5 lattice. The eight L/H/T sensors described in Section 3.1 were placed on the walls with a uniform height from the floor of h = 1.2 m.
Considering a top view of the room such as the one in Figure 3, the x-axis has been placed on the wall with length l 1 = 6.3 m, while the y-axis on the wall with length l 2 = 6.7 m. Annotating the sensors coordinates in the form S n (x n , y n ), with n the ID of the specific sensor, the monitoring nodes are placed in: S1(1. The internal room heat-map has been derived following the procedure in Section 4.3. Finally, for the proof of concept, only a single transporter was used (Figure 2b). All the results in the following section have been extracted from an environmental monitoring of 10 days and 11 h. In the following will be provided experimental results about the kinetic model approximations, Central Control Unit users' interface and monitoring panel, and quantitative shelf life optimization.

Kinetic Model Approximations Assessment
Since the internal room heat-map is mathematically derived by an average procedure described in Section 4.3, before proceeding to the sensor placement a quantitative evaluation of the absolute temperature error has been done. This evaluation allows identifying the maximum intersensor distance (Isd) that ensures a temperature error below the sensors' accuracies even if the temperature on a specific position is derived from a contiguous element average.
For this aim, a section of the room was divided in a 3 × 3 lattice and two setups were realized, as shown by Figure 8a. Setup 1 covers all the available positions with physical sensors realizing a kind of ground truth of the temperature, while Setup 2 covers only three positions with sensors and the remaining six ones are mathematically determined.
The assessment of the absolute temperature error (ε) was done according to Equation (5): where T s1,i,j is the temperature in the (i,j) lattice position for the Setup 1 and the T s1,i,j is the temperature in the (i,j) lattice position for the Setup 2. Sixteen monitoring events for each evaluated Isd have been realized in order to extract a statistical behavior. The Isd was ranged from 1 m to 2.5 m with step 0.25 m. For sake of clarity, Figure 8b shows the absolute error of a single run for Isd = 1 m, 1.5 m, 2 m, 2.5 m, highlighting the expected decreasing trend when the sensors become close among each other. Figure 8c shows the average and standard deviations of temperature and RH errors versus Isd. The statistical behavior shows that the sensors cannot be placed further than 2.5 m in order to ensure a temperature error < 2 • C and a RH error < 8%. If the sensors' accuracy changes, another characterization needs to be done. Moreover, in general, it is possible to extract an empirical rule about the number of needed sensors to cover the storing room with a temperature error lower than the sensors accuracy: with Isd@std(ε) > Acc, the inter-sensors distance which ensures an error lower than the sensor accuracy, derivable by a characterization like the one in Figure 8c.  Figure 9 shows two snapshots of the possible (and tested) Central Control Unit interface configurations during the SL monitoring. Figure 9a shows a local interface in which a 7″ LCD touch screen is connected via HDMI to the RPi, reporting in real time the SL numerical assessment and a SL chart for specific selected positions, considering a single pallet. Figure 9b shows a more complex panel hosted on the screen of a personal computer. The RPi is connected to the PC via Ethernet. In this way, the HTTP request action can be done by using a network bridge directly on the computer, which hosts the control system.    Figure 9a shows a local interface in which a 7" LCD touch screen is connected via HDMI to the RPi, reporting in real time the SL numerical assessment and a SL chart for specific selected positions, considering a single pallet. Figure 9b shows a more complex panel hosted on the screen of a personal computer. The RPi is connected to the PC via Ethernet. In this way, the HTTP request action can be done by using a network bridge directly on the computer, which hosts the control system.  Figure 9 shows two snapshots of the possible (and tested) Central Control Unit interface configurations during the SL monitoring. Figure 9a shows a local interface in which a 7″ LCD touch screen is connected via HDMI to the RPi, reporting in real time the SL numerical assessment and a SL chart for specific selected positions, considering a single pallet. Figure 9b shows a more complex panel hosted on the screen of a personal computer. The RPi is connected to the PC via Ethernet. In this way, the HTTP request action can be done by using a network bridge directly on the computer, which hosts the control system.    (1,4)), for a specific pallet (e.g., Pack ID: 1), as shown in Figure 10b. • A gnuplot panel (Figure 10c) that allows managing the data to be plotted (SL, C, Temperature, different ID pack). • HTTP request Login interface (Figure 10d) for the sensors data extraction, if the router (gateway) sends them in cloud. The HTTP request is enabled by compiling a set of Python coding rows [26]. For instance, to extract the temperature data the rows are:  4)), for a specific pallet (e.g., Pack ID: 1), as shown in Figure 10b. • A gnuplot panel (Figure 10c) that allows managing the data to be plotted (SL, C, Temperature, different ID pack). • HTTP request Login interface (Figure 10d) for the sensors data extraction, if the router (gateway) sends them in cloud. The HTTP request is enabled by compiling a set of Python coding rows [26]. For instance, to extract the temperature data the rows are:

Pro-Active WSN Performance
For the validation of the proposed WSN-based system, the testing room has been monitored for about 10 days and 11 h. The placement of the environmental sensors inside the room is sketched in Figure 11a Indeed, the temperature measurements on 10 days returned, on average, a value of 21.3 °C ± 1.2 °C, with minimum temperature revealed on S3 and S6. The RH recorded in the room in the same time span was 55.73% ± 3%, with minimum humidity on S1, S2 and S6. The adaptive calibration of the

Pro-Active WSN Performance
For the validation of the proposed WSN-based system, the testing room has been monitored for about 10 days and 11 h. The placement of the environmental sensors inside the room is sketched in Figure 11a. Here, it is reported a heat-map of the room during 24 h monitoring (Day1: 8.00-Day2: 8:00). With green dots are reported the L/H/T sensors, a blue rectangle defines a window (l 3 = 4.3 m), and the yellow one represents the door of the room.
Control loop. Typical profiles of temperature and RH readings during a span of 24 h are shown in Figure 11b,c. The figures show the real measurements (dots) and an ordinary least squares (OLS) approximations of the reading (solid line). The waveform trends displayed in Figure 11b,c represent well the typical behavior of the temperature and RH inside the room during all the testing duration. Indeed, the temperature measurements on 10 days returned, on average, a value of 21.3 • C ± 1.2 • C, with minimum temperature revealed on S3 and S6. The RH recorded in the room in the same time span was 55.73% ± 3%, with minimum humidity on S1, S2 and S6. The adaptive calibration of the fudge factor on the temperature sensors ensured a measure dispersion around the OLS-derived profile lower than 1.5 • C.  Figure 11 shows a typical temperature increment of 2.8 °C ± 0.8 °C from 9.00 to 16.00 on S1 and S2. These overheating cycles are due to the sunlight irradiation through the window (the sensors were not directly exposed to the sunlight). These increases fall to the average room temperature with a delay of about 0.1 °C /h. Finally, as expected the RH follow inverse trend w.r.t. the temperature one, showing decreses of about 2.5% when 3 °C temperature increments occur.
QCL Algorithm and SL monitoring. For the QCL algorithm validation, four pallets have been initially placed at the coordinates reported in Table 3. A typical monitoring system [10][11][12][13][14][15]19] would leave the pallets in their own initial position, sending warnings or asking for human intervention. In any case, the overall shelflife reached by all the pallets inside the testing room would be 20.871 days, with the expected expirations for pallets 1 and 4 below 5 days (with a predicted loss of −3 days/24 h considering the profile in Figure 11).   Figure 11 shows a typical temperature increment of 2.8 • C ± 0.8 • C from 9.00 to 16.00 on S1 and S2. These overheating cycles are due to the sunlight irradiation through the window (the sensors were not directly exposed to the sunlight). These increases fall to the average room temperature with a delay of about 0.1 • C/h. Finally, as expected the RH follow inverse trend w.r.t. the temperature one, showing decreses of about 2.5% when 3 • C temperature increments occur.
QCL Algorithm and SL monitoring. For the QCL algorithm validation, four pallets have been initially placed at the coordinates reported in Table 3. A typical monitoring system [10][11][12][13][14][15]19] would leave the pallets in their own initial position, sending warnings or asking for human intervention. In any case, the overall shelflife reached by all the pallets inside the testing room would be 20.871 days, with the expected expirations for pallets 1 and 4 below 5 days (with a predicted loss of −3 days/24 h considering the profile in Figure 11). The proposed algorithm intervenes on the pallets positions by SL priority-based movements as described in Section 4.3. Table 3 shows the number of displacement operated for each pallet, and the number of priority flags (first pallet to be displaced in order to optimize the overall SL-Section 4.3).
The last column of the Table 3 summarizes the path used by the transporter to move the pallet from the initial coordinates to the final one. Initial pallets positions and final ones are shown in Figure 12a,b, respectively. Figure 12a,b also show, on the right, the quality factor (firmness) decays and the SL predictions along the 24 h, for all the monitored nodes. From the figures is possible to extract an improvement of the overall SL of about 5.3 days. The proposed algorithm intervenes on the pallets positions by SL priority-based movements as described in Section 4.3. Table 3 shows the number of displacement operated for each pallet, and the number of priority flags (first pallet to be displaced in order to optimize the overall SL-Section 4.3).
The last column of the Table 3 summarizes the path used by the transporter to move the pallet from the initial coordinates to the final one. Initial pallets positions and final ones are shown in Figures 12a,b, respectively. Figures 12a,b also show, on the right, the quality factor (firmness) decays and the SL predictions along the 24 h, for all the monitored nodes. From the figures is possible to extract an improvement of the overall SL of about 5.3 days.

Conclusions
In this paper, an automated infrastructure for perishable goods supply chain monitoring and their functional management has been presented. It exploits wireless sensor network technologies for goods monitoring and a parallel "real-time" processing for the shelf life prediction and maximization. The low cost of the overall platform and its easy implementation offer a suitable solution for continuous monitoring of the goods, from the farm to the fork, opening to the possibility of packaging monitoring also during the transit. Indeed, e.g., RPi Central Control Unit can manage only a certain number of pallets, and it can be made mobile and transportable, in order to follow the pallets along the whole supply chain.
Moreover, the proposed system offers an effective tool for the reduction of the waste and losses in the supply chain by the integration of Quality Controlled Logistic algorithm that ensures the maximization of the product shelf life and manages the first-to-expire first-out stack. The recorded improvements on agriculture products management show an increment of about 1.2 days (15% of maximum product useful life) of the expected expiration date. In the context of pallets management, the proposed proof of concept showed the logic network for the complete management of autonomous transporters, here based on low-cost platforms.
The re-programmability of the Central Control Unit allows one to implement more complex shelf-life prediction methods, or simply to modify the kinetics parameters in Table 2. Indeed, the approach can be used for the bacterial concentration assessment, due to the dependence from the

Conclusions
In this paper, an automated infrastructure for perishable goods supply chain monitoring and their functional management has been presented. It exploits wireless sensor network technologies for goods monitoring and a parallel "real-time" processing for the shelf life prediction and maximization. The low cost of the overall platform and its easy implementation offer a suitable solution for continuous monitoring of the goods, from the farm to the fork, opening to the possibility of packaging monitoring also during the transit. Indeed, e.g., RPi Central Control Unit can manage only a certain number of pallets, and it can be made mobile and transportable, in order to follow the pallets along the whole supply chain.
Moreover, the proposed system offers an effective tool for the reduction of the waste and losses in the supply chain by the integration of Quality Controlled Logistic algorithm that ensures the maximization of the product shelf life and manages the first-to-expire first-out stack. The recorded improvements on agriculture products management show an increment of about 1.2 days (15% of maximum product useful life) of the expected expiration date. In the context of pallets management, the proposed proof of concept showed the logic network for the complete management of autonomous transporters, here based on low-cost platforms.
The re-programmability of the Central Control Unit allows one to implement more complex shelf-life prediction methods, or simply to modify the kinetics parameters in Table 2. Indeed, the approach can be used for the bacterial concentration assessment, due to the dependence from the monitored parameters. Finally, the proof of concept proposed here is therefore just a demonstration of smart warehouse system feasibility, but future perspectives will concern the performance assessment of the proposed model in real storage conditions, as well as the improvement of the automated pallets management architecture.