Migrating MQTT Sample to a Custom Board

Hi,

I have successfully built and ran the MQTT sample (/opt/nordic/ncs/v2.7.0/nrf/samples/net/mqtt) on the nRF9160-DK. I did have a few problems with SIM coverage and firmware versions which was sorted in this ticket.

 MQTT Sample Not Connecting on nRF9160 Board 

I would now like to move this code onto my own board.

When I run this code on my own board, I see this error.

*** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
*** Using Zephyr OS v3.6.99-100befc70c74 ***
[00:00:00.431,610] <inf> network: Bringing network interface up and connecting to the network
[00:00:00.658,813] <inf> nrf_modem_lib_trace: Trace thread ready
[00:00:00.666,107] <inf> nrf_modem_lib_trace: Trace level override: 2
[00:00:00.667,724] <err> lte_lc: Could not send AT command, error: 65536
[00:00:00.667,755] <err> lte_lc: Failed to set system mode and mode preference, err -14
+CEREG: 2
+CEREG: 4
+CEREG: 2,"B984","00542616",9
+CSCON: 1
+CEREG: 2,"B984","00542616",9,0,11
+CSCON: 0
 

My overlay file is shown below.

&pinctrl {
        uart0_default: uart0_default {
                group1 {
                        psels = <NRF_PSEL(UART_TX, 0, 6)>, <NRF_PSEL(UART_RX, 0, 7)>;
                };
        };

        uart0_sleep: uart0_sleep {
                group1 {
                        psels = <NRF_PSEL(UART_TX, 0, 6)>, <NRF_PSEL(UART_RX, 0, 7)>;
                        low-power-enable;
                };
        };
};

&uart0 {
        status = "okay";
        current-speed = < 115200 >;
        /delete-property/ rts-pin;
        /delete-property/ cts-pin;
};

/* Enable uart1 for tracing. */

&uart1 {
   status = "okay";
   current-speed = <1000000>;
   pinctrl-0 = <&uart1_default>;
   pinctrl-1 = <&uart1_sleep>;
   pinctrl-names = "default", "sleep";
};

/ {
   chosen {
      nordic,modem-trace-uart = &uart1;
   };
};

I use UART0 for my serial terminal.

Would appreciate your pointers on this,

Thanks,

Rod 

Parents Reply Children
  • Hi Rod,

    I will look into this during next week.
    I expect to get back to you by the end of next week.

    Best regards,
    Dejan

  • Hi Rod,

    AT%XSYSTEMMODE command is allowed only before activating the modem using AT+CFUN=1. Before changing the system mode, you could try to put the modem in a required state using AT+CFUN=0 (or AT+CFUN=4).

    Best regards,
    Dejan 

  • Hi Dejan,

    I am running the "standard mqtt sample", (nrf/samples/net/mqtt) unmodified; so have not touched the code. It runs fine on the nRF9160DK board. 

    I tried another one of my boards and it seems to work, although I cant see any traces on the UART on the second board. This is what I see on the serial terminal.

    [00:00:00.721,435] <inf> nrf_modem_lib_trace: Trace thread ready
    [00:00:00.722,595] <inf> nrf_modem_lib_trace: Trace level override: 2
    [00:00:00.724,426] <err> lte_lc: Could not send AT command, error: 65536
    [00:00:00.724,456] <err> lte_lc: Failed to set system mode and mode preference, err -14
    [00:00:02.118,682] <wrn> nrf_modem_lib_netif: lte_lc_modem_events_enable, error: -14
    +CEREG: 2,"01B0","0928D982",7,0,0,"11100000","11100000"
    [00:00:16.853,210] <wrn> lte_lc: Registration rejected, EMM cause: 0, Cell ID: 153672066, Tracking area: 432, LTE mode: 7
    +CSCON: 1
    +CGEV: ME PDN ACT 0,0
    +CNEC_ESM: 50,0
    +CEREG: 1,"01B0","0928D982",7,,,"11100000","11100000"
    [00:00:19.289,672] <inf> network: Network connectivity established
    +CSCON: 0
    +CSCON: 1
    +CSCON: 0
    +CSCON: 1
    [00:00:45.602,630] <inf> transport: Connected to MQTT broker
    [00:00:45.602,691] <inf> transport: Hostname: test.mosquitto.org
    [00:00:45.602,722] <inf> transport: Client ID: 352656100493439
    [00:00:45.602,722] <inf> transport: Port: 8883
    [00:00:45.602,752] <inf> transport: TLS: Yes
    [00:00:45.602,813] <inf> transport: Subscribing to: 352656100493439/my/subscribe/topic
    [00:00:46.262,634] <inf> transport: Subscribed to topic 352656100493439/my/subscribe/topic
    [00:00:46.606,658] <inf> transport: Published message: "Hello MQTT! Current uptime is: 46605" on topic: "352656100493439/my/publish/topic"
    [00:00:46.627,716] <inf> transport: Published message: "Hello MQTT! Current uptime is: 46626" on topic: "352656100493439/my/publish/topic"
    [00:00:46.640,441] <inf> transport: Published message: "Hello MQTT! Current uptime is: 46639" on topic: "352656100493439/my/publish/topic"
    [00:00:46.653,015] <inf> transport: Published message: "Hello MQTT! Current uptime is: 46651" on topic: "352656100493439/my/publish/topic"
    [00:00:46.664,398] <inf> transport: Published message: "Hello MQTT! Current uptime is: 46663" on topic: "352656100493439/my/publish/topic"

    So, summarise.

    When i run the code on one of my boards, i get a trace on UART0 but the board does not connect to the network.

    When i run the same code on another board, (exact same hardware, same code, same SIM card etc). It does connect but I do not see a trace. 

    I have flashed both boards with the latest modem firmware. 

    Apart from the possibility of a hardware fault, is there anything else i am missing?

    Thanks,

    Rod

Related