MQTT (Message Queuing Telemetry Transport), also known as Message Queuing Telemetry Transport protocol, is a "lightweight" communication protocol based on publish/subscribe mode. It is a communication protocol built on TCP/IP and released in 1999. The advantage of MQTT is that it can provide real-time, reliable messaging services for connecting remote devices with little code and limited bandwidth. As a real-time communication protocol with low energy consumption and low bandwidth occupation, it has been widely used in the Internet of Things, small devices, mobile applications and so on.
MQTT server (message agent), the common MQTT server is not a bunch of cabinets in the macro computer room, but based on the Erlang/OTP platform development of a software, and then there are computers and other devices to run this software. Intuitively understood as a server or a cluster of servers running MQTT message server software.
Figure 1-1 shows the functions:
(1) Accept network connections from clients
(2) Accept the information released by the client
(3) Handle subscription and unsubscription requests from clients
(4) Forward application messages to subscribed customers.
MQTT Protocol Network Transmission
MQTT will build the underlying network transport, it will establish the client and server connections, and Provides ordered, lossless, bidirectional transmission based on byte stream. When sending data, MQTT will associate the associated quality of service (Qos) with the Topic.
(1) Protocol principle
The communication process of MQTT protocol needs to be completed by both client and server. There are three identities: Publish, Broker and Subscribe. The message publisher and subscriber can both be clients, and the message broker is the MQTT server.
① The implementation of MQTT
Topic: Which can be understood as the type of message;
Payload: Indicates the message content, which is the data content to be used
An application or device using the MQTT protocol, which is a network connection based on the MQTT server, is used to publish information, subscribe to publish information, unsubscribe or delete application messages, and disconnect from the server.
(2) MQTT protocol characteristics
The protocol is designed to communicate with remote sensors and control devices in low-bandwidth, unreliable networks. It has the following main features:
① Use the publish/subscribe message mode to provide one-to-many message publishing and decoupling application programs.
② The message transmission of the load content mask.
③ Use TCP/IP to provide network connections.
④ There are three kinds of message publishing quality of service, message publishing (Qos: 0 at most once, 1 at least once, 2 only once)
⑤ Small transmission, small traffic demand.
The Communication between MQTT Server and Terminal Monitoring Device
Many meters connect to gateways to enable devices to interact with MQTT servers. However, the ADW300 meter, one of our ADW series meters, has the Internet function itself, including 4G and WIFI, which enable the device to have the Internet function through the IoT card or LAN. Reduce the trivial process of connecting the device to the gateway and then the server, and realize the industrial Internet of Things.
1. ADW300 Three Phase Wireless Energy Meter Main Functions:
High Precision: Class 0.5S
Rich functions: Voltage , Current, Power factor, Frequency, Active power, Reactive power, Apparent power, Harmonic, Temperature Measurement, DI/DO, Alarm, etc.
Many Options for Communication: RS485, LoRa, NB, 4G, WiFi
ADW310 Single Phase Wireless Energy Meter Main Functions:
Input current AC 20(100)A
Active energy accuracy: Class 1
Rich functions: Voltage , Current, Power factor, Frequency, Active power, Reactive power, Apparent power, Temperature Measurement, Digital input/Digital output, Leakage of current alarm, etc.
Many Options for Communication: RS485, 4G, WiFi, LoRa
2. Standardized MQTT protocol
Subscriptions include Topic filters and Quality of Service (QoS). A subscription is associated with a Session. A session can contain multiple subscriptions. Each subscription in each session has a different topic filter.
After each client establishes a connection with the server, there should be a stateful interaction between the session client and the server. The session exists between a network or may span multiple continuous network connections between the client and the server.
③ Topic Name
A tag connected to an application message that matches the server's subscription and the server sends the message to each client whose subscription matches the tag
④ Data Upload
The wireless transmission of the electricity meter achieves small transmission and small traffic demand. The data uploading process of this electricity meter is simple. (See appendix for details) the redundant data uploading steps are optimized to promote customized data uploading. It includes commonly used electrical parameter data, signal strength, active power demand, voltage-current ratio, temperature, DI state, voltage-current harmonic distortion rate, peak and valley electric energy and so on.
To sum up, in the current environment of Internet of Things technology, MQTT server has been adopted by various businesses, because MQTT server and MQTT protocol can meet their intelligent management needs. Some production workshops of many enterprises need to use wireless equipment to monitor the working state of electrical equipment, and the production workshops of enterprises are mostly scattered independent electrical equipment, if each equipment is installed gateway, the cost of transformation is a great amount of capital. Therefore, in order to save costs, most enterprises often install a batch of electricity meters for wireless monitoring equipment -- ADW300. Through CT, various equipment parameters of cables and production lines are collected, mainly including electric parameter data such as current and voltage, and the obtained data is uploaded to the MQTT server cloud in real time. Then subscribe to the subject of MQTT server through the Internet of Things platform and database to obtain the data of terminal monitoring equipment, realize the two-way communication between terminal and cloud, and build a powerful data channel. The obtained data is stored in the cloud database of MQTT server, which can ensure the security of the data and build the power management and display system. Through cloud technology, big data and the Internet, the obtained data will be displayed to the foreground, and users can monitor the power data of equipment and cables in real time by logging in the mobile APP and web page.
Related Articles about Acrel