Development of Smart Refrigerator Based on Message Queuing Telemetry Transport

boxes to


Introduction
Online shopping is becoming increasingly popular. Shopping for agricultural products online currently accounts for approximately 1% of food consumption; the e-commerce value for Taiwanese agricultural products is thus estimated to be 15 billion New Taiwan dollars (NTDs). (1) This shows that the economic scale of e-commerce for fresh food products is considerable and that there is still plenty of room for growth. In addition to paying attention to prices when shopping for food products online, consumers also take note of the delivery speed when choosing online shopping platforms. The logistics of last-mile deliveries are the ultimate test for fresh food products.
The perishability of fresh food products requires them to be kept at low temperatures when being delivered, and also requires consumers to be present when they are delivered so as to avoid reduced freshness due to room-temperature exposure or multiple deliveries. As most people have very busy lives, concentrating deliveries at times when people are off work will require an increase in the number of couriers or cause delays. Customers that can accept the delivery of fresh food products at convenience stores can avoid wasting resources from multiple deliveries, but missing the pick-up period will result in food products being returned. (2) Improving the effectiveness of last-mile deliveries is crucial to increasing the ratio of fresh food products purchased online.
The aim of this study is to allow consumers to accept deliveries at any time after purchasing products online to avoid delays from not being able to accept deliveries at home. Consumers that have purchased fresh food products will not have to concern themselves with being unable to accept deliveries immediately and having food products perish. We designed a smart refrigerator cabinet whose temperature can be remotely controlled by consumers' mobile phones to refrigerate food products or maintain the cabinet at room temperature. The smart refrigerator cabinet can automatically detect the temperature and humidity inside the cabinet and display them on consumers' mobile phones. Consumers can place their smart refrigerator cabinets at their front door, then have the courier contact them once they have arrived with the products, remotely operate the cabinet door, and adjust the cabinet temperature to immediately accept the delivery.
The U.S. Food and Drug Administration (FDA) divides food safety issues into six categories on the basis of severity: toxigenic and pathogenic microorganisms, nutritional hazards, environmental contaminants, natural toxic constituents, pesticide residues, and food additives. (3) Toxigenic and pathogenic microorganisms contribute to the perishability of fresh food products, which is the focus of this study.
The main factors that contribute to the perishability of fresh food products are the growth and activity of microorganisms, the activity of natural food enzymes, temperature, humidity, air, light, and time. Low-temperature environments can inhibit the growth and reproduction of microorganisms, and also slow down the chemical reactions caused by food enzymes to prolong the storage life.
Certified Agricultural Standards (CAS) (in Taiwan) emphasize the management of temperature and time and the technology of controlling microorganisms during the processing of chilled prepared foods, and strictly require food products to be stored or transported at temperatures below 7 °C and above the free point to reduce the growth and reproduction of microorganisms in food products. (4) Therefore, we will regulate the refrigeration temperature to below 7 °C so that consumers will have peace of mind regarding food safety.
This study is based on a Japanese delivery box. Even though ordering products online can be very convenient, being away from home during work or business trips forces people to ask couriers to make additional deliveries or people to return home at a different time or accept the delivery at a convenience store, where they may have to wait in a long queue, increasing the burden on consumers. However, placing our novel delivery box at the front door would avoid these problems since consumers can receive the courier's delivery without having to be at home.
Finally, we also examine mobile electronic refrigerators currently on the market. They can be used for refrigeration or insulation through the thermoelectric cooling of semiconductors for low power consumption and zero pollution from fluorine.

System Structure
The temperature and door of the smart refrigerator cabinet are controlled through a remote device, and its temperature and humidity are monitored in real time. Its feedback circuit can help determine the point of malfunction of the cooling chip module or power supply equipment. The system structure is shown in Fig. 1. For a function to be successfully executed, the embedded system must be connected to various sensors and hardware devices. The cable used to connect the different hardware components of the smart refrigerator cabinet is shown in Fig. 2.  The interior of the smart refrigerator cabinet has dimensions of 45 × 30 × 30 cm 3 . A photograph of the smart refrigerator cabinet is shown in Fig. 3.
The evaluation board (EVB), the temperature and humidity sensors, and the door lock motor are all embedded in the cabinet door. This allows users to monitor the temperature and humidity inside the cabinet, and open or close the cabinet door in real time. The system embedded in the cabinet door is shown in Fig. 4. After the embedded system sends out a signal to adjust the temperature, the signal control relay triggers the thermoelectric cooling chip module to have a power input of 12 V to control the cabinet temperature. The relay and cooling chip modules are integrated as shown in Fig. 5.

