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

mqtt_simple connect to AWS

I have an AWS account and I am comfortable with the AWS IOT operation in general. I have used it in the past. I am trying to get the sample mqtt_simple to connect to AWS IOT and be able to send packets and receive packets to the nRF9160dk board.

 I am not sure how to set up mqtt_simple parameters? I have created a thing and certificates. I have named the thing "nrf-IMEI" as recommended so it has the board ID in it. All I want to do is to be able to publish a packet to a topic on my AWS account and receive a packet from a topic in my AWS account. I have done this several times in the past with other systems so I am comfortable with AWS IOT operations and formats. I just do not understand how to get mqtt_simple to publish from my board to AWS and subscribe to messages from AWS.

Is this the correct program to use. It seems like all the pieces are there I just do not know how to use them.

I appreciate any help you can give, This is an essential requirement of our production system. right now we are using the pre-production system with a modified version of asset_tracker to send sensor data to the nRF Connect site. We need to be able to send sensor data to our AWS site.

Parents Reply Children
  • Hi Timothy,
    The issue is most likely that cJSON_Init() never gets called.
    If it's not called malloc/free from newlib will then be used, and this causes issues since malloc/free gets mixed up with k_malloc/k_free.

    So if you call cJSON_init() someplace in your code it should work.

  • Martin

    yes that fixed the problem. I am able to publish to my AWS account and send messages from my AWS account.

    AWESOME!!! thank you.

  • Hi Timothy,
    No problem, I am happy to help.
    Glad to hear that you got it up and running,

  • Martin

    I am back again. I loaded V1.3.0 and I am trying to get the AWS connection to my account working.

    I made all of the changes (I think) we talked about above and I have mqtt_simple working for V1.3.0. when I make the same changes for asset_tracker I cannot connect to my account. I get the following messages. As before it is crucial that I connect asset_tracker to my AWS account so I can send data to my tables. I am sure I missed something or something changed in V1.3.0. any help you could give would be greatly appreciated. I am dead in the water right now.

    [[00:00:00.237,579] <inf> asset_tracker: Connecting to LTE network.
    [00:00:00.244,232] <inf> asset_tracker: This may take several minutes.
    [00:00:00.251,312] <dbg> lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0
    [00:00:00.270,599] <dbg> lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0
    +CEREG: 2,"9E03","026B8102",7,0,0,"11100000","11100000"
    [00:00:02.253,540] <dbg> lte_lc.at_handler: +CEREG notification: +CEREG: 2,"9E03","026B8102",7,0,0,"11100000","11100000"

    [00:00:02.265,319] <dbg> lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec

    +CSCON: 1
    [00:00:02.305,145] <dbg> lte_lc.at_handler: +CSCON notification
    +CEREG: 5,"9E03","026B8102",7,,,"11100000","11100000"
    [00:00:05.878,753] <dbg> lte_lc.at_handler: +CEREG notification: +CEREG: 5,"9E03","026B8102",7,,,"11100000","11100000"

    [00:00:05.890,350] <dbg> lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec

    [00:00:05.898,345] <inf> asset_tracker: Connected to LTE network.
    [00:00:05.904,937] <inf> asset_tracker: Connecting to cloud, attempt 1 of 8
    [00:00:10.265,930] <inf> asset_tracker: Cloud connection request sent.
    [00:00:10.272,918] <inf> asset_tracker: Connection response timeout is set to 30 seconds.
    +CSCON: 0
    [00:00:17.348,327] <dbg> lte_lc.at_handler: +CSCON notification
    [00:00:40.281,646] <err> asset_tracker: LTE link disconnect
    +CSCON: 1
    [00:00:40.404,907] <dbg> lte_lc.at_handler: +CSCON notification
    +CEREG: 0,"9E03","026B8102",7,0,0,"11100000","11100000"
    [00:00:40.416,503] <dbg> lte_lc.at_handler: +CEREG notification: +CEREG: 0,"9E03","026B8102",7,0,0,"11100000","11100000"

    [00:00:40.428,253] <dbg> lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec

    +CSCON: 0
    [00:00:41.808,380] <dbg> lte_lc.at_handler: +CSCON notification
    [00:00:42.136,688] <err> asset_tracker: Shutdown modem

  • Hi Timothy,
    Have you provisioned the correct certificates to the modem?

    So the asset_tracker from v1.2.0 you were able to connect to your server, but not the NCS v1.3.0 version?

    Could you maybe share the Modem trace ?

Related