Integrate LoRAWAM device sensor to MQTT server using a Mikrotik Router

Hello,

I need to connect a LoRAWAN module to a MQTT server. As a first Proof-Of-Concept the setup to test I propose is the next:

  • To use a Mikrotik wAP LoRA8Kit router to route LoRAWAM to the TTN MQTT Server.
  • The LoRAWAN module does not have any MQTT client.

I have been able to connect the gateway to TTN, create an Application, create the LoRAWAM device and getting to join this device to the application. This LoRAWAN device is, in fact, a module that I am controlling using AT commands.

Relate to the MQTT integration, I have created the API Key. But I have to admit that I am not able to see how to integrate the application to the MQTT server in TTN. I thought that the router would do the job of uplinking the LoRAWAN messages to the MQTT Server, and just the other way round. But following the documentation available I cannot see how to setup these arquitecture.

Do you see the setup proposed feasible?
Would you suggest any other LoRAWN-MQTT router?
May you help me on that?

Thank you very much in advance.

Regards,
Joel

Your end device sends data through the gateway (MikroTik wAP) to the TTN backend. In the TTN backend you have your application with the registered node. For the same application you create the MQTT integration (which is a server) where you take a client to connect to it using the API key. (See the documentation link at the bottom of each TTN console page on how to connect MQTT clients)

If you need to send the data to another MQTT server you need some kind of MQTT bridge or replication between the TTN MQTT server and the other MQTT server.

I see.
I have connected the TTN MQTT integration/server to a Node-Red application in my PC (Windows). Using the mqtt-In node I have been able to get an uplink message payload from the registered device in the TTN backend. However, I am not able to downlink a message from the PC to the device using a mqtt-out node.
imagen
The function code is the next:
msg.payload = {
“end_device_ids”:{
“device_id”: “eui-70b3d57ed005629d”,
“application_ids”: {
“application_id”: “rfm6601-test-1”
},
“dev_eui”: “70B3D57ED005629D”,
“join_eui”: “323531322F002E00”,
“dev_addr”: “260B7D71”
},
“downlinks”: [{
“f_port”: 15,
“frm_payload”: msg.payload.toString(“base64”),
“priority”: “NORMAL”
}]
}
return msg;
I can see that the gateway receives the data payload, but it doesn’t arrive to the application. I have revised all the EUIs, IDs and APi Key and they are all ok.

The payload formatters are “None” for Uplink and for Downlink.

Any suggestion to get the the downlink message to arrive to the end device?

To what topic are you using in you MQTT out node?

Seems like you contradicting yourself here

Are you getting your sensor to connect to TTN? What do you see in your Application live data?

For a downlink message that doesn’t make sense. A downlink message travels from your code to the TTN backend, when the device uplinks the downlink will be transmitted to the gateway to send to the device 5 or 6 seconds after it uplinked.

Thank you for your comments.

I have changed the function in the Node-Red to the next code, changing also the port number:

return {
“payload”: {
“downlinks”: [{
“f_port”: 1,
“frm_payload”: msg.payload.toString(“base64”),
“priority”: “HIGH”
}]
}
}

I have reconfigured my LoRAWAN device and now it’s working on Class A. So, I can read the downlink message when the device sends an uplink message.

Regards,
Joel

As above, this makes no sense.

Uplinks are FROM device to you & your application

Downlinks are from you/your app TO the device.

You may send a downlink message when the device sends an uplink message on Class A, but you don’t ‘read’ a downlink in the literal sense, you create it and send it for onward transmission.

It is particularly important that you understand this as frequent downlinks (more than once per fortnight) are not a good thing for a network.