Publishing MQTT messages from Thread device using NCS

I have a system that consists of a sensor (nRF52840), hub (nRF5340), and gateway (nRF9160). The high level end goal is to be able to publish a MQTT message from the sensor, and have it travel to a device that can forward it a the cellular network. One concept was to the publish the MQTT message from the sensor, route the data to the hub via OpenThread, and from there route the data to the gateway via PPP. The gateway will then be responsible for sending the data over the cellular network to the MQTT broker. Is this possible? I have been hard pressed to find examples or documentation to support this. A good start would have been a MQTT over Thread demo for NCS which does not exist. 

Parents
  • The hub is connected to a permanent power source. Your thoughts do make sense, especially your point on TCP and power. The goal for this project is to replace the existing BLE solution with a Thread solution. This solution must use MQTT, however, since we can get data from the Thread sensors to the hub BLE chip using CoAP, we can get the data over to the nRF9160 via UART and publish the MQTT message from there. Does that seem reasonable? 

Reply
  • The hub is connected to a permanent power source. Your thoughts do make sense, especially your point on TCP and power. The goal for this project is to replace the existing BLE solution with a Thread solution. This solution must use MQTT, however, since we can get data from the Thread sensors to the hub BLE chip using CoAP, we can get the data over to the nRF9160 via UART and publish the MQTT message from there. Does that seem reasonable? 

Children
  • This sounds reasonable.

    If we had a border router solution for the nRF9160, it might be an idea to use the same protocol for both.
    But since we do not have such a thing, I can see not see any reason to use the same protocol for both Thread and LTE.

    In summary, the two main reasons for using CoAP over MQTT is:

    • CoAP use UDP, which likely use less power. (*)
    • We do have samples for CoAP in the nRF Connect SDK.

    (*) I have not actually tested the power consumption of CoAP vs MQTT for Thread, but it makes sense that a heavier protocol(TCP vs UDP) will use more resources and therefore more power. My colleague agrees on this.

    Regards,
    Sigurd Hellesvik

Related