Tag Archives: MQTT

MonsterMQ with Grafana

Because MonsterMQ can store topic values directly in PostgreSQL/Timescale, you can instantly create dashboards with Grafana! ๐Ÿ“Š

Hereโ€™s a simple example:

๐Ÿ‘‰ Check out the live dashboard

Itโ€™s super easy to get started. Use the public available MonsterMQ at test.monstermq.com at port 1883. Just publish a JSON string to any topic under “Test”, like “Test/Sensor1” with a payload like this: {“value”: 1}, and youโ€™ll see the value reflected in the Grafana dashboard in real time.

Iโ€™m currently publishing temperature sensor values to the public broker from my home automation using automation-gateway.com. Just that you see some values in the dashboard.

So, if you need a broker to store your IoT data directly into TimescaleDB without the need for any additional components, consider using MonsterMQ. It’s free and available at MonsterMQ.com.

Here is the exmaple docker-compose.yml file of the public availble test.monstermq.com broker:

services:
  timescale:
    image: timescale/timescaledb:latest-pg16
    restart: unless-stopped
    ports:
      - "5432:5432"
    volumes:
      - /data/timescale:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: system
      POSTGRES_PASSWORD: xxx
  monstermq:
    image: rocworks/monstermq:latest
    restart: unless-stopped
    ports:
      - 1883:1883
    volumes:
      - ./config.yaml:/app/config.yaml
    command: ["+cluster", "-log INFO"]
  pgadmin:
    image: dpage/pgadmin4
    restart: unless-stopped
    environment:
      PGADMIN_DEFAULT_EMAIL: andreas.vogler@rocworks.at
      PGADMIN_DEFAULT_PASSWORD: xxx
    volumes:
      - /data/pgadmin:/var/lib/pgadmin/storage
    ports:
      - "8080:80"
  grafana:
    image: grafana/grafana
    restart: unless-stopped
    ports:
    - 80:3000

Here is the MonsterMQ config.yml file:

Port: 1883
SSL: false
WS: true
TCP: true

SessionStoreType: POSTGRES
RetainedStoreType: POSTGRES

SparkplugMetricExpansion:
  Enabled: true

ArchiveGroups:
  - Name: "All"
    Enabled: true
    TopicFilter: [ "#" ]
    RetainedOnly: false
    LastValType: POSTGRES
    ArchiveType: NONE
  - Name: "Test"
    Enabled: true
    TopicFilter: [ "Test/#" ]
    RetainedOnly: false
    LastValType: NONE
    ArchiveType: POSTGRES

Postgres:
  Url: jdbc:postgresql://timescale:5432/monster
  User: system
  Pass: xxx

Give it a try and let me know what you think!

#iot #mqtt #monstermq #timescale #postgresql #grafana

Publish OPC UA and MQTT Data to the Cloud with Automation-Gateway

Publish OPC UA and MQTT Data to the Cloud with Automation-Gateway – inspired by a users request ๐Ÿ’ก

If you have a local ๐—ข๐—ฃ๐—– ๐—จ๐—” server or ๐— ๐—ค๐—ง๐—ง broker and want to bring that data to a ๐—ฐ๐—น๐—ผ๐˜‚๐—ฑ-๐—ฏ๐—ฎ๐˜€๐—ฒ๐—ฑ dashboard, Automation-Gateway.com makes it simple. You can easily publish your data to ๐—œ๐—ป๐—ณ๐—น๐˜‚๐˜…๐——๐—• Cloud and visualize it in ๐—š๐—ฟ๐—ฎ๐—ณ๐—ฎ๐—ป๐—ฎ โ€” all without complex setups.

I recently added support for InfluxDB V2 to the gateway, allowing you to configure an Influx token and bucket for data publishing. With just a few steps, your local OPC UA or MQTT data can be ๐˜€๐˜๐—ผ๐—ฟ๐—ฒ๐—ฑ ๐—ถ๐—ป ๐˜๐—ต๐—ฒ ๐—ฐ๐—น๐—ผ๐˜‚๐—ฑ and displayed in Grafana in real time.

MQTT Server Interface for WinCC OA? Made with Kotlin ๐Ÿ˜ฒ


Starting with WinCC OA Version 3.20, you can write your business logic in JavaScript and run them using Node.js, providing direct access to the WinCC OA Runtime.

