Energy storage EMS alarm system and method based on mqtt communication protocol
By introducing the two-way communication technology of the MQTT protocol into the energy storage EMS system, combining cloud servers, distributed Broker architecture and security enhancement modules, the low polling efficiency and security risks of the HTTP protocol are solved, real-time data transmission and efficient and reliable operation of the system are achieved.
Patent Information
- Application Number
- CN202510557355.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-07-08
AI Technical Summary
In the existing energy storage EMS systems, the polling mechanism of the HTTP protocol leads to untimely data transmission, untimely alarms, wasted network resources, and lack of active communication capabilities, which poses security risks.
Using two-way communication technology based on MQTT protocol, cloud servers are introduced to maintain connection with local servers. Clients and cloud servers obtain data and issue commands by subscribing to topics, combining distributed Broker architecture, TLS encryption and access control lists to ensure data transmission security and system scalability.
Real-time data acquisition and command issuance are realized, system operation efficiency is improved, architecture differences and security guarantee problems are solved, and system timely fault handling capabilities are ensured.
Smart Images

Figure CN120281762A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of digital information transmission, and particularly relates to an energy storage EMS alarm system and method based on the MQTT communication protocol. Background Art
[0002] Energy storage will be a key technology affecting the future energy pattern, and it is of great significance for the safe, stable and efficient operation of its access to the energy system, improving the comprehensive energy utilization efficiency, promoting the development of the new energy industry, and driving the energy strategic transformation. Energy storage has a wide range of applications in the power system, covering all aspects of power generation, transmission, distribution and end-users.
[0003] The energy management system (EMS) is an energy management solution aimed at improving the flexibility and reliability of the power system. With the rapid development of renewable energy, how to effectively store and manage electric energy has become an important issue. The EMS realizes the efficient utilization and scheduling of electric energy by combining energy storage devices with an intelligent management system.
[0004] In most mainstream EMS systems, the HTTP protocol is used for transmission. The client connects and communicates in the form of HTTP. The data collected by the system is transmitted to the client through HTTP, and the client then displays the data. HTTP is based on the request-response model, that is, the communication can only be initiated by the client, and the server makes a response, stateless and connectionless.
[0005] When a conventional EMS system uses HTTP to respond to requests to collect background data, the client periodically sends an AJAX request to the server. After receiving the request, the server immediately returns the response information and closes the connection. This process can only be carried out passively, that is, from the client sending a request to the server responding. The server cannot actively contact the client and can only be initiated by the client. This characteristic of one-way requests determines that if the server has continuous state changes, it is very troublesome for the client to obtain information. Only "polling" can be used: every once in a while, an inquiry is sent to find out if there is new data on the server. This results in the EMS system being untimely in data transmission, untimely in alarm, prone to security hazards, low polling efficiency, and waste of network resources. In view of this, the present invention provides an energy storage EMS alarm system and method based on the MQTT communication protocol. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to overcome the above-mentioned disadvantages of the prior art and provide an energy storage EMS alarm system and method based on the MQTT communication protocol.
[0007] The technical solution adopted to solve the above technical problem is:
[0008] An energy storage EMS system based on MQTT two-way communication, including a client, a cloud server and a local server. The client is used to obtain data by subscribing to topics and publish and send commands to relevant topics. The cloud server is used to keep connecting with the local server to obtain real-time data transmitted by the local server program and establish a connection with the active client. The local server is used to collect data and keep connecting with the cloud server for a long time, publish real-time data and subscribe to the received message topics;
[0009] The cloud server adopts the MQTT two-way communication protocol.
[0010] The interface of the client is displayed in the form of a web browser or an app. The interface of the client includes data display and data control.
[0011] The energy storage EMS system further includes an architecture optimization module, which is used to introduce a distributed Broker architecture to improve the scalability and fault tolerance of the system, and transfer the data processing logic from the client to the Broker or the cloud server.
[0012] The energy storage EMS system further includes a security enhancement module, which is used to enable TLS encryption for MQTT communication to ensure data transmission security, and configure an access control list to restrict the access rights of the client to the Broker.
[0013] The energy storage EMS system further includes a monitoring module, which is used to use Prometheus and Grafana to monitor the MQTT communication status in real time, create alarm rules, and enable detailed logs, and use the MQTT test tool to verify the communication and monitor the network status.
[0014] An implementation method of an energy storage EMS system based on MQTT two-way communication, characterized in that the specific implementation steps are as follows:
[0015] The cloud server establishes an MQTT server;
[0016] The EMS local server connects to the cloud server through the network and connects to the cloud MQTT server, publishes the collected real-time data through topics and subscribes to the message topics to be received;
[0017] When the client is in an active state, it establishes a connection with the cloud MQTT server. When real-time data is needed, it subscribes to relevant topics, processes and displays the real-time data after obtaining it;
[0018] When the client sends a command, it can publish a message to the topic subscribed by the local server. After the local server receives the message, it further processes the message;
[0019] The cloud server remains continuously connected to the local server without interruption and obtains real-time data transmitted by the local server program in real time;
[0020] The client only maintains a connection with the cloud server when it is in an active state. When the client is closed or in an inactive state, the MQTT connection is disconnected.
[0021] The beneficial effects of the present invention are as follows:
[0022] (1) Through the design of the client, cloud server and local server, the present invention develops an energy storage EMS system based on MQTT protocol two-way communication in the field of energy storage systems. Aiming at the disadvantages of low efficiency of HTTP polling and waste of network resources, the MQTT two-way communication technology is adopted, which not only satisfies the acquisition of real-time data, ensures the real-time update of energy storage power station data, but also satisfies the command issuance, achieves the purpose of controlling the energy storage system, and improves the overall operation efficiency;
[0023] (2) The present invention overcomes the architecture differences and security guarantee problems that occur when the MQTT protocol replaces the existing HTTP protocol, as well as the problem of ensuring that the system can timely detect and handle communication failures during subsequent use. This solution introduces a distributed Broker architecture to optimize the existing architecture, enables TLS encryption, configures an access control list to ensure security, sets up a monitoring module to monitor the MQTT communication status in real time, creates an alarm rule, so that MQTT can be successfully applied to the energy storage EMS system. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 is a schematic structural diagram of the present invention;
[0025] Figure 2 is a schematic working principle diagram of the present invention.
[0026] Reference numerals: 1, client; 2, cloud server; 3, local server. DETAILED DESCRIPTION OF THE INVENTION
[0027] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0028] Such as Figure 1 - Figure 2As shown in the figure, this embodiment provides an energy storage EMS system based on MQTT two-way communication. The energy storage EMS system includes a client 11, a cloud server 2, and a local server 3. The client 1 interface is presented in the form of a web browser or an app, including data display and command issuance. The local server 3 collects data and maintains a long-term connection with the MQTT server of the cloud server 2, publishes real-time data, and subscribes to the received message topics. When the client 1 is in an active state, it establishes and maintains a connection with the MQTT server of the cloud server 2, obtains data by subscribing to topics, and publishes and issues commands to relevant topics.
[0029] Aiming at the disadvantages of low efficiency and waste of network resources in the existing HTTP polling, this patent proposes to introduce a cloud server 2 in the application and use MQTT as the data collection and communication medium. Its greatest feature is that the local server 3 can actively push information to the client 1 through the cloud server 2, and the client 1 can also actively send information to the local server 3 through the cloud server 2, which is a truly two-way equal dialogue.
[0030] Specifically, MQTT is a lightweight publish-subscribe message transmission protocol designed for resource-constrained environments, which is very suitable for occasions with low power, limited bandwidth, or unstable networks. Its small packet size, topic-based message routing, and multiple quality of service (QoS) levels make it perform excellently in Internet of Things applications that require high efficiency and reliability;
[0031] Compared with the traditional HTTP mode where each request-response requires the client 1 to establish a connection with the server, MQTT is a TCP long connection communication mode similar to a socket. Once the MQTT connection is established, subsequent data is transmitted in the form of a frame sequence. Before the client 1 disconnects or the server side interrupts the connection, there is no need for the client 1 and the server to re-initiate a connection request. In the case of a large number of concurrent connections and a large traffic load in the interaction between the client 1 and the server, it greatly saves the consumption of network bandwidth resources and has obvious performance advantages. Moreover, the client 1 sends and receives messages on the same persistent connection, with obvious real-time advantages. Therefore, it has natural advantages in applications in systems such as the EMS system with very high real-time requirements.
[0032] In a further embodiment, if the user's original system is completely designed based on the HTTP protocol, directly replacing it with MQTT requires re-adapting the communication protocol on the device side. Different devices (such as PCS, BMS, etc.) need to be customized and developed to support the MQTT protocol. Since the request-response mode of HTTP is relatively simple, while the publish-subscribe mode of MQTT requires the introduction of a message broker (Broker), therefore, an architecture optimization module is set up to introduce a distributed Broker architecture, improve the scalability and fault tolerance of the system, and transfer the data processing logic from the client 1 to the Broker or the cloud server 2, reducing the computing burden on the device side.
[0033] Specifically, develop a driver or middleware that supports MQTT, and quickly build an MQTT Broker with the help of open-source tools (such as EMQX, Mosquitto);
[0034] For the construction of the MQTT Broker, it is necessary to select a suitable MQTT Broker software, such as EMQX or Mosquitto. At the same time, it is necessary to ensure that the server or virtual machine meets the hardware and software requirements of the selected Broker software, and necessary dependency packages and development tools need to be installed;
[0035] Subsequently, install the MQTT Broker. (Taking EMQX as an example, it is necessary to visit the EMQX official website to download the latest installation package or use the package management tool for installation, and execute the installation command, such as: sudo apt-get instal l emqx);
[0036] Subsequently, it is necessary to configure the MQTT Broker. Specifically, it is necessary to edit the configuration file (usually located at / etc / emqx / emqx.conf) to adjust the Broker parameters, set key parameters such as the listening port, maximum connection number, and message retention policy, and configure the authentication and authorization mechanisms to ensure communication security.
[0037] Then start the MQTT Broker, use the command to start the Broker service, such as: sudo systemctl startemqx, and check the log file to confirm whether the Broker is started and running normally;
[0038] Finally, conduct testing and verification. Use an MQTT client 1 tool (such as MQTTBox, MQTT.fx) to connect to the Broker for testing, verify the publish-subscribe function, the reliability and real-time performance of message delivery, and adjust the configuration parameters to optimize the performance and stability.
[0039] Through the above operations, the energy storage EMS system based on the HTTP protocol can be replaced with the MQTT protocol to achieve more efficient and real-time data communication. With the continuous development of Internet of Things technology, the MQTT protocol will play an important role in more fields, bringing greater innovation and transformation to the energy storage EMS system.
[0040] In a further embodiment, although the MQTT protocol is lightweight, additional configuration is required in terms of security. At the same time, the system needs to be able to handle connection interruptions caused by network instability and ensure the reliability of data transmission. Therefore, a security enhancement module is set up to enable TLS encryption for MQTT communication to ensure data transmission security, and an access control list (ACL) is configured to restrict the access rights of Client 1 to the Broker.
[0041] Specifically, TLS encryption can ensure the confidentiality and integrity of data during transmission, preventing data from being stolen or tampered with. The following are the detailed steps to enable TLS encryption:
[0042] 1. Obtain a certificate from a certified certificate authority (CA), or use a self-signed certificate (for test environments). You can also use tools (such as OpenSSL) to generate a self-signed certificate. The generation code is openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key, which will generate server.crt (certificate file) and server.key (private key file).
[0043] 2. Configure the MQTT Broker to enable TLS. Taking EMQX as an example, by logging in to the EMQX Dashboard, go to the "Listeners" page, select the MQTT listener, enable SSL / TLS, and upload the certificate file (server.crt) and private key file (server.key), save the configuration and restart the Broker. It can also be configured through the configuration file, that is, add the following content to the EMQX configuration file (such as emqx.conf):
[0044] listener.mqtt Cauldron=8883
[0045] listener.mqtt.Cauldron.tls=true
[0046] listener.mqtt.Cauldron.cacertfi le= / path / to / server.crtlistener.mqtt.Cauldron.certfile= / path / to / server.crt
[0047] listener.mqtt.Cauldron.keyfile = / path / to / server.key
[0048] Then restart the EMQX service.
[0049] 3. Configure Client 1 to connect to the Broker using TLS, that is, specify the certificate file path in the Client 1 code (if two-way authentication is required). The sample code (Python) is as follows:
[0050]
[0051] 4. Use the MQTT Client 1 tool (such as MQTTBox, MQTT.fx) to test the TLS connection, and check the logs of the Broker and Client 1 to ensure that the connection is successful and there are no errors.
[0052] At the same time, ACL can be used to restrict the access rights of Client 1 to the MQTT Broker, ensuring that only authorized Client 1 can publish or subscribe to specific topics. The following are the detailed steps for configuring ACL:
[0053] 1. The ACL rules define the access rights of Client 1 to specific topics (such as publish, subscribe). Example rules:
[0054] Allow user user1 to subscribe to the topic sensor / temperature.
[0055] Deny user user2 from publishing messages to the topic control / command.
[0056] 2. In EMQX, the ACL rules can be defined through the configuration file acl.conf:
[0057] {user = user1,topic = sensor / temperature,action = subscribe,permission = allow}
[0058] {user = user2,topic = control / command,action = publish,permission = deny}
[0059] Save the configuration file and restart the Broker.
[0060] 3. For dynamic permission management, an external database (such as MySQL, Redis) can be used to store the ACL rules:
[0061] Enable the ACL plugin:
[0062] plugins.emqx_auth_mysql = on
[0063] Configure the database connection:
[0064] auth.mysql.server = 127.0.0.1:3306
[0065] auth.mysql.username = root
[0066] auth.mysql.password = password
[0067] auth.mysql.database = mqtt_acl
[0068] auth.mysql.query = SELECT permission FROM acl WHEREusername = '%u' ANDtopic = '%t' AND action = '%a'
[0069] Create an ACL table in the database and populate it with rules.
[0070] 4. For complex scenarios, ACL rules can be dynamically added, modified, or deleted via the HTTP API. Example API calls (using curl):
[0071]
[0072]
[0073] 5. Connect to the Broker with different user identities, attempt publish and subscribe operations, check the Broker logs, and confirm that the ACL rules are effective.
[0074] In a further embodiment, after the user replaces the protocol, the operation and maintenance team needs to be familiar with MQTT monitoring and management tools such as the MQTTX client 1, the EMQX platform, etc. They also need to establish a new monitoring mechanism to ensure that the system can promptly detect and handle communication failures. Set up a monitoring module, use Prometheus and Grafana to monitor the MQTT communication status in real time, create alarm rules, promptly detect and handle communication failures, enable detailed logs, and use MQTT test tools to verify communication and monitor the network status.
[0075] Specifically, a visualization monitoring mechanism needs to be established using Prometheus and Grafana. The operation steps are as follows:
[0076] 1. Prometheus is an open-source monitoring and alerting tool suitable for collecting and storing time series data. The following are the deployment steps:
[0077] Install Prometheus:
[0078] Download the binary file of Prometheus or use the Docker image:
[0079] docker run -d -p 9090:9090 prom / prometheus
[0080] Configure the Prometheus configuration file (prometheus.yml) to specify the data source and monitoring targets.
[0081] Configure the integration of Prometheus with the MQTT Broker:
[0082] Use the MQTT Exporter of Prometheus (such as emqx-prometheus-exporter) to extract monitoring data from the MQTT Broker.
[0083] Add the scrape configuration of the MQTT Exporter to the Prometheus configuration file:
[0084]
[0085] 2. Deploy Grafana
[0086] Grafana is an open-source visualization platform that supports multiple data sources (including Prometheus). The following are the deployment steps:
[0087] Install Grafana:
[0088] Download the binary file of Grafana or use the Docker image:
[0089] docker run -d -p 3000:3000 grafana / grafana
[0090] Access the Grafana web interface (default address: http: / / localhost:3000).
[0091] Configure the Prometheus data source:
[0092] Add Prometheus as a data source in Grafana:
[0093] Navigate to "Configuration" > "Data Sources".
[0094] Select "Prometheus" and enter the URL of the Prometheus server (e.g., http: / / prometheus:9090).
[0095] Create a monitoring dashboard:
[0096] Create a new dashboard in Grafana and add charts to display the MQTT communication status:
[0097] Use a query statement (e.g., rate(mqtt_messages_received_total[1m])) to monitor the message reception rate.
[0098] Add alert rules, for example, trigger an alert when the message reception rate is below a threshold.
[0099] To facilitate troubleshooting and debugging of MQTT communication, detailed logs can be enabled. Specifically, enable the detailed logging function of the MQTT Broker (such as EMQX or Mosquitto) to record operations such as connections, subscriptions, and publications. You can also use the client 1 logs to ensure that the client 1 library (such as MQTTX or MQTT Assistant) enables logging for problem troubleshooting.
[0100] Moreover, an MQTT test tool can be used to simulate fault scenarios to test the system's fault tolerance. Specifically, use a full-featured MQTT client 1 tool that supports operations such as publishing, subscribing, and viewing message flows; use the mosquitto_pub and mosquitto_sub command-line tools to manually send and receive messages to verify the normalcy of communication.
[0101] You can also use a network monitoring tool (such as Wireshark) to capture MQTT communication packets and analyze connection interruption or latency issues.
[0102] To ensure the smooth operation of the system, training and technical support are required for the operations and maintenance team. The operations and maintenance team should be familiar with the configuration and management of EMQX or Mosquitto, including user authentication, ACL configuration, log management, etc. Learn how to locate problems through logs, such as checking connection errors and subscription failures, and master common troubleshooting methods, such as using MQTT test tools and analyzing network status. Train the operations and maintenance team to learn how to use these tools to create monitoring dashboards, set alert rules, learn how to quickly connect to the Broker, view message flows, and debug communication problems through these tools to ensure that problems can be quickly responded to and resolved.
[0103] An implementation method of an energy storage EMS system based on MQTT two-way communication is as follows:
[0104] S1. The cloud server 2 establishes an MQTT server;
[0105] The EMS local server 3 is connected to the cloud server 2 through the network and is connected to the cloud MQTT server. The collected real-time data is published through a topic. The published topic is appended with a device number, such as realtimeData / 1, and the data is {"device":"temp","data":"37"}; and it subscribes to topics such as order / 1;
[0106] It should be noted that the cloud server 2 and the local server 3 always maintain an uninterrupted connection and obtain the real-time data transmitted by the local server 3 program in real time;
[0107] S2. When the client 1 is in an active state, it establishes a connection with the cloud MQTT server. When real-time data is required, it subscribes to relevant topics, processes and displays the real-time data after obtaining it; it subscribes to the topic realtimeData / 1, obtains the real-time data {"device":"temp","data":"37"} and displays or processes it;
[0108] S3. When the client 1 issues a command, it can publish a message to the topic subscribed by the local server 3. After the local server 3 receives the message, it further processes the message; when issuing an instruction, it can publish a message, such as {"operate":"setData:1"} to the topic order / 1. Since the local server 3 subscribes to this topic, it can receive the message {"operate":"setData:1"} and can then process the message further;
[0109] S4. The client 1 only maintains a connection with the cloud server 2 when it is in an active state. When the client 1 is closed or in an inactive state, the connection with the cloud MQTT server is disconnected.
[0110] The above is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention.
Claims
1. An energy storage EMS alarm system based on the MQTT communication protocol, characterized in that, It includes a client (1), a cloud server (2) and a local server (3): The client (1) is used to obtain data by subscribing to topics and publish and send commands to relevant topics; The cloud server (2) is used to keep connected to the local server all the time to obtain real-time data transmitted by the local server program and establish a connection with the active client; The local server (3) is used to collect data, keep connected to the cloud server for a long time, publish real-time data and subscribe to the received message topics.
2. The energy storage EMS alarm system based on the MQTT communication protocol according to claim 1, wherein, The cloud server (2) adopts the MQTT two-way communication protocol.
3. The energy storage EMS alarm system based on the MQTT communication protocol according to claim 1, characterized in that, The interface of the client (1) is presented in the form of a web browser or an app, and the interface of the client includes the display and control of data.
4. The energy storage EMS alarm system based on the MQTT communication protocol according to claim 1, characterized in that, It also includes an architecture optimization module, which is used to introduce a distributed Broker architecture, improve the scalability and fault tolerance of the system, and transfer the data processing logic from the client (1) to the Broker or the cloud server (2).
5. The energy storage EMS alarm system based on the MQTT communication protocol according to claim 4, characterized in that, It also includes a security enhancement module, which is used to enable TLS encryption for MQTT communication to ensure data transmission security, and configure an access control list to limit the access rights of the client to the Broker.
6. The energy storage EMS alarm system based on the MQTT communication protocol according to claim 1, wherein, It also includes a monitoring module, which is used to use Prometheus and Grafana to monitor the MQTT communication status in real time, create alarm rules, enable detailed logs, and use an MQTT test tool to verify the communication and monitor the network status.
7. A method for alarming an energy storage EMS based on the MQTT communication protocol, according to the energy storage EMS alarming system based on the MQTT communication protocol described in claim 1, characterized in that, It includes the following steps: The cloud server (2) establishes a cloud MQTT server; The ems local server (3) connects to the cloud server (2) through the network and connects to the cloud MQTT server, publishes the collected real-time data through topics and subscribes to the message topics to be received; When the client (1) is in an active state, it establishes a connection with the cloud MQTT server. When real-time data is needed, it subscribes to relevant topics, processes and displays the real-time data after obtaining it; When the client (1) sends a command, it can publish a message to the topic subscribed by the local server (3). After the local server (3) receives the message, it further processes the message; The cloud server (2) keeps connected to the local server (3) without interruption and obtains the real-time data transmitted by the local server (3) program in real time; The client (1) only keeps connected to the cloud server (2) in an active state. When the client (1) is closed or in an inactive state, the connection to the cloud MQTT server is disconnected.
Citation Information
Patent Citations
Photovoltaic power station monitoring system based on MQTT protocol
CN109245295A
Microgrid energy management system based on digital twinning
CN112332444A
Energy management method and system based on big data AI self-learning
CN114581262A
Mqtt automatic subscription system and subscription method based on redis
CN119109945A