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

Connect nRF52832 to CoAP IP using an LTE module.

Good morning,

I am using SDK 16.0.0 and nRF52832 uC. I have a project where I need to connect the uC to a CoAP IP. The only internet access it has is through an SoC developed by U-BLOX called SARA-R410M-02B which has an LTE unit embedded in our board. Is there a possibility to use CoAP supported libraries in this SDK and configure it to use it with our modem?

Thanks in advance.

Parents
  • Hi!

    I recommend using the nRF Connect SDK (NCS) where Zephyr provides a CoAP library where the users must create the sockets for communication. This is a good solution for your setup, where you have an MCU and a separate modem. 

    As long as you know how to deal with creating sockets on the U-Blox device from the nRF52832.

    Best regards,

    Heidi

  • Hi,

    Thanks for your answer. Yesterday I spent all day trying to compile CoAP example on nRF52832. However, I always get 'CONFIG_NET_CONFIG_IEEE802154_DEV_NAME' undeclared (first use in this function), any suggestions on how to fix that? Also, if you can bear with me, can you clarify much more how to use this library, or provide me a tutorial or an example to follow?

    Thanks in advance.

  • Hi! 

    I will be on vacation next week so I will take a look at this case next Monday. 

  • Which CoAP example are you trying to use?

    The one available in NCS (nRF CoAP Client) uses the CoAP utils library in NCS which uses the BSD socket API and therefore will not work on the nRF52 devices alone, only the nRF9160. To use the CoAP utils library on nRF52 devices, you will need some external device that implements BSD sockets, such as the U-Blox modem.

    Zephyr has the CoAP client and CoAP Server sample, both of which I am able to build for the nrf52dk_nrf52832 board.

  • Thanks for your answer, I am one step closer now. The CoAP client project is working now. The last thing left now, how can I use SARA-R410M-02B which has our LTE modem, to be used with such example?

    Thanks in advance.

  • One more thing, even though I am able to build a CoAP client project using the Zephyr platform, yet when I debug it on my boards, none of them works as expected at all. Any suggestion..

  • I think my initial advice was a bit misleading. 

    The Zephyr CoAP library will only format and parse the data, it does not have the functionality to send and receive it. Hence the CoAP client sample assumes the platform running it has networking support, so if you're running the sample on an nRF52 board, it will not be able to receive data.

    This is where the CoAP utils library in NCS comes in. It combines the Zephyr CoAP library to format data with the BSD Sockets API to send and receive.

    This library will work on an nRF52 device as long as there is some external device that implements BSD sockets: in your case the U-Blox modem. 

    You can try this with the nRF CoAP Client sample available in NCS, which uses the CoAP utils library. You will need to add an overlay file (<board_name.overlay>) to add the U-Blox modem to the device tree. Something like this:

    &uart0 {
    	current-speed = <115200>;
    	status = "okay";
    
    	sara_r4 {
    		compatible = "ublox,sara-r4";
    		label = "ublox-sara-r4";
    		mdm-power-gpios = <&arduino_header 11 0>; /* D5 */
    		mdm-reset-gpios = <&arduino_header 12 0>; /* D6 */
    		status = "okay";
    	};
    };
    

    Then in the prj.conf file, add and remove the following configs.

    # Add these
    CONFIG_NRFX_UART0=y
    CONFIG_MODEM=y
    CONFIG_MODEM_UBLOX_SARA=y
    CONFIG_MODEM_UBLOX_SARA_R4=y
    
    # Remove these
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    CONFIG_NRF_MODEM_LIB=y
    CONFIG_NRF_MODEM_LIB_TRACE_ENABLED=n
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_AT_HOST_LIBRARY=y

    I don't have a U-Blox modem to actually test this, so you might have to make some more modifications. But let me know how testing this goes!

    Best regards,

    Heidi

Reply
  • I think my initial advice was a bit misleading. 

    The Zephyr CoAP library will only format and parse the data, it does not have the functionality to send and receive it. Hence the CoAP client sample assumes the platform running it has networking support, so if you're running the sample on an nRF52 board, it will not be able to receive data.

    This is where the CoAP utils library in NCS comes in. It combines the Zephyr CoAP library to format data with the BSD Sockets API to send and receive.

    This library will work on an nRF52 device as long as there is some external device that implements BSD sockets: in your case the U-Blox modem. 

    You can try this with the nRF CoAP Client sample available in NCS, which uses the CoAP utils library. You will need to add an overlay file (<board_name.overlay>) to add the U-Blox modem to the device tree. Something like this:

    &uart0 {
    	current-speed = <115200>;
    	status = "okay";
    
    	sara_r4 {
    		compatible = "ublox,sara-r4";
    		label = "ublox-sara-r4";
    		mdm-power-gpios = <&arduino_header 11 0>; /* D5 */
    		mdm-reset-gpios = <&arduino_header 12 0>; /* D6 */
    		status = "okay";
    	};
    };
    

    Then in the prj.conf file, add and remove the following configs.

    # Add these
    CONFIG_NRFX_UART0=y
    CONFIG_MODEM=y
    CONFIG_MODEM_UBLOX_SARA=y
    CONFIG_MODEM_UBLOX_SARA_R4=y
    
    # Remove these
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    CONFIG_NRF_MODEM_LIB=y
    CONFIG_NRF_MODEM_LIB_TRACE_ENABLED=n
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_AT_HOST_LIBRARY=y

    I don't have a U-Blox modem to actually test this, so you might have to make some more modifications. But let me know how testing this goes!

    Best regards,

    Heidi

Children
  • By building up your suggested project on my board and adding your modifications, I get these errors in devicetree.h definition: #define DT_INST(inst, compat) UTIL_CAT(DT_N_INST, DT_DASH(inst, compat)):

    1. 'DT_N_INST_0_ublox_sara_r4_P_mdm_power_gpios_IDX_0_PH_P_label' undeclared here (not in a function)
    2. 'DT_N_INST_0_ublox_sara_r4_P_mdm_power_gpios_IDX_0_VAL_pin' undeclared here (not in a function)
    3. 'DT_N_INST_0_ublox_sara_r4_BUS_P_hw_flow_control' undeclared (first use in this function)
    4. 'DT_N_INST_0_ublox_sara_r4_BUS_P_label' undeclared (first use in this function) 

    Regards!

  • Can you check the resulting DeviceTree (the build/zephyr/zephyr.dts file) to see if the uart0 node was modified?

    Which NCS version are you using?

Related