๐Ÿ™ˆ With that, I have developed a Kotlin program that acts as an MQTT Broker. When you subscribe to a topic (where the topic name matches a datapoint name), the program will send value changes from the corresponding WinCC OA datapoint to your MQTT client.

โ“ But wait, Kotlin is like Java, it runs on the JVM, it is not JavaScript!

๐Ÿ’ก Did you know that a Node.js Runtime built with GraalVM exists? It allows you to mix Java and JavaScript. And it also works with WinCC OA.

๐Ÿคฉ You can use JVM based languages and its huge ecosystem to develop business logic with WinCC OA. I have developed a Java library which makes it easier to use the WinCC OA JavaScript functions in Java.

๐Ÿ‘‰ Here it is: https://github.com/vogler75/winccoa-graalvm please note that the example program is provided as an example; it lacks security features and has not been tested for production use. However, it can be extended and customized to meet specific requirements.

โšก Please be aware that the GraalVM Node.js Runtime is not officially supported by WinCC Open Architecture.

Bringing PLC values to OPC UA, MQTT, GraphQL

With just some lines of configuration you can bring PLC values to OPC UA, MQTT and GraphQL. And to a variety of databases for tag logging…

๐Ÿ’ก In that example with ModBus, but thanks to #plc4x this should work in the same way also for the other protocols supported by PLC4X.

๐Ÿ“บ See the video, ModBus values are brought to OPC UA and MQTT.

๐Ÿ’ฃ In MQTT the topic name is enriched with a UNS ISA95 topic path.

โšก On MQTT SparkplugB encoded messages could be used.

๐Ÿ˜Ž 100% GUI free and Open Source.

๐Ÿ‘‰ automation-gateway.com

Servers:
  GraphQL:
    - Port: 4000
      LogLevel: INFO
      GraphiQL: true

  OpcUa:
    - Port: 4841
      Enabled: true
      LogLevel: INFO      
      Topics:
        - Topic: plc/demo/node/holding-register:1:INT
        - Topic: plc/demo/node/holding-register:2:INT
        - Topic: plc/demo/node/holding-register:3:INT
Drivers:
  Plc4x:
    - Id: "demo"
      Enabled: true
      Url: "modbus://localhost:502"
      Polling:
        Time: 100
        OldNew: true
      WriteTimeout: 100
      ReadTimeout: 100
      LogLevel: INFO    

Loggers:
  Mqtt:
    - Id: mqtt1
      Enabled: true
      Host: 192.168.1.4
      Port: 1883
      Topic: modbus
      Format: Raw
      Logging:
        - Topic: plc/demo/node/holding-register:1:INT
          Target: enterprise/area1/line1/cell1/speed
        - Topic: plc/demo/node/holding-register:2:INT
          Target: enterprise/area1/line1/cell1/power
        - Topic: plc/demo/node/holding-register:3:INT
          Target: enterprise/area1/line1/cell1/torque

TCP – MQTT – TCP Bridge

Some weeks ago, someone asked at theโ€ฏ#HiveMQโ€ฏSlack channel if there is any way to run SSHโ€ฏoverโ€ฏMQTTโ€ฆ
ย 
๐Ÿ‘‰โ€ฏStrange idea? I liked it, and I want to share the TCP-MQTT-TCP bridge I made weeks ago.ย 
ย 
๐Ÿค”โ€ฏUse Case? Imagine you have IoTโ€™s connected to a central MQTT broker and you want to connect from one to another via SSH, transfer files, expose services, a Webpage, without exposing ports to the public internet or creating a VPN.ย 
ย ย 
โš ๏ธย Be careful and please evaluate and consider the possible security impacts before using this “backdoor man” … the doors …
ย 
โš ๏ธโ€ฏAnd transferring files over MQTT may increase your cloud billโ€ฏ๐Ÿค‘ย 
ย 
๐Ÿ‘‰It’s on โ€ฏGitHub, it is just a draft and can be used as a template to be extended by your needs.โ€ฏย 
ย 
๐Ÿ‘€โ€ฏHow to? Start the client.js script at the destination host – or more precisely at a node in the local network where the destination node runs – and start the server.js script on the source node from where you want to connect to the remote/destination host and port. For example, if there is a SSH server running on the destination host+port, then you can do a SSH localhost -p 8080 -l username at your source node, and you will get a SSH connection from the source node to the destination node. And the data is transmitted over MQTT topics.ย 
ย 

