json-scada icon indicating copy to clipboard operation
json-scada copied to clipboard

ESP32-MQTT-JSONSCADA- MONGODB flow

Open Nolan-29 opened this issue 2 years ago • 17 comments

Dear companion,

Here am working on project , My Sensor data (Temperature and Speed ) get from module and its connected through mqtt protocol. now so I want to see that data on JSON-SCADA Display Viewer which is in .SVG file .

In SVG file I created my Own layout Shape and also i done Tag . Now the

Que 1. how my .svg file and inside Tag will communicate to my Real time Data with help of MQTT Protocol Driver.

Que 2 : I need some details about Json-Scada and MQTT protocol connection. below i attached image reference

que 3 : How to set configuration between MongoDB , MQTT Protocol Connection and tag ID

Que 4: Should i add MongoDB Library In my Arduino Code or Not for storing data ? Or only Mqtt config is Enough ? Like just giving mqtt broker details in my arduino code as im getting my data in mqtt broker frome there I'm confused about sending data to json scada mogodb mqtt screen

hope i explained you as much understandable if not pls excuse and am expecting your valid reply...:)

Nolan-29 avatar Aug 07 '23 08:08 Nolan-29

First try to connect the device to a MQTT broker and then JSON-SCADA to the broker. After configuring connection, restart the service JSON_SCADA_mqttsparkplugclient. If you do not see data, check logs.

To see mqtt logs do this: Go to windows services and stop JSON_SCADA_mqttsparkplugclient Or do in cmd as admin net stop JSON_SCADA_mqttsparkplugclient cd C:\json-scada\src\mqtt-sparkplug \json-scada\platform-windows\nodejs-runtime\node.exe index.js 1 3

Does your device has Sparkplug B? If not do not use spBv1.0 topics.

riclolsen avatar Aug 07 '23 10:08 riclolsen

My device(esp32) is connected to Mqtt broker and then broker is receiving the data.From there to how to connect with json scada?

Nolan-29 avatar Aug 07 '23 16:08 Nolan-29

https://github.com/riclolsen/json-scada/blob/master/src/mqtt-sparkplug/README.md

Basically put the broker address in endpointURLs, and list topics in topics parameter. Username and password if necessary.

Restart the service JSON_SCADA_mqttsparkplugclient.

riclolsen avatar Aug 07 '23 16:08 riclolsen

Given like that only what u mentioned, now If json scada is connected to mqtt broker where have to see that ? In MongoDB vice should i do any Configuration ??

Nolan-29 avatar Aug 07 '23 17:08 Nolan-29

Better look first at the logs.

To see mqtt logs do this: Go to windows services and stop JSON_SCADA_mqttsparkplugclient Or do in cmd as admin net stop JSON_SCADA_mqttsparkplugclient cd C:\json-scada\src\mqtt-sparkplug \json-scada\platform-windows\nodejs-runtime\node.exe index.js 1 3

riclolsen avatar Aug 07 '23 18:08 riclolsen

Getting like this

Screenshot (70)

Nolan-29 avatar Aug 08 '23 05:08 Nolan-29

Odd unexpected error on MongoBD changestream! I am not sure what can be the problem. Please retry. Uninstall/Reinstall JSON-SCADA if necessary. If possible, post your protocolConnections contents from mongodb.

The log should be something like this C:\json-scada\src\mqtt-sparkplug>\json-scada\platform-windows\nodejs-runtime\node.exe index.js 1 3 2023-08-08T21:44:28.792Z - Config - Config File: ../../conf/json-scada.json 2023-08-08T21:44:28.797Z - Config - {json:scada} - MQTT-Sparkplug-B Client Driver Version 0.1.5 2023-08-08T21:44:28.798Z - Config - Instance: 1 2023-08-08T21:44:28.798Z - Config - Log level: 3 2023-08-08T21:44:28.799Z - MongoDB - Connecting to MongoDB server... 2023-08-08T21:44:28.838Z - MongoDB - Connected correctly to MongoDB server 2023-08-08T21:44:28.854Z - Connection - Connection Number: 1200 2023-08-08T21:44:28.859Z - Auto Key - Initial value: 1200000022 2023-08-08T21:44:28.859Z - Redundancy - Process Inactive 2023-08-08T21:44:28.865Z - Redundancy - Node activated! 2023-08-08T21:44:33.874Z - Redundancy - Process Active 2023-08-08T21:44:33.886Z - MQTT Client - Creating client... 2023-08-08T21:44:33.887Z - MQTT Client - Try connecting to mqtt://test.mosquitto.org:1883 2023-08-08T21:44:34.629Z - SparkplugClientLib - packetreceive: {"cmd":"connack","retain":false,"qos":0,"dup":false,"length":2,"topic":null,"payload":null,"sessionPresent":false,"returnCode":0} 2023-08-08T21:44:34.632Z - SparkplugClientLib - Client has connected 2023-08-08T21:44:34.632Z - MQTT Client - Event: Connected to broker 2023-08-08T21:44:34.632Z - MQTT Client - Subscribing topic: spBv1.0/Edge Nodes/#

riclolsen avatar Aug 08 '23 21:08 riclolsen

Getting like this.
Now where to see the data coming from my device in json scada? Screenshot (83)

Nolan-29 avatar Aug 09 '23 03:08 Nolan-29

Connection to mongo and broker are ok now. Remove spBv1.0 from topics list. Put there your topic filter (or # for all topics). Leave publishTopicRoot and groupId empty or it will publish JSON-SCADA data to the broker.

riclolsen avatar Aug 10 '23 00:08 riclolsen

here im getting data from mqtt broker to mongodb so , do i need postgres or can i directly send these json payload to display viewer to observe changes in svg file?

Nolan-29 avatar Aug 18 '23 11:08 Nolan-29

You have to use the tags created in mongodb by the MQTT driver. Use the tags to markup objects in the SVG files. See example SVG files and demo tags.

riclolsen avatar Aug 18 '23 12:08 riclolsen

Demo Tags in admin page and MongoDB real-time data ID , all related to opc-UA only. Is there any example tag for Mqtt (spark plug) ? If mean can u please share example!! Also still not clear about MongoDB data how to Fetch in json Scada !!

Nolan-29 avatar Aug 18 '23 12:08 Nolan-29

One more doubt , We need just 12 set of parameters only , so can we edit the schema as per our customise or we have use as per demo only ???

Nolan-29 avatar Aug 18 '23 20:08 Nolan-29

When the data is already loaded by the protocol driver to MongoDB it doesn't matter the protocol anymore, values acquired will flow to SVG as requested identified by the "tag" field from the mongo document. In fact, the demo SVG presents IEC-104 data only, not OPC. So, it is just a matter of studying the demo SVG files. I didn't quite get your last question. You can use JSON-PATH syntax to extract properties in the "topics" parameter or use "topicsScripted" to extract the data from a topic with a script. Each individual data value must be in a distinct tag to be displayed in the SVG. See https://github.com/riclolsen/json-scada/blob/master/src/mqtt-sparkplug/README.md

riclolsen avatar Aug 19 '23 11:08 riclolsen

SAGE (Cepel) HTML/SVG Displays (SAGE-web) where it is?

Nolan-29 avatar Aug 30 '23 11:08 Nolan-29

This is specific to displays created for the Brazilian SCADA SAGE. It is possible to convert those displays to SVG and animate in JSON-SCADA.

riclolsen avatar Aug 30 '23 20:08 riclolsen

I have detected problems with the MQTT driver in version 0.29, now fixed in version 0.30!

riclolsen avatar Sep 10 '23 20:09 riclolsen