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

NRF_ERROR_TIMEOUT while running pc-ble-driver-py/examples/heart_rate_collector.py

Hi,

I'm newbie to nRF DKs but started trying to run examples from pc-ble-driver-py/pc_ble_driver_py/examples/ on github in order to get familiar with the nRF52840.
I managed to install the library and everything works fine for the example - serial_port_enum.py which gives me the serial port and then I try running heart_rate_collector.py like this

(>>>python3 heart_rate_collector.py NRF52 <my_serial_port>) terminal throws an error 'NRF_ERROR_TIMEOUT'.

I'm working on mac os 10.15.

Any suggestions?

best regards,
Jakub

Parents
  • Hello Jakub,

    I'm newbie to nRF DKs

    Welcome! Please do not hesitate to ask here in the forums if you should encounter any issues or questions.

    to run examples from pc-ble-driver-py/pc_ble_driver_py/examples/ on github in order to get familiar with the nRF52840.

    This is indeed a good way to start familiarizing with the pc-ble-driver. However, the pc-ble-driver is intended to be integrated into desktop applications, i.e it is best used when you intend to create your own desktop program / application from scratch.
    If you would like to skip this step for now, and start working primarily on the nRF52840 side of things, then I suggest making use of our nRF Connect Application for Desktop
    Alternatively, you could use a simple serial monitor on your desktop to monitor the activities of the nRF52840 DK, and then connect the DK to your phone through BLE.
    If you are unfamiliar with BLE and nRF development I would recommend one of the two above approaches, since you then do not have to set up your central side program / application in addition to the nRF52840 code.

    I managed to install the library and everything works fine for the example

    Could you elaborate what you mean when you say that everything works fine - are you here referring to the library installation being successful?

    What the pc-ble-driver-py is actually doing in this example is using the device that is connected through the serial port to communicate with another device that is running the Heart Rate Application. So, if this is to work, you will need two BLE devices - one connected to your computer through USB, and one running the Heart Rate Application nearby.
    Could you confirm for me whether you have two devices, where one is programmed with the pc-ble-driver connectivity firmware, and one is programmed with the Heart Rate Application from the SDK?

    The device connected to your computer through the serial port also needs to be flashed with the connectivity firmware, to respond properly to your python program. Have you made sure to perform the hardware setup of the pc-ble-driver before launching the Heart Collector example?
    I suspect that the connectivity firmware is not flashed to your nRF52840 DK, and that this is the reason behind the "NRF_ERROR_TIMEOUT" error message you are seeing. It is probably caused by python trying to open the serial port to the device, and the device not complying, thus timing out.

    I highly recommend checking out either the Getting Started with nRF Connect SDK page or the Getting Started with nRF5 SDK and SES for nRF52 page, if you have not already.

    Looking forward to resolving this issue together!

    Best regards,
    Karl

  • Thank You for quick response!

    If you would like to skip this step for now, and start working primarily on the nRF52840 side of things, then I suggest making use of our nRF Connect Application for Desktop
    Alternatively, you could use a simple serial monitor on your desktop to monitor the activities of the nRF52840 DK, and then connect the DK to your phone through BLE.

    My goal for now is to try running heart_rate_app.py from computer (>>>python3 heart_rate_collector.py NRF52 <my_serial_port>) to make the connected DK work in the same way as I flash .hex file in the J-Link or build the app via segger and then observe the result on the nrF toolbox App on smartphone. Which brings question, is it supposted to work the same way? I assume yes (DK connected to pc + smartphone toolbox app running Heart Rate Application), as you wrote:

    What the pc-ble-driver-py is actually doing in this example is using the device that is connected through the serial port to communicate with another device that is running the Heart Rate Application. So, if this is to work, you will need two BLE devices - one connected to your computer through USB, and one running the Heart Rate Application nearby. Could you confirm for me whether you have two devices, where one is programmed with the pc-ble-driver connectivity firmware, and one is programmed with the Heart Rate Application from the SDK?

    (DK connected to pc + smartphone toolbox app running Heart Rate Application)

    Could you elaborate what you mean when you say that everything works fine - are you here referring to the library installation being successful?

    By that I ment library installation accordignly to the steps on github.com. serial_port_enum.py example works perfectly which indicates that as well.

    I suspect that the connectivity firmware is not flashed to your nRF52840 DK, and that this is the reason behind the "NRF_ERROR_TIMEOUT" error message you are seeing. It is probably caused by python trying to open the serial port to the device, and the device not complying, thus timing out.

    By flashing connectivity firmware on my DK you mean copying .hex file on J-Link in Finder?

    Best regards,
    Jakub

  • jmichalo said:
    Thank You for quick response!

    No problem at all, I am happy to help!

    jmichalo said:
    My goal for now is to try running heart_rate_app.py from computer (>>>python3 heart_rate_collector.py NRF52 <my_serial_port>) to make the connected DK work in the same way as I flash .hex file in the J-Link or build the app via segger and then observe the result on the nrF toolbox App on smartphone. Which brings question, is it supposted to work the same way?

    No, not exactly.
    The pc-ble-driver-py will need a connected nRF device with the connectivity firmware programmed, to work. So, the DK that you are using together with the pc-ble-driver-py can not simultaneously be programmed with the Heart Rate Application from the SDK, and the connectivity firmware for the pc-ble-driver-py.
    When you are connecting your phone to a device running the Heart Rate Application, then the phone will act as the central. This is the same role that the pc-ble-driver-py will fulfill - but as mentioned the pc-ble-driver-py will need a connected device with the connectivity firmware.

    jmichalo said:
    (DK connected to pc + smartphone toolbox app running Heart Rate Application)

    Yes, this will work. If you flash the DK with the Heart Rate Application from the SDK, and connect to it with a phone running the nRF Toolbox with Heart Rate monitor application you will see the heart rate displayed. This is how the Heart Rate monitor example is made to be connected.
    Now, if you would like to swap out the phone central, and instead use your computer with pc-ble-driver-py as central, you will need to provide pc-ble-driver-py with a nRF device programmed with the aforementioned connectivity firmware.

    jmichalo said:
    By that I ment library installation accordignly to the steps on github.com. serial_port_enum.py example works perfectly which indicates that as well.

    Great! Did you also follow the setup guide detailed in the pc-ble-driver github?

    jmichalo said:
    By flashing connectivity firmware on my DK you mean copying .hex file on J-Link in Finder?

    Yes, that is one way to program the DK with the connectivity firmware.
    If you intend to use the pc-ble-driver, then please make sure that you have completed every step of the hardware setup guide from pc-ble-driver github, as well as the library installation form pc-ble-driver-py.
    Keep in mind that if you only have 1 DK, and you flash it with the connectivity firmware, you will not have any device running Heart Rate Application to connect to.
    I am mentioning this just to avoid any confusion.

    Best regards,
    Karl

  • If you intend to use the pc-ble-driver, then please make sure that you have completed every step of the hardware setup guide from pc-ble-driver github, as well as the library installation form pc-ble-driver-py.

    Yes, I followed every step for hardware setup on github and for pc-ble-driver-library installation. Now after flashing connectivity firmaware on J-Link I can finally use aforementioned library with Python and connect to my DK. That was the issue!

    Now, if you would like to swap out the phone central, and instead use your computer with pc-ble-driver-py as central, you will need to provide pc-ble-driver-py with a nRF device programmed with the aforementioned connectivity firmware.

    Following this logic when the PC is a central. I intend to build my application where DK(peripheral) sends data to my PC(central), is that correct that with that pc-ble-driver-py library I would need two nrf devices for this data transfer? Additionally one e.g. dongle plugged to the Computer pc to be a client of DK that is a server? or is that possible to establish communication DK-pc?