HighByte to Unity3D with SparkplugB

Successfully connected HighByte Intelligence Hub to Unity3D with SparkplugB!ย โœ”

๐Ÿ‘€ I am sending data from my Automation-Gateway.com to the Intelligence Hub via OPC UA, then the values are published from HighByte to MQTT with the Intelligence Hub SparkplugB connector and then getting consumed in Unity with the MQTT SparkplugB Asset.

๐Ÿ‘ Works straight forward and was easy to setup!

๐Ÿง Sparkplug Learning: If a Host Application is not the Primary Host of an Edge Node and it starts up after the Edge Node, it must send the Rebirth command to the Edge Nodes in which it is interested in, to get a birth message with the current/initial values of all the metrics of the nodes. My Unity client ignores incoming metrics of DATA messages which it has not seen before in a BIRTH message…

UNS with WinCC Open Architecture?

Did you know that WinCC Open Architecture is โ€œUNS READYโ€? ๐Ÿ‘

And it even does not matter how your underlying tags are structured ๐Ÿ˜ฎ

๐Ÿ‘‰ You can create your own hierarchical view on tags which you want to publish to MQTT in a Unified Namespace!

๐Ÿ‘‰ You can define a fully ISA 95 compliant view on top of your machine data!

Happy UNS Publishing with WinCC Open Architecture!

See the MQTT publisher at the WinCC Open Architecture Documentation

SparkplugB for Unity3D

Unlock the potential of industrial data from SparkplugB enabled devices, seamlessly integrated into Unity3D to build 3D applications?

Or start creating industry Apps for Apple’s Vision Pro with SparkplugB connectivity? ๐Ÿ•ถ๏ธ

๐Ÿ’ก I completed a SparkplugB ๐Ÿš€ implementation for Unity. The primary objective was to acquire a hands-on understanding of SparkplugB.

๐Ÿ‘‰ You can find it for free on GitHub It’s made on top of the “MQTT for Unity” Asset.

Disclaimer: There is no assurance that I have captured all the rules within the extensive 140-page SparkplugB specification. While Unity supports visionOS, I have not conducted testing on this platform.

MQTT for Gaming?

MQTT for Multiplayer Games? I am not a Game-Developer and I do not know how they create multiplayer internet games. But I know that MQTT can be used for that. Why?

# IoT turns to IoP

MQTT is used for connecting devices. Think about using MQTT for connecting players. “Internet of Things” (IoT) will turn to โ€žInternet of Playersโ€œ (IoP).

# A Player is like a Device?

In a multiplayer game, each player is like a device. When they join the game, it’s like they’re saying “Hello, I’m here!” to everyone else โ€“ this is known as a “birth message” in MQTT terms.

# Sharing Information Seamlessly

As players move around in the game, they keep sending updates like their location, healthy state, collected goodies, โ€ฆ. MQTT acts like a messenger, picking up this information and delivering it to everyone else playing. 

# Handling Player Exits

What if a player leaves the game intentionally or unintentionally? MQTT has a smart feature called “last will message.” It’s like a goodbye note that tells other players someone has left the game. This way, everyone stays in the loop.

# Central Management 

A central game management connected to the central MQTT broker, written in any kind of language, could be used to observe and control the game and all the players.

# Why MQTT?

1. **Real-Time Updates**: It’s fast and perfect for real-time games.

2. **Reliable**: Even if a player’s connection is shaky, MQTT makes sure messages get through.

3. **Efficient**: It doesn’t eat up much data, so players won’t lag.

4. **Simple**: It’s not complicated to set up and to use.

# Conclusion

Using MQTT in multiplayer games is like having a super-efficient mailman who ensures everyone knows what’s happening as it happens.

For Unity there is a โ€žUnity for MQTTโ€œ and a โ€œGraphQL for Unity Proโ€ asset. Easy to use and usable with all the main build targets, including WebGL!

See the game demo I made with MQTT.. I also integrated data from WinCC Unified in the demo, with the GraphQL for Unity Pro Asset.

You can try it out: https://server.rocworks.at/unity/game/ (could be already removed when you try to access it)