Publish data to different MQTT topics based on application and data type in ChirpStack v4

Hi everyone,

I am using ChirpStack v4 for a network of sensors that send different types of messages over LoRa. The data type is identified by the first byte of each message, and I am currently decoding these messages using JavaScript on the server.

What I want to achieve is to publish the messages to MQTT topics based on the application name and the data type (for example, app1/temp, app2/humidity, etc.).

I’ve been going through the ChirpStack v4 documentation, but I haven’t been able to figure out how to configure this to work directly within ChirpStack. Is it possible to do this via ChirpStack’s configuration, or would I need to handle it at the server level after receiving the data?

Any advice or guidance would be greatly appreciated. Thanks in advance!

The latter. Putting business logic into ChirpStack would not be advisable, there are too many possible permutations.

Great, thank you very much for the help :wink:

I have been reviewing the documentation.

The architecture of my network will consist of gateways with MQTT forwarders sending data in Protobuf. Each gateway is associated with a different location. In my business logic, I am deploying IoT networks on different livestock farms. Each farm will have its own gateway, and since I want them to be independent, I plan to create one application per farm (or would it be better to use a tenant per farm?).

I want to publish the network data (as I mentioned, by data type and depending on the gateway origin) to an MQTT broker different from ChirpStack, using a scheme like location_origin/data_type/emitter_id. The location origin corresponds to where the gateway is deployed.

How should I implement this business logic? Should I use Redis Streams? Or should I consume the data directly from MQTT?

I usually prefer to consume from the MQTT integration with a slim service that lives outside of ChirpStack (usually in Go, but again just preference). Then the business logic can be as complex as the service or infrastructure demands, and you can send the data as many places as you need.

Tieing things to tenants or applications is frequently dealer’s choice, I usually don’t have ChirpStack admininstration exposed to the end users.

1 Like