Enable logging for nRf52840 dongle(PCA10059)

I have a requirement where I'm using a .NET-based test adapter that communicates using the Modbus protocol over a serial (COM) port.

Now, I want to develop a BLE Central device using the nRF52840 Dongle (PCA10059), which will communicate with other BLE Peripheral devices. The idea is to send Modbus commands from the .NET test adapter (via COM port) to the nRF52840 dongle, and the dongle will handle BLE operations accordingly.

At the same time, I want to be able to view log outputs from the dongle in parallel (e.g., to another COM port).

My Questions:

  1. Is it possible to achieve Modbus communication and logging simultaneously using the nRF52840 dongle without any hardware modifications (e.g., without soldering to UART pins)?

  2. If yes, could you please guide me on how to implement this? Specifically:

    • How to expose two virtual COM ports over USB (e.g., using two USB CDC ACM instances)?

    • How to route one COM port for Modbus commands and another for logs (e.g., using LOG_INF()).

    • Any example project or modifications to existing samples to support this use case.

SDK: nRF connect SDK v2.9.0
Toolchain : nRF connect SDK Toolchain v2.9.0
Board target : nrf52840dongle/nrf52840
Selected Nordiac SoC
zephyr version was v2.9.0

Looking forward to your guidance.

Thank you!

  • Hello Appugowda C,

    Is it possible to achieve Modbus communication and logging simultaneously using the nRF52840 dongle without any hardware modifications (e.g., without soldering to UART pins)?

    We don't have much experience Modbus, so we cannot confirm that Modbus over USB CDC ACM would work. You might find more help from the Zephyr Discord Server.

    How to expose two virtual COM ports over USB (e.g., using two USB CDC ACM instances)?

    In the past, I have added new virtual COM ports over USB by doing something simple like this:

    		usbd: zephyr_udc0: usbd@40027000 {
    			compatible = "nordic,nrf-usbd";
    			reg = < 0x40027000 0x1000 >;
    			interrupts = < 0x27 0x1 >;
    			num-bidir-endpoints = < 0x1 >;
    			num-in-endpoints = < 0x7 >;
    			num-out-endpoints = < 0x7 >;
    			num-isoin-endpoints = < 0x1 >;
    			num-isoout-endpoints = < 0x1 >;
    			status = "okay";
    			cdc_acm_uart: cdc_acm_uart {
    				compatible = "zephyr,cdc-acm-uart";
    			};
    			cdc_acm_uart0: cdc_acm_uart0 {
    				compatible = "zephyr,cdc-acm-uart";
    				label = "CDC_ACM_0";
    			};

    As the dongle already has one virtual COM port, you only need to add one more in your overlay.

    How to route one COM port for Modbus commands and another for logs (e.g., using LOG_INF()).

    The existing virtual COM port on the nRF52840 Dongle board file would have already been routed to the logging function, and you don't need to do anything.

    Adding a Modbus device as a child of an UART device is shown in this case:  What config changes I need to make for running the Modbus Example on nRF52832? 

    You can refer to it and add the Modbus node as a child of the new virtual COM device. However, as mentioned, I cannot be sure it will work.

    Any example project or modifications to existing samples to support this use case.

    The modifications I mentioned above could be tested using the Modbus RTU samples as base.

    Hieu

Related