/Streaming-PLC-Grafana

Streaming values from Beckhoff TwinCAT 3 PLC to Grafana with Inxton and websockets.

Primary LanguageC#MIT LicenseMIT

Streaming from PLC to Grafana with Inxton

grafana-stream-gif-2.gif

Requirements

  • Grafana - link
  • Inxton developer license - link
  • hse Streaming Source - link
  • .NET SDK - link
  • TwinCAT 3 installed

How to run

  1. Install hse Stream Source by unpacking from .\assets\ it to path_to_grafana\plugins-bundled\internal\.
  2. Add hse Stream Source as Data Source in Grafana - grafana docs.
  3. Open the solution, activate configuration, run the PLC.
  4. Run the WebSocketGrafana project.
  5. Open Grafana. link
  6. Create new dashboard. Select the hse Stream source in the panel. grafana docs. It will say that the datasource is unsigned. Don't worry about that.
  7. To server field write ws://127.0.0.1:5002/MAIN/Data/IntValue$
  8. You should see the value live.

If you want to use the dashoard in the Gif import the dashboard from json (located in assets\Inxton-Grafan.json) grafana docs.

What is going on

When you enter ws://127.0.0.1:5002/MAIN/Data/IntValue$ to Grafana a WebSocket connection is estabilshed between the Grafana panel and the server app.

The server app will parse the input MAIN/Data/IntValue$ into MAIN.Data.IntValue and read the value from PLC and publish it to the websocket.

URL explained

  • ws://127.0.0.1 Address of the websocket server
  • :5002 Port
  • /MAIN/Data/IntValue path to the variable
  • $ terminating character

Adding new variable in the PLC

When you add a variable to the PLC, you need to run the Inxton builder and restart the app.