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

MQTT integration with Losant IoT

Good afternoon,

First of all, I hope that you are all well and are able to work from home, regardless of the government instructions of your country of residence.

My question is related to an experiment we are currently running using the Losant IoT platform (https://app.losant.com) and several Nordic Thingy:52 kits.

We have already managed to connect a kit to Losant using a Raspberry Pi3 as a gateway. However, it is important to our experiment to connect a different kit to Losant IoT using a different method, namely an MQTT integration.

In order to achieve an MQTT integration with Losant, which we have successfully achieved using other sensors from other brands, Losant requires the following data (also including our current inputs):


MQTT
a2n7tk1kp18wix-ats.iot.us-east-1.amazonaws.com

PORT
8883

CLIENT ID
prod-4c2698a1-2597-4760-82d1-7ecf1be56d18-account

AUTHENTICATION

Private Key
-----BEGIN RSA PRIVATE KEY-----{Private key}-----END RSA PRIVATE KEY-----

Certificate
-----BEGIN CERTIFICATE-----{Certificate}-----END CERTIFICATE-----

TOPICS

prod/4c2698a1-2597-4760-82d1-7ecf1be56d18/a/gateways
prod/4c2698a1-2597-4760-82d1-7ecf1be56d18/a/connections
prod/4c2698a1-2597-4760-82d1-7ecf1be56d18/a/alerts
prod/4c2698a1-2597-4760-82d1-7ecf1be56d18/a/alerts/notifications
prod/4c2698a1-2597-4760-82d1-7ecf1be56d18/m/

CA CERTIFICATE

-----BEGIN CERTIFICATE-----{CA Certificate}-----END CERTIFICATE-----

Even though we succesfully connected the kit to nrfcloud using an iOS device as gateway and are able to follow the MQTT documentation instruction to obtain the above data for our inputs (I have attached the JSON response to the POST API call to certificate as described in the MQTT documentation, as well as the certificate downloaded from nrfcloud), when using this data in Losant IoT we keep receiving the following error message:

Failed to create integration!
Invalid openssl exit code: 1 % openssl x509 -noout -nameopt RFC2253,sep_multiline,space_eq,-esc_msb,utf8 -text -in /tmp/3a40d58688868c30f5e7e2bea98a5119ab6df832 unable to load certificate 140522648251720:error:0909006C:PEM routines:get_name:no start line:crypto/pem/pem_lib.c:745:Expecting: TRUSTED CERTIFICATE

Can you provide any help or guidance in order to get past this step? What could be going wrong? Did we miss any steps?

Thank you in advance, stay safe!

  • Many thanks for your help once again Didrik.

    Continuing the discussion thread here, as I was able to get past the Losant error message by following your suggestion and using nRF Connect for Desktop to properly format the certificates and private key.

    However, although all details are now supplied correctly, Losant is unable to connect to the MQTT stream.

    This leads me to believe I might be doing something wrong before downloading the device certificates from nRF Connect for Cloud, i.e. perhaps I am supplying a wrong Device ID or PIN/HWID. What should these values be?

    Also, it is worth noting that although the Thingy:52 is properly connected to the nRF Cloud Gateway on my iOS device, that both the gateway and device are displayed on nRF Connect for Cloud as being online and that the nRF Cloud Gateway logs show that the Thingy:52 is transmitting rssi values every minute, nRF Connect for Cloud cannot display the cards for the device (i.e. the loader is displayed endlessly and the cards screen never loads).

  • adaxem said:
    This leads me to believe I might be doing something wrong before downloading the device certificates from nRF Connect for Cloud, i.e. perhaps I am supplying a wrong Device ID or PIN/HWID. What should these values be?

     Are you getting the certificates from the web UI? I think you will then only get certificates for "generic" devices. which are not able to listen to the traffic of other "generic" devices.

    Instead, if I have understood this correctly, you need to add Losant as an "account device". You can get the certificates and device ID for an "account device" by sending a POST request to the /account/certificates endpoint.

     

    adaxem said:
    Also, it is worth noting that although the Thingy:52 is properly connected to the nRF Cloud Gateway on my iOS device, that both the gateway and device are displayed on nRF Connect for Cloud as being online and that the nRF Cloud Gateway logs show that the Thingy:52 is transmitting rssi values every minute, nRF Connect for Cloud cannot display the cards for the device (i.e. the loader is displayed endlessly and the cards screen never loads).

     Are the relevant services configured to send data on the Thingy? If the services has been disabled from the Thingy-app, I don't think they will show up in nRF Cloud.

  • Thank you for this additional information Didrik.

    I was indeed downloading the certificates from the web UI, so followed your suggestion and got the certificates using the POST request to the /account/certificates endpoint, then formatted them correctly using the Certificate manager of nRF Connect for Desktop and entered all these new details to Losant.

    However, Losant is still unable to subscribe to the MQTT stream for my Thingy:52, although I am not receiving any error messages. Please note that I am not trying to add the Thingy:52 as a Device to Losant, but rather have Losant subscribe to the MQTT stream through the Integrations functionality of Losant (https://docs.losant.com/applications/integrations/) which allows to connect Losant to external MQTT brokers (I assume nRF Cloud plays this role in the setup we are discussing).

    It is also worth noting that even though the Thingy:52 is transmitting data for all environmental sensors (checked on the Thingy iOS app and nRF Cloud Gateway logs), the Cards page on nRF Connect for Cloud is still unaccessible (although both the device and gateway are displayed as being connected).

    I'd be grateful if you have any other suggestions regarding how to proceed further, any other way (apart from Losant) to check that the MQTT stream is actually accessible and a possible explanation for the environmental Cards not being loaded on nRF Connect for Cloud.

    Thank you once more for all your assistance, stay safe and have a nice weekend Slight smile

  • adaxem said:
    It is also worth noting that even though the Thingy:52 is transmitting data for all environmental sensors (checked on the Thingy iOS app and nRF Cloud Gateway logs), the Cards page on nRF Connect for Cloud is still unaccessible (although both the device and gateway are displayed as being connected).

    If you only get the loading diamond, have you tried to refresh the page?

    Are you subscribing to the right topic?

  • Hi Didrik,

    Indeed, I am getting only the loading diamond and can sometimes actually get the whole Cards page to load by refreshing, but not consistently. However, I have never actually managed to get a live reading (for temperature or pressure) displayed on the Cards page, even though the Thingy:52 is actually transmitting.

    Double-checked the topics I am subscribing to on the Losant integration, unfortunately they seem to be correct.

    Is there any other way I could check that the MQTT stream can be subscribed to? Any other software or utility?

Related