MQTT Sample Not Connecting on nRF9160 Board

Hi,

Sorry, i am new to MQTT so may be asking a stupid question, please bear with me. 

I am trying to run the MQTT sample (nrf\samples\net\mqtt) and get the following output

*** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
[00:00:00.312,896] <inf> network: Bringing network interface up and connecting to the network
[00:00:00.505,187] <inf> nrf_modem_lib_trace: Trace thread ready
[00:00:00.506,500] <inf> nrf_modem_lib_trace: Trace level override: 2
[00:00:00.508,270] <err> lte_lc: Could not send AT command, error: 65536
[00:00:00.508,270] <err> lte_lc: Failed to set system mode and mode preference, err -14
+CEREG: 2,"01B0","081A1682",7,0,0,"11100000","11100000"
+CSCON: 1
+CSCON: 0
+CSCON: 1
+CGEV: ME PDN ACT 0,0
+CNEC_ESM: 50,0
+CEREG: 1,"01B0","081A1682",7,,,"00011110","00011011"
[00:00:15.113,403] <inf> network: Network connectivity established
+CSCON: 0
+CSCON: 1
+CSCON: 0
+CSCON: 1
+CSCON: 0
+CSCON: 1
+CSCON: 0
+CSCON: 1
[00:00:43.618,835] <err> mqtt_helper: mqtt_connect, error: -116
[00:00:43.618,865] <err> transport: Failed connecting to MQTT, error code: -116
+CSCON: 0

Looking at the cellular monitor, it suggests I am connecting?

Any pointers would be appreciated

Rod

Parents
  • Hello Rod, 

    What MQTT broker are you trying to connect? And with what SIM card? 

    From the start of the log, the LTE Link Controller reports the following

    [00:00:00.508,270] <err> lte_lc: Could not send AT command, error: 65536
    [00:00:00.508,270] <err> lte_lc: Failed to set system mode and mode preference, err -14

    #define NRF_EFAULT 14           /**< Bad address */
    #define NRF_ETIMEDOUT 116       /**< Connection timed out */
    Here is my output after building the default MQTT sample (with nRF Connect SDK v2.6.0)
    +CSCON: 1
    +CGEV: ME PDN ACT 0,0
    +CNEC_ESM: 50,0
    +CEREG: 5,"8173","01165700",7,,,"11100000","11100000"
    [00:00:09.843,292] <inf> network: Network connectivity established
    [00:00:15.231,231] <inf> transport: Connected to MQTT broker
    [00:00:15.231,262] <inf> transport: Hostname: test.mosquitto.org
    [00:00:15.231,323] <inf> transport: Client ID: 350457791991456
    [00:00:15.231,323] <inf> transport: Port: 1883
    [00:00:15.231,353] <inf> transport: TLS: No
    [00:00:15.231,414] <inf> transport: Subscribing to: 350457791991456/my/subscribe/topic
    [00:00:15.303,253] <inf> transport: Subscribed to topic 350457791991456/my/subscribe/topic
    +CSCON: 0
    [00:01:00.324,523] <inf> transport: Published message: "Hello MQTT! Current uptime is: 60315" on topic: "350457791991456/my/publish/topic"
    +CSCON: 1
    +CSCON: 0
    [00:02:00.324,707] <inf> transport: Published message: "Hello MQTT! Current uptime is: 120315" on topic: "350457791991456/my/publish/topic"
    +CSCON: 1
    +CSCON: 0
    KInd regards,
    Øyvind
  • Hi Øyvind,

    I have not changed the code so am trying to connect to the default of test.mosquitto.org. I am using a Tesco PAYG SIM currently but have tried SIMS from EE and Vodafone. Can you recommend one? I am based in the UK.

    Cheers,

    Rod

  • No, no reason, i just have not updated to the latest :-( I will update the modem firmware and let you know. 

    Thanks,

    Rod

  • Hi Øyvind,

    I updated the firmware to the latest version.

    However, this seems to have introduced more errors. The trace-sim-lte connection-ppm status is stuck at Trace.

    There is also an error around the database.

    Do i need to change something else to use the latest firmware?

    Rod

  • I moved to 1.3.5 and saw the same error but when i moved to 1.3.4, it seems to be working better.

    Its still not connecting 

    Here is the trace file

    trace-2024-06-21T15-21-04.370Z.mtrace

    Any suggestions?

    Rod

  • Thanks Rod! 

    The device is timing out during the connection. My initial thought is that your connection is poor, i.e. bad signal strength. 

    At what location are you testing?

    Kind regards,
    Øyvind

  • Hi Øyvind,

    I just outside Cambridge, in CB23 postcode. I have put the SIM card in a mobile phone and and seeing "4 bars" so I think Im getting a strong signal. Maybe I am using an incompatible SIM card. Can you recommend one for this area?

    Does the MQTT demo use LTE-M or NBIOT?

    Rod

Reply Children
Related