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

Connecting an nRF9160 to AWS

Hello,

I'm attempting to connect the nRF9160 DK to our AWS IoT account. I've been following the information in this question: https://devzone.nordicsemi.com/f/nordic-q-a/44528/switch-cloud-endpoint-from-nordic-aws-to-our-own-aws-account but I'm having an issue establishing the connection.

So far I have been able to call the certificates from a replica of 'certificates.h' and flash these onto the nRF91 using the nrf_inbuilt_key commands and have been able to establish a broker connection but receive a time out error when connecting to AWS with MQTT. I am currently modifying mqtt_simple to acheve this connection.

So far I have updated 'pj.conf' with:

I have added the following additional functions to mqtt_simple:

I have changed the following in Kconfig:

Finally, the certs are inside certificates.h:

I'm not sure what is still left to change in order to make the connection to AWS.

  • Hi,

     

    You are using \r\n as the line ending (normal is \n only), but both shall be accepted by the nrf_inbuilt API.

    I do not see any problems specific to your implementation, but what you could do is to verify that you have the latest modem installed, which can be found here:

    https://www.nordicsemi.com/Products/Low-power-cellular-IoT/nRF9160/Download#infotabs

     

    Do you always get the same error message, even if you try several times? if you enter debug mode, and debug the function mqtt_transport_socket_tls.c::mqtt_client_tls_connect(), which function returns the err?

     

    Kind regards,

    Håkon

  • Apologises for the delayed response. I have identified the issue with the connection. Turns out the network provider requires a whitelisted IP address that is incompatible with the dynamic IPs of AWS IoT Core.

    As the device I am using is deployed in another area of the UK, I can't manually update the modem to the latest version without risking something going wrong. I'd rather avoid updating the modem at this moment if I can get away with it. The device is hooked up to a Raspberry Pi with internet access which can faciliate re-flashing with JLinkExe but hasn't been set up with the modem update tools.

    I've been busy figuring out a counter to this issue and have decided to take a different path and use the BSD library to create a UDP connection to a static IP bounded EC2 instance on AWS. I have encountered a different problem with setting up this kind of connection however.

    The code compiles but the nRF9160 reports back a hard fault when the code is loaded onto the device. It will run the code until the UDP IPv4 socket information structure (struct nrf_sockaddr_in) is populated. I've tried to follow what examples I have found of this structure in the ncs repo but I seem to be missing something.

    This is were it appears the code gets to before hard fault, I placed printks to figure out where the code reaches before faulting:

    This is the UART information when the device resets until faulting:

    This is main.c

    EDIT: I should clarify, I have one DK deployed in an area of NB-IoT coverage that can be re-flashed remotely. I have a second DK beside me that I can use to test flashes operate as expected, but without any NB-IoT coverage in this area, before taking the merged zephyr hex file and remotely flashing using JLinkExe.

  • Hi,

     

    This code looks like trouble:

     

    Could you try this instead?

     

    Kind regards,

    Håkon

  • Hi,

    Thank you, that allowed the code to pass through the struct without faulting.

    I have tweeked the code slightly as the timer was causing an instruction fault (first time I've seen that as I use that timer code in other Zephyr nrf91 samples, I have removed it for now as it wasn't really needed). I have edited nrf_connect as even though there was no network for it to connect to, it was still returning 0 on err.

    Is this the correct way for nrf_connect to be called? It now fails out as expected for no network connection.

  • Hi,

     

    The code looks ok. I have an udp-example here (the bind is strictly not needed):

    https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/ntp/src/main.c

    Kind regards,

    Håkon

1 2 3