Configure USB com port and write to Serial Monitor

Hi,

I’m quite new to the nRF5 SoC’s and currently facing a problem with USB virtual com port communication using nRF52840 dongle (PCA10059). I need to get results from the dongle through a Serial Monitor without using external communication IC (as an example, let’s say i = 0 and increase i every one second by 1. Then print the value of i to a Serial Monitor).

I’m referred the examples (located in peripheral folder) ‘usbd_ble_uart’ and ‘usbd_cdc_acm’. But unfortunately, unable to understand “how to set up the virtual USB Com Port” and “print values using it to a Serial Monitor”. Very appreciate if someone can provide simple code, example or guide for the mentioned problem.

I’m using Segger Embedded Studio with nRF5_SDK_15.3.0.

Parents
  • Hi,

    I’m quite new to the nRF5 SoC

    I see that you use nRF5_SDK_15.3.0.

    If you are starting with our products, we recommend using the nRF Connect SDK.
    Do you have any reason for using the nRF5 SDK instead?

    To better be able to help you with this issue:
    What is the end goal for the dongle to do?
    Can you provide a brief overview over your use-case?

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    Thank you for your reply.

    My end goal is to collect data through some sensors (e.g.:ICM42670, using i2c interface), done some calculations and send to a mobile app through BLE. I found a similar library (made for MPU6050) and modified it for the this one. This is the reason to use nRF5 SDK for the project, because the old library tutorial is on nRF5 SDK. I have limited time for the moment, therefore decided to follow the same approach.

    For now, I'm stuck with data monitoring part which essential to evaluate the modified library and to configure the sensors. I want to read the sensors and display on a Serial Monitor (like PuTTY, or Arduino).

    If it is recommended, I'll try Connect SDK. But could you please provide guidelines to configure a Com port (through USB port) and write data using nRF5 SDK also.

    Regards.

  • Hi,

    If you decide to use the nRF Connect SDK, have a look at the Zephyr MPU6050: Invensense Motion Tracking Device sample, it might be useful.

    Then to your issue with the nRF5 SDK:

    Did you program the example to the Dongle?
    Have you confirmed that the sample runs on the Dongle? How did you observe this?

    But unfortunately, unable to understand “how to set up the virtual USB Com Port” and “print values using it to a Serial Monitor”.

    Open a Serial Monitor, such as Arduino. Personally I like Tera Term or Termite.
    With the Dongle connected, can you open a Serial Emulator "COM-port list" and screenshot it to paste here?
    It should just be to connect to the correct COM-port and you should be able to see data when pressing the button on the Dongle running usbd_cdc_acm.

    Regards,
    Sigurd Hellesvik

Reply
  • Hi,

    If you decide to use the nRF Connect SDK, have a look at the Zephyr MPU6050: Invensense Motion Tracking Device sample, it might be useful.

    Then to your issue with the nRF5 SDK:

    Did you program the example to the Dongle?
    Have you confirmed that the sample runs on the Dongle? How did you observe this?

    But unfortunately, unable to understand “how to set up the virtual USB Com Port” and “print values using it to a Serial Monitor”.

    Open a Serial Monitor, such as Arduino. Personally I like Tera Term or Termite.
    With the Dongle connected, can you open a Serial Emulator "COM-port list" and screenshot it to paste here?
    It should just be to connect to the correct COM-port and you should be able to see data when pressing the button on the Dongle running usbd_cdc_acm.

    Regards,
    Sigurd Hellesvik

Children
  • Hi Sigurd,

    There is no problem on the PC side. I want to configure the code. I think it is my mistake to not mentioned before.

    The attached image shows a code with a count. But, as I think the NRF_LOG_INFO is printed through a separated UART port (if use a board like PCA10056). Let's say, I want to get the same data using the USB port, and please give necessary details to simply turn on and write data using the USB port. Simply, the same example with NRF_LOG_INFO, not using UART, but USB port. (Very appreciate if supply necessary sdk_config configurations, libraries and code to usb port turn on)

    I know this is a very basic question, but still I didn't able to do this correctly.

    Thank you.

  • To see if I understand correctly:
    If you use the usbd_cdc_acm sample, you can see data on the USB, right?

    In that case, you do it like this:

    1. Find tool to compare files. I like VS Code.
    2. Open Segger Embedded Studio (SES)
    3. Find the most basic sample you know. For example peripheral/blinky. Open blinky in SES.
    4. Open more complicated sample in SES. For this example peripheral/usbd_cdc_acm.
    5. Copy main.c file from blinky into new file inVS Code. Copy main.c from
    6. Compare main.c files using the "Compare files" functionality in VS Code.
    7. The differences are likely the parts you need to enable the feature.
    8. Next do the same for sdk_config.h
    9. Next, also compare files included in SES solution:
    10. Make sure that blinky has the correct .c files here
    11. Next we will also figure out which headers are needed for this.
      1. Right-click the project configuration and select "Options ..."
      2. Then Click "Release" and select "Common"
      3. Enter menu "Preprocessor"
      4. Double-click "User Include Directories"
      5. These are included directories for header files.
    12. Compare these directories for both projects, and you find which are needed for your project.
    13. Now you should know every difference, and you can apply them to your project.

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    Thank you very much for the guidance. I'll try the way you mentioned above.

Related