Combining GNSS and CoAP client in nRF Connect SDK — GNSS fix not read, CoAP request not sent

Hi Nordic team,

I’m working on an nRF9151 DK with nRF Connect SDK v3.0.0.
My goal is to send GNSS latitude/longitude data to a CoAP server.

  • The GNSS sample works fine → I get correct coordinates.

  • The CoAP client sample works fine → I can send POST requests and get responses from my server.

  • But when I combine both in one project, I get no GNSS fix and no CoAP messages are sent.

I only see: 

<inf> coap_client_sample: Starting GNSS + CoAP client
<inf> coap_client_sample: Bringing network interface up
<inf> coap_client_sample: Waiting for network connectivity

  • Is there a specific order required for modem/LTE/GNSS init when used with CoAP?

  • Any debugging tips to see why GNSS events never trigger and CoAP never sends?

Additional info

  • Board: nRF9151 DK

  • SDK: nRF Connect SDK v3.0.0

  • Both examples work independently

  • Using IPv6 CoAP server

Any guidance or example on how to properly combine GNSS fix + CoAP POST would be greatly appreciated.

Regards 

Arun

Parents
  • Hi Arun,

    Can you describe your setup and provide complete application log?

    Best regards,
    Dejan

  • Hi, thanks for the quick response.

    Here’s my setup:

    • Board: nRF9151 DK

    • SDK: nRF Connect SDK v3.0.0

    • SIM/network: Jio NB-IoT (India)

    • Server: IPv6 CoAP server at dev-iot.imsafe.app:5683

    • Environment: Tested outdoors, GNSS works when I run the standalone GNSS sample.

    Here is the complete application log from boot:

    *** Booting nRF Connect SDK v3.0.0 ***
    *** Using Zephyr OS v4.0.99 ***
    [00:00:00.305] <inf> coap_client_sample: Starting GNSS + CoAP client
    [00:00:00.312] <inf> coap_client_sample: Bringing network interface up
    [00:00:00.320] <inf> coap_client_sample: Waiting for network connectivity
    +CEREG: 2,"C094","00482492",9
    +CSCON: 1
    +CEREG: 5,"C094","00482492",9,,,"11100000","11100000"
    +CEDRXP: 5,"1001","1001","0011"
    <no further GNSS or CoAP activity>

    When I run the GNSS sample alone → I get fixes.
    When I run the CoAP client alone → I get responses from the server.
    When I combine them → neither GNSS events nor CoAP requests happen.

    My goal is:
    To get latitude & longitude from the nRF9151’s GNSS and send that data via CoAP POST to my server.

    Regards

    Arun

  • Hi Arun,

    Can you describe details of your application logic?

    How did you integrate 2 samples? What was your starting point? Which changes did you make to the samples?

    Best regards,
    Dejan

  • Here are the details of my application logic and how I combined the two samples:

    • Starting point: I used the coap_client sample from nrf/samples/nrf9160/coap_client as the base.

    • Integration:

      1. I added the GNSS initialization and event handling from the gnss sample.

      2. In my main thread, after LTE link is established, I start GNSS (nrf_modem_gnss_start()).

      3. When a GNSS fix event arrives, I parse latitude/longitude from struct nrf_modem_gnss_pvt_data_frame.

      4. I format latitude/longitude into a JSON string (e.g. {"lat": xx.xxxxx, "lon": yy.yyyyy}).

      5. I send that JSON via CoAP POST to my IPv6 server (dev-iot.imsafe.app:5683).

    • Changes made:

      • Added GNSS related Kconfig options (CONFIG_NRF9160_GPS, CONFIG_MODEM_KEY_MGMT, CONFIG_GNSS_SAMPLE_ASSISTANCE_NONE, etc).

      • Modified main.c to include both GNSS event handler and CoAP send logic.

      • CoAP sending is triggered only when a GNSS fix is available.

    Current behavior:

    • LTE attaches successfully (CEREG: 5).

    • After that, GNSS events never arrive.

    • CoAP messages are never sent because no fix is received.

    I’m not sure if my current integration is correct.

    Can you please tell me the correct way to read GNSS location data (latitude & longitude) and send it to a custom CoAP server?

    Do you have any example code for this?

  • Hi juha,

    I can get location and send it to the CoAP server. Thank you for your support.

    Last thing I want to confirm: does GNSS only work outdoors?
    Because when I test indoors, I don’t get location, but outdoors it works.


    Regards,

    Arun

  • Hi Arun,

    GNSS description provides this information
    "GNSS signals do not usually penetrate ceilings or other structures that well. For best GNSS performance, the DK should be placed outside on a flat surface in an open space far from sources of interference and other structures that can block the satellite signals."

    In GNSS guide, you can find that "GNSS is designed to be used with a line of sight to the sky. Therefore, the performance is not ideal when there are obstructions overhead or if the receiver is indoors."

    You can also look at troubleshooting and why I cannot get GNSS fix.

    Best regards,
    Dejan

Reply Children
Related