Monitoring System
Message Queuing Telemetry Transport (MQTT) was invented in 1999 by Dr. Andrew Stanford-Clark of IBM and Arlen Nipper of Arcom (now Eurotech). (5) In 2014, it was approved by the Organization for the Advancement of Structured Information Standards (OASIS) as an international standard. (6) It was designed for devices with low bandwidth and high latency, and unreliable networks. The design principle was to minimize network bandwidth and equipment resource requirements while ensuring reliability and a certain degree of delivery assurance. This principle also led to the creation of the ideal protocol for the emerging machine to machine (M2M) Internet of Things, and is also the ideal choice for mobile applications where bandwidth and battery power are both important. (5)    The MQTT communication protocol is built on the TCP/IP protocol. It uses the publish/ subscribe model to offer different quality of service (QoS) message delivery levels. Higher QoS message delivery levels can deliver messages more reliably but may have delayed deliveries, possibly caused by network latency or the requirement of a larger bandwidth. (7) MQTT has the following five characteristics: (8) (1) It is a one-to-many communication protocol that is implemented by means of publish/subscribe. There are three functions: broker, publisher, and subscriber. The broker is the server for relaying MQTT communication, the publisher is the user transmitting messages, and the subscriber is the user receiving messages. Messages transmitted and received using MQTT will be tagged with topic addresses, and users will use the topics as target audiences to deliver or receive messages similarly to a post office box at a post office. (9) (2) It uses TCP/IP to provide the basic network connectivity.
(3) It provides three QoS message delivery levels. The different QoS message delivery levels are shown in Table 1. (4) The message headers are fixed to 2 bytes, therefore reducing the extra load when packets are transmitted and reducing the required bandwidth. (5) The last will and testament functions are subscriber mechanisms that notify the subscribers with will messages when there are abnormal client disconnections. The Microsoft SQL server is a relational database developed by Microsoft Corporation. The SQL server management studio (SSMS) is an integrated environment that can be used to manage any SQL infrastructure, ranging from SQL servers to SQL databases. SSMS provides tools to set up, monitor, and manage SQL execution entities. With SSMS, users can deploy, monitor, and upgrade the layer components of application data. Users can also build queries and scripts with SSMS on local computers or in the cloud. (10) This program uses an SQL database to record user data and information on the smart refrigerator cabinet. It also uses MQTT to receive real-time information and view the cabinet real-time temperature and humidity set temperature conditions, and open or close the cabinet door. A flow chart of the application developed to control the smart refrigerator cabinet is shown in Fig. 6.
After opening the application, users will be directed to an account login interface. Users that have already registered an account can directly enter their mobile phone number and password to log in. Users that have not registered accounts will have to click on "Register New Account" for registration and will be directed to the new account registration page. After correctly filling in the relevant information, users will be directed back to the login interface. Users will then enter the real-time monitoring page after logging in with the correct mobile phone number and password, which will allow them to view real-time information about the smart refrigerator cabinet. Visual Basic 6.0 was mainly used to develop the program for monitoring the smart refrigerator cabinet. The program is connected to an SQL database to allow users to search all user registered information, monitor the temperature and humidity of each refrigerator cabinet, and display malfunction indicators to assist troubleshooting. Every troubleshooting scenario is carefully recorded by the program.
If an error of the smart refrigerator cabinet cannot be fixed, the program will promptly display a reminder and the Malfunctioning Cabinet table. In addition to displaying the status of the error, this table also has customer information to assist contacting the manufacturer to make the necessary repair. This table can also update the maintenance status, and the statuses of all malfunctioning cabinets are recorded in the Error Records table. If the smart refrigerator cabinet has no errors, users will directly enter the table containing all information on the customers page. On this page, the consumer can select any search mode to filter and search for the required information.
Double-clicking on the columns in the tables on the Customer Information and Error Status pages allows users to enter the Smart Refrigerator Cabinet Details page. The information of the selected date and time is displayed in a table. If there is a new error on any page, the program will immediately provide a pop-up notification and redirect the user back to the Error Status Update page. Users can view malfunctioning cabinets and user information in real time.

Conclusion
We integrated temperature and humidity sensors, cooling chip controls, door lock controls, MQTT, and SQL servers to develop an embedded system for a smart refrigerator cabinet. A mobile phone application and computer monitoring software were also developed. The software allows users to use their mobile phones to monitor the status of the smart refrigerator cabinet in real time, while the computer monitoring program on the server end not only allows users to monitor the smart refrigerator cabinet in real time, but also records all errors and user information, which enables contact with manufacturers for relevant repairs. The obtained results suggest that food can be kept fresh by the smart refrigerator cabinet, without the user having to wait at home to receive it.