Mesh Network Based on MQTT Broker for Smart Home and IIoT Factory

The Industrial Internet of Things (IIoT) provides connection among devices with the ability to monitor and exchange sensor data through the Internet. The need for reliability and high-quality data, as soon as possible that data monitoring able to afford the requirements from the IoT industrial standards. Recently, researchers have created more suitable communication protocols for IIoT devices, of which each has advantages such as XMPP, MQTT, AMQP in which MQTT is most widely used. This study proposes the utilization of MQTT as a communication protocol, which is one of the data communication protocols for IIoT. This work used temperature and humidity sensors, accelerometer sensors, current and voltage sensors because the digital and analog parameters are often needed as parameters of IIoT conditions. Data were scaled in real-time and stored in MySQL database. This study is also completed by mesh networks to deliver data from source to destination efficiently, these nodes using MQTT-based publish and subscribe. The result of this work demonstrates the transmission of data quality and reliability using MQTT protocol and the efficient power saving in mesh networks.


INTRODUCTION
With the developments in hardware, software and a massive number of IIoT devices (Počuča & Giljević, 2012) in recent years have increased to the explosion of the IIoT with the number of connected devices growing such as smart cities, home protection, and traffic management. It is important for these data generated by sensors require to find a diversified system architecture that can afford to both process and store all the data in a database or be displayed on the application interface. Some cases are shown by Grgić et al. (2016) that the benefits of cloud computing are suitable communication, which was satisfied many IIoT requirements, such as data sharing, remote control, and data monitoring.
All researchers have known that the advantages and popularity of HTTP (Chen & Cheng, 2016), HTTP protocol is used for web data exchange which can particularly be used for handling data of hardware, but the ability of HTTP is less suitable when being used on IIoTbased applications. The protocol for IIoT applications requires less bandwidth, real-time response, and low energy consumption because applications are commonly used for small devices. The problem for developers is to choose the optimal solution for their specific IIoT requirements which is specialized handling and sharing amount of data. For example, data transmission between different devices is extremely important because an IIoT system has to deliver instruction or direction to a further appliance to handle the system. message queuing protocol telemetry transport (MQTT), XMPP, and CoAP protocol (Mishra & Kertesz, 2020) were implemented data transfer protocols which are used for exchanging messages on middleware platforms and can be worked with wireless sensor networks (WSN). However, MQTT (Mishra & Biswajeeban, 2018) has provided an advantage to be used on many IIoT purposes and it was forced to work on low-power machines as a lightweight protocol.
This work aims to implement the usability of the MQTT protocol for temperature, humidity, vibration, current, and voltage sensor data acquisition which is developed based on a completed product and combination with a mesh network to provide the effectiveness of the system.

METHODS AND MATERIALS
MQTT Broker based on mesh network will be the best way for Smart home in the future. The Industrial Internet of Things (IIoT) can be defined as a system of sensors and other devices interacting with industrial and manufacturing systems (Awerbuch et al., 2004) all in an effort to enhance business operations. Industries such as manufacturing, power consumption, energy, oil & gas… deploy massive numbers of sensors. These sensors send critical telemetry data to analytics engines, where the data is analyzed for trends or anomalies, enabling organizations to better monitor and improve their applications (Nagabhushan, 2021).
MQTT (Zabasta et al., 2018) has been commercialized in recent years since the Internet of Things became a solution for communication between machine-to-machine (M2M) ( Figure.1). Specifically, IIoT needs the capability to work with low-powered devices to succeed, and MQTT meets all of IIoT's needs in that sense. This publish-subscribe protocol specializes in connecting low-bandwidth devices with limited CPUs and with limited overhead, making it an ideal solution for connecting and communicating between small numbers of lowenergy devices and a central hub. MQTT6 is flexible depending on the quality of performance and message transmission required, which is important because many devices used for IIoT purposes are basic devices without much performance capacity. MQTT plays a crucial role in making IIoT projects more "low-lift" in terms of technical specifications while achieving the desired connections among devices, servers, and applications. This is one of the reasonable options for low-power wireless devices with unstable connections.

Figure 1. Mesh Network
Standard Wi-Fi networks (as reported by Liu and Liu (2014)) usually consist of an access point or base station, normally placed in a central location that communicates with each of the user's devices (Figure 2). Mesh networks (Tsai et al., 2006), which offer peer-to-peer support, place a device, or node, at different locations. Each of these devices communicates with each other, aggregating a "mesh" that allows for a stable signal over a wider range. Devices then connect to the closest node, rather than the central base station to provide a more reliable network connection (Karthika, 2016).

Figure 2. Data transaction inside mesh network
Mesh networking is a suitable way to efficiently organize the exchange of data between IIoT devices. It works best for transferring small data packages and allows you to connect more nodes while keeping network performance at a high level. Figure 3 shows a scenario of an MQTT broker collect data from sensors and transfer through a mesh network in the IIoT factory. Figure 4 shows a scenario of an MQTT broker collect data from sensors and transfer through a mesh network in Smart Home.  The IIoT Nodes will be placed around the factory, these nodes connect to multiple other nodes and communicate with each other to transfer data across a large area. Every machine or device can access to mesh network which can send and receive information. All the sensors: temperature sensor, humid sensor, vibration sensor, voltage sensor, and current sensor automatically collect data from machine tools, CNC, electrical cabinets, transfer machines, grinders. After collecting data from machines, data will be uploaded to the broker by IIoT nodes. IIoT nodes are responsible for receiving all data measurements, filtering the data measurements, determining who is subscribed to each data measurements, and sending data measurements to these subscribed clients. The IIoT nodes also hold the session data of all clients that have persistent sessions, including subscriptions and missed data measurements. Another responsibility of the IIoT nodes (broker) is the authentication and authorization of clients. By subscribing to the topic on IIoT nodes, clients can monitor the trend or inconstant of the result measurements. All details of the result measurements will be updated in 1 second, which is useful for clients to observe the change of measurements. Once the connection is established, the broker keeps it open until the client sends a disconnect command or the connection breaks.

EXPERIMENTAL RESULTS
The subscribers can monitor data through a web platform, which was built using HTML, PAP, and Javascript. All of those data will be added with a feature to save information to the MySQL database. The users communicated to the MQTT broker by Web Socket which allowed data transactions can full-duplex and real-time. Detailed information is in Figures 5 and 6. In this paper, there were 3 parameters tested that were temperature, humid and current. The MQTT broker using a script to publish data from the sensors to the topic which had been named before and contained the sensor data, device ID. By logging into the MQTT server, data from each sensor were displayed on the web page and database. The web page was created for clients to manage which data sensors will be displayed on the screen and included their information. Moreover, all the data can display in a line diagram and the data will be updated continuously every 1 second.
In Figure 7, the system is designed as a Wifi module, which allows many kinds of IoT devices to connect to the mesh network. Any devices such as electronic devices, sensors, computers, and microcontroller boards can connect to the MQTT Board through UART, SPI, SDIO, I2C, I2S. Besides, it can connect directly to sensors by using 12-bit ADC and 2 x 8-bit DAC, make it suitable for various devices. Detailed information is in Figure 8.