riclolsen / json-scada

A portable and scalable SCADA/IIoT-I4.0/Gateway platform centered on the MongoDB database server.
https://riclolsen.github.io/json-scada/
GNU General Public License v3.0
292 stars 78 forks source link

ESP32-MQTT-JSONSCADA- MONGODB flow #116

Open Nolan-29 opened 1 year ago

Nolan-29 commented 1 year ago

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...:)

riclolsen commented 1 year ago

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.

Nolan-29 commented 1 year ago

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

riclolsen commented 1 year ago

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.

Nolan-29 commented 1 year ago

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 ??

riclolsen commented 1 year ago

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

Nolan-29 commented 1 year ago

Getting like this

Screenshot (70)

riclolsen commented 1 year ago

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/#

Nolan-29 commented 1 year ago

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

riclolsen commented 1 year ago

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.

Nolan-29 commented 1 year ago

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?

riclolsen commented 1 year ago

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.

Nolan-29 commented 1 year ago

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 commented 1 year ago

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 ???

riclolsen commented 1 year ago

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

Nolan-29 commented 1 year ago

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

riclolsen commented 1 year ago

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 commented 1 year ago

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