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

Transmit GPS data to website

Hello 

I would like to transmit gps data to my website in addition to nrf cloud, there is a example or documentation about this that I can take of reference? I am working with nRF 9160 DK 

thanks in advance.

Kind Regards

Julio

Parents
  • Hi,

     

    The asset_tracker shows how to connect to a cloud based system, and send certain sensors + gps data to the cloud.

    If you want a simpler solution, like a tcp/udp connection directly to your own server, I would recommend that you look at the "gps" sample, and add your own implementation around this.

     

    Note that there's a restriction towards getting GPS and LTE concurrent, which is that you have to be in eDRX or PSM mode in order to use the GPS. A recommended use-case is to use the AT CSCON event to signal when you can or cannot use the GPS.

     

    Kind regards,

    Håkon

  • Thx Håkon,

    I tried setting CSCON=0 when initialising the GPS.

    (After looking at the code in asset_tracker I also saw it use lte_lc_psm_req(true))

    If I then try to initialise a UDP connection lte_lc_init_and_connect_async(lte_handler) fails.

    (Initialisation code from the UDP example)

    I'm not clear on the sequence I need to initialise both GPS and UDP.

    further...

    I wanted to see why lte_lc_init_and_connect_async is failing but this seems to be part of the distribution that is shipped in binary.

    Specifically, the error is:

    modem_configure()
    I: Using legacy LTE PCO mode...
    I: PDP Context: AT+CGDCONT=0,"IP","lpwa.vodafone.iot"
    E: Could not send AT command, error: -8

    Which is odd because when initialising the GPS we already sent 4 AT commands without error.

    This part of UDP initialisation works fine if I comment out the GPS initialisation 

    Thx.

  • Hi,

    paul_tanner said:
    I tried setting CSCON=0 when initialising the GPS.

     This is an event coming from the modem, which indicates if the LTE link is active or not. You should set the CSCON non-zero to enable notification, and then you should get it through your AT notification handler (if set).

    By setting it to 0, you're disabling the notification.

     

    paul_tanner said:
    If I then try to initialise a UDP connection lte_lc_init_and_connect_async(lte_handler) fails.

     Is "CONFIG_LTE_AUTO_INIT_AND_CONNECT" disabled? If this is enabled, the link is enabled and established prior to entering main. 

     

    paul_tanner said:
    I'm not clear on the sequence I need to initialise both GPS and UDP.

    You first need to enable the usage of GPS, for instance by enabling CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y (or if NB1: CONFIG_LTE_NETWORK_MODE_NBIOT_GPS)

    This will set the permission in AT%XSYSTEMMODE.

    If you are able to successfully enter PSM or eDRX, and you have ensured the CSCON event is enabled (See the docs here: https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/packet_domain/cscon_set.html?cp=2_1_6_16_0), you can start the GPS, as shown in the "gps" sample.

     

    The CSCON event is available through the lte_lc library, and samples like the udp/cloud_client/asset_tracker, implement a print when you're connected or idle:

    https://github.com/nrfconnect/sdk-nrf/blob/master/samples/nrf9160/udp/src/main.c#L79-L82

     

    when CSCON (or lte_lc::LTE_LC_EVT_RRC_UPDATE) gives you a notification "idle", you can start the GPS.

     

    Kind regards,

    Håkon

  • Many thx Håkon

    I guess this means that if testing without a connection it will wait indefinitely - if you let it.

    That should not be a problem as you can't send anything until you get a signal.

    I'll try this when I'm in range of a cell tower.

    Regards, Paul

  • You can evaluate the gps without using LTE, by running the "gps" example.

    This doesn't require LTE, but does require that you're outside (or the GPS-antenna shall be outside) while testing.

     

    Kind regards,

    Håkon

  • Thx Håkon

    Yes.  The first thing I did was to test both GPS and UDP examples.

    Only then did I try to put them together to make a minimal tracker using UDP and without the need for all the other good stuff in your asset_tracker app.

    So I now wait for udp Idle.

    However, from the code in the gps sample I then get an error from

    ```

    at_cmd_write(at_commands[i])

    ```

    AT_XSYSTEMMODE,  (fails on this one)
    AT_MAGPIO,
    AT_COEX0,
    AT_ACTIVATE_GPS

    so GPS is not activated.

    XSYSTEMMODE is probably redundant but why would it throw an error?

    Regards.

  • Hi,

     

    paul_tanner said:
    XSYSTEMMODE is probably redundant but why would it throw an error?

    Its highly likely because the modem is already enabled (AT+CFUN=1) at this point. Please check that "modem_configure()" isn't called, and that "CONFIG_LTE_AUTO_INIT_AND_CONNECT=n" is set in your project.

     

    Kind regards,

    Håkon

Reply Children
Related