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

Combined normal GPS to MQTT Simple example

Hi, I want to use normal GPS data (not AGPS) to send to my MQTT server.

I work well with MQTT_Simple to send sensor data to my server.

I see a GPS example in /nrf/samples/nrf9160/gps and can run it successfully.

I don't know how to combine these 2 examples, can you give me some clues?

I try to combine, use thread (K_THREAD_STACK_DEFINE), but got a very hard fault when running (stack overflow, Precise data bus error, ....)

My dummy main code

I use ncs v1.5.1, thingy91, ubuntu 18.0.4

Thanks in advance

Parents
  • Hi,

     

    You are on the right track, by looking at the two functionalities you need, and combine those into one application.

    I try to combine, use thread (K_THREAD_STACK_DEFINE), but got a very hard fault when running (stack overflow, Precise data bus error, ....)

    This usually means that you gave the stack that is faulting too little memory, or that you have a out-of-bounds access somewhere in that specific thread. In this case, I see that you have the thread 500 bytes, which is highly likely too little.

     

    When you get the fault information, you also get a memory address of the thread that faulted. You can look at the build-folder/zephyr/zephyr.map to see what thread this corresponds to, and adjust the memory size accordingly.

     

    Kind regards,

    Håkon 

  • Hi and thanks for the quick response, Does it need anything special when combining NB-IoT and GPS? For example, is it necessary to turn off NBIoT while doing a GPS scan?
    In the MQTT_Sample example, I use NBIoT + GPS mode, so when should I initialize GPS? After the MQTT client is connected and polling the network?
    It is true that I should combine the 2 examples GPS and MQTT_Sample, but which combination makes the most sense? Which process should be done first? Thanks for reading

  • Hi,

     

    Nahan_Trogn said:
    Does it need anything special when combining NB-IoT and GPS? For example, is it necessary to turn off NBIoT while doing a GPS scan?

    If you are able to enter eDRX or PSM mode, you can run the GPS in those modes.

    You can use the AT+CSCON event to signal when you're IDLE (thus can start the GPS): https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/packet_domain/cscon_set.html?cp=2_1_6_16_0

     

    You need to enable both NB1 and GPS in AT%XSYSTEMMODE, but you can use the helper library lte_lc to enable this on boot, by setting this config in your prj.conf:

    https://github.com/nrfconnect/sdk-nrf/blob/master/lib/lte_link_control/Kconfig#L150

     

     

    Nahan_Trogn said:
    In the MQTT_Sample example, I use NBIoT + GPS mode, so when should I initialize GPS? After the MQTT client is connected and polling the network?

     You shall start the GPS only when the link is idle. As mentioned, this is via CSCON event, which can also be given by the lte_lc library:

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

     

    Nahan_Trogn said:
    It is true that I should combine the 2 examples GPS and MQTT_Sample, but which combination makes the most sense? Which process should be done first? Thanks for reading

    I haven't though about this much, but I guess its usually starting with the largest logic, which might be mqtt in this case.

     

    Kind regards,

    Håkon 

Reply Children
No Data
Related