This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Easiest way to subscribe to MQTT messages from Thingy91 on the nRF Cloud

Hi,

What's the easiest way to subscribe to the MQTT messages that the thingy91 sends to the nRF cloud?

I have tried setting it up with a node-red and a python client, but I'm never able to connect to the MQTT broker that is set up in the nRF cloud. I want to find out the easiest way to subscribe to these messages so that I can present them in a web application like node-red or similar.

The documentation that is found under APIs doesn't seem to help me, as I'm unable to connect to the broker. As I can see the data being sent to the nRF cloud, I figured it wouldn't be too difficult to just parse that data somewhere else.

Thanks

Best regards

Joakim Uddenfeldt

  • Hello Joakim, 

    First I must apologize for not being very clear when asking about the certificate manager. You are not supposed to click on Update Certificates. The only reason to use this is to get the certificates in the correct format to copy and paste into separate certificates, and then close the Certificate Manager. You will need to remove the device and add the device again to your nRF Cloud account.

    Joakim U said:
    I'm still uncertain what the issue can be, but the error I receive is that I can't connect to the broker, which might be due to the certification error that I pointed out above.

    Where are you receiving the error? And what error are you receiving? 

    Joakim U said:
    have tested that my tools work with another MQTT broker and it works fine.

    What MQTT broker did you use?

    Thanks!

  • Hi Øyvind,

    No worries, I might have been a bit unclear myself as well. What I have done is actually to use the certificate manager in the same way that you are describing, in other words, i'm only using it to get the certificates in the right format. As I'm using Windows, I assumed this was the best way of formatting the certificates. Once I have done that, I check the certificates against  this tool: https://www.sslshopper.com/certificate-decoder.html, which tells me if the certificate is correctly formatted.

    I'm currently using Node-red (https://nodered.org) to test out these connections. I haven't set up a broker, instead I'm trying to subscribe to the broker that my Thingy is sending its data to, which is the one you can see below. The error I receive is the following:

    8 Oct 08:31:15 - [info] [mqtt-broker:Thingy91] Connection failed to broker: mqtts://a2n7tk1kp18wix-ats.iot.us-east-1.amazonaws.com:8883

     I know it perhaps doesn't say much, but that's the feedback I get from that program.

    My workaround is to use HTTP requests to retrieve the messages, but it is not as nice implementation as MQTT.

    Best regards

    Joakim Uddenfeldt

  • Hello Joakim, 

    there have been updates on the nRF Cloud API. To get the correct certificates and client-id to use when connecting to the Thingy:91 broker, please run the following:

     http POST https://api.nrfcloud.com/v1/account/certificates Authorization:"Bearer b09f76779f504da08ffea13814024ce545f68b3b"

    This will output CA certificate, Client Certificate and Private Key, which you need to format correctly in separate files.

    As I am not familiar with Node-Red, I do not know how to answer questions about this. I have tested using Mosquitto, and I urge you test with this first to validate the connection. 

  • Hi Øyvind,

    I will start testing with Mosquitto and also the Curl command you sent above, in order to see if it helps. Did you use a Windows to format it or did it work better in Linux?

    Thanks

    Best regards

    Joakim Uddenfeldt

  • Apologies for the late reply. 

    Joakim U said:
    Did you use a Windows to format it or did it work better in Linux?

    I used a standard text editor which I copied the output to, and made sure to add a new line after \n (visible in the output). When this is done you should have the correct format, but may need to remove \n.

    Kind regards,
    Øyvind

Related