Reply
  • If you intend to use the pc-ble-driver, then please make sure that you have completed every step of the hardware setup guide from pc-ble-driver github, as well as the library installation form pc-ble-driver-py.

    Yes, I followed every step for hardware setup on github and for pc-ble-driver-library installation. Now after flashing connectivity firmaware on J-Link I can finally use aforementioned library with Python and connect to my DK. That was the issue!

    Now, if you would like to swap out the phone central, and instead use your computer with pc-ble-driver-py as central, you will need to provide pc-ble-driver-py with a nRF device programmed with the aforementioned connectivity firmware.

    Following this logic when the PC is a central. I intend to build my application where DK(peripheral) sends data to my PC(central), is that correct that with that pc-ble-driver-py library I would need two nrf devices for this data transfer? Additionally one e.g. dongle plugged to the Computer pc to be a client of DK that is a server? or is that possible to establish communication DK-pc?

Children
  • jmichalo said:
    Yes, I followed every step for hardware setup on github and for pc-ble-driver-library installation. Now after flashing connectivity firmaware on J-Link I can finally use aforementioned library with Python and connect to my DK. That was the issue!

    Great, I am happy to hear that you were able to resolve your issue and now can use the pc-ble-driver-py library!

    jmichalo said:
    Following this logic when the PC is a central. I intend to build my application where DK(peripheral) sends data to my PC(central), is that correct that with that pc-ble-driver-py library I would need two nrf devices for this data transfer? Additionally one e.g. dongle plugged to the Computer pc to be a client of DK that is a server?

    Yes, if you intend to use the pc-ble-driver-py for your Bluetooth communication on the PC, then you will need to provide the pc-ble-driver-py with an nRF device flashed with the connectivity firmware from the official Github repository.

    jmichalo said:
    or is that possible to establish communication DK-pc?

    Yes, this is also possible - to connect the DK to the PC using the PC's built-in BLE adapter. This is possible, but most operating system does not accept data from "random" connected Bluetooth devices. Mainly, acting as a central the PC will either have to request data from the peripheral or enable notifications to receive data unprompted from the peripheral. This is where the pc-ble-driver-py comes in. You will need to perform these actions as a central on the PC - to request and receive the data from the peripheral, and process the data accordingly - since the operating system does not do this on its own.

    However, operating systems do accept data a certain group of devices, namely from Human Interface Devices ( HID ), such as a keyboard or a mouse. So, the answer to your question is:
    Yes, this is possible if you intend to create a HID device ( or other device natively accepted by the Operating System ), but it will not work for any other data. In the case of a non-HID device you will need to create a desktop application that initiates and handles the BLE communication, and that is why we have created the pc-ble-driver-py ( which requires an accompanying Bluetooth stack ( SoftDevice ), which requires an nRF device ).

    If you would like to see this in action, you can flash your DK with one of the HID examples from the SDK and see that it shows up and functions when connected to the PC's BLE adapter ( because HID devices are known devices, and the PC knows what to do with the received information ). However, if you flash your DK with a non-HID example from the SDK the device will show up during scanning, and you can connect to it just fine, but nothing more will happen. This is because the PC does not discover any known services or profiles on the device, and therefore does not know what to do with any data that the peripheral tries to send ( which would be unexpected to the PC ).

    I hope my answer here was more clear. Please let me know if anything still should be unclear, or if you have any other questions!

    Best regards,
    Karl

Related