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

Communication between nrf52840 and nrf9160 on thingy 91

Hei

I am trying to make SPI or UART communication between nrf9160 and nrf52840 on thingy 91....... i need to send data from nrf52840 to nrf9160(i will use and print the data)
what is the best way to do it? I tried connectivity bridge, but with no hope......


Another small question....i cannot get any thing out on putty when i write printk("hello world"); in the main function in connectivity bridge code ...how to fix it?

  • Hello Mohammad,

    you can communicate between the nRF9160 and nRF52840 on the Thingy:91 using MCU_IF.

    https://www.nordicsemi.com/-/media/Software-and-other-downloads/Dev-Kits/Thingy91/Hardware-files/Thingy91---Hardware-files-1_5_0.zip

    Have a look at “PCA20035_Schematic_And_PCB.pdf” page 2 (nRF91 GPIO pin mapping) & 3 (nRF52 GPIO pin mapping). The instances UART0 and UART1 on both sides are already pre-configured to communicate with each other.

     

    Another small question....i cannot get any thing out on putty when i write printk("hello world"); in the main function in connectivity bridge code ...how to fix it?

    In the file ../build/zephyr/zephyr.dts you can see that UART0 is used to write to the console. But since the connectivity bridge application doesn’t have a “connectivity bridge” for its own console data, it will not be transmitted from the nRF52840 via USB. Alternatively, you can use RTT to read printk commandos by setting CONFIG_RTT_CONSOLE=y in prj.conf.

     Cheers!

    Markus

  • hei
    Thanks for your answer

    1-
    I see that i can use MCU_IF to communicate between nrf91 and nrf52840, and I road that the connectivity bridge has already done it (if i don't misunderstand it) ....but how/ where I will write my code? do you have an example for UART functions? write and read? all I need for now is to send one string between nrf91 and nrf52840 and print it out to putty 

    I am using the connectivity bridge on nrf52840 and the asset tracker on nrf9160

    2-
    I tried CONFIG_RTT_CONSOLE=y on my prj.conf but i still don't get any output, is there anything else i can enable/disable to fix it?

  • Hello,

    Hamada888 said:
    1-
    I see that i can use MCU_IF to communicate between nrf91 and nrf52840, and I road that the connectivity bridge has already done it (if i don't misunderstand it) ....but how/ where I will write my code? do you have an example for UART functions? write and read? all I need for now is to send one string between nrf91 and nrf52840 and print it out to putty 

    I am using the connectivity bridge on nrf52840 and the asset tracker on nrf9160

    How and where to write the code is up to your requirements and needs. In general, you have to add/modify both the asset tracker and connectivity bridge application to handle the data which is transmitted between the units. As an example for how to set up an UART communication, you can have a look here:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/nrf/samples/peripheral/lpuart/README.html

    The connectivity bridge application already has UART code implemented, which could be a good entry point.

    Hamada888 said:
    2-
    I tried CONFIG_RTT_CONSOLE=y on my prj.conf but i still don't get any output, is there anything else i can enable/disable to fix it?

    I’m not sure if PuTTY is supporting RTT. Anyway, you can have a look at this guideline:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/zephyr/guides/tools/nordic_segger.html#rtt-console

    I hope this will help you.

    Cheers!

    Markus

  • thanks again for your answer


    i am trying now lpuart with asset tracker........... i copied lpuart code into asset tracker......... i get feil ("Failed to get the device") .................

    in main function I have:

     lpuart = device_get_binding("LPUART");
    __ASSERT(lpuart, "Failed to get the device");



    thingy91_nrf9160ns.overlay:

    &uart1 {
    compatible = "nordic,nrf-uarte";
    status = "okay";
    rx-pin = <44>;
    tx-pin = <45>;
    baudrate = <1000000>;
    /delete-property/ rts-pin;
    /delete-property/ cts-pin;
    /delete-property/ hw-flow-control;

    lpuart: nrf-sw-lpuart {
    compatible = "nordic,nrf-sw-lpuart";
    status = "okay";
    label = "LPUART";
    req-pin = <46>;
    rdy-pin = <47>;
    };
    };

    prj.conf:

    #
    # Copyright (c) 2019 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    # General config
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    CONFIG_ASSERT=y
    CONFIG_REBOOT=y
    CONFIG_LOG=y
    CONFIG_LOG_IMMEDIATE=y

    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_NATIVE=n
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_OFFLOAD=y

    # LTE link control
    CONFIG_POWER_OPTIMIZATION_ENABLE=n
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n

    CONFIG_LTE_NETWORK_MODE_NBIOT_GPS=n
    CONFIG_LTE_LEGACY_PCO_MODE=n
    CONFIG_LTE_PSM_REQ_RPTAU="00000110"
    CONFIG_LTE_PSM_REQ_RAT="00000010"

    # Modem info
    CONFIG_MODEM_INFO=y
    CONFIG_MODEM_INFO_ADD_DATE_TIME=n

    # Modem library
    CONFIG_NRF_MODEM_LIB=y
    CONFIG_NRF_MODEM_LIB_TRACE_ENABLED=n

    # nRF Cloud
    CONFIG_CLOUD_API=y
    CONFIG_NRF_CLOUD=y
    CONFIG_NRF_CLOUD_LOG_LEVEL_DBG=y
    CONFIG_NRF_CLOUD_AGPS=y
    CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD=y
    CONFIG_NRF_CLOUD_SEND_TIMEOUT=y
    CONFIG_NRF_CLOUD_SEND_TIMEOUT_SEC=60
    CONFIG_NRF_CLOUD_FOTA_LOG_LEVEL_DBG=y
    # nRF Cloud FOTA download configuration
    CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
    # Needed for the cloud codec
    CONFIG_CJSON_LIB=y
    # Shorter to prevent NAT timeouts
    CONFIG_MQTT_KEEPALIVE=120
    # Don't resubscribe to topics if broker remembers them
    CONFIG_MQTT_CLEAN_SESSION=n

    # Sensors
    CONFIG_ACCEL_USE_SIM=y
    CONFIG_TEMP_USE_SIM=y
    CONFIG_CLOUD_BUTTON=n

    # GPS
    CONFIG_NRF9160_GPS=y
    # CONFIG_GPS_USE_SIM=y
    CONFIG_NRF9160_GPS_LOG_LEVEL_DBG=y
    CONFIG_GPS_USE_EXTERNAL=y
    CONFIG_GPS_DEV_NAME="NRF9160_GPS"
    CONFIG_GPS_CONTROL_PSM_ENABLE_ON_START=y

    CONFIG_GPS_CONTROL_FIRST_FIX_CHECK_DELAY=10
    CONFIG_GPS_CONTROL_FIX_CHECK_INTERVAL=30
    CONFIG_GPS_CONTROL_FIX_TRY_TIME=360
    CONFIG_GPS_CONTROL_PSM_DISABLE_ON_STOP=n
    CONFIG_AGPS=y

    # Library for buttons and LEDs
    CONFIG_DK_LIBRARY=y
    CONFIG_DK_LIBRARY_INVERT_LEDS=n

    # Library that maintains the current date time UTC.
    CONFIG_DATE_TIME=y

    # Console
    CONFIG_CONSOLE_SUBSYS=y
    CONFIG_CONSOLE_HANDLER=y
    CONFIG_CONSOLE_GETCHAR=y

    # Heap and stacks
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    CONFIG_MAIN_STACK_SIZE=8192
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

    # Settings
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_FCB=y
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_FCB=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y

    # MCUBOOT
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUBOOT_IMG_MANAGER=y
    CONFIG_IMG_ERASE_PROGRESSIVELY=y


    CONFIG_CONSOLE=n               // this one from lpuart sample
    CONFIG_UART_CONSOLE=n
    CONFIG_NRF_SW_LPUART=y

    # Fatal error
    CONFIG_RESET_ON_FATAL_ERROR=n
    CONFIG_WATCHDOG=y


    how to fix it? i need to use uart to connect to nrf52840

    Mohammad

  • Hello Mohammad,

    configuring the LPUART in the asset tracker application is unfortunately not that straight forward. But I’m not sure if you need that, actually.

    UART0 and 1 are already pre-configured in the asset tracker, so you could use them as they are (and of course modify them via an overlay-file). You just replace the argument in the get binding function, eg.:

    uart0_dev = device_get_binding("UART_0");

    If you want to check the labels you can have a look at zephyr.dts in ../<your_build_folder>/zephyr.

    Let me know if you have any more questions!

    Regards,

    Markus

Related