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

nRF52840 Sensor Network with SPI Sensor

Dear All,

I am working with nRF52840 product. According to my scenario i have 1central unit(master) and up to 19 peripheral unit(slave).

I downloaded SDK 15.3.0 ble_central and ble_pripheral examples. These examples are very very good. They are sending button and led situations.

In my project, i have SPI sensor at slaves. So, i should read Spi register value and send to the master. 

How i can add Spi reading in to the ble_peripheral example

Best regards,

Parents
  • If you want to merge SPI functions into the ble_peripheral example you'll have to do the following:

    • Copy the example examples/ble_peripheral into the same folder with a new name, then open it and add the SPI related code
    • The SPI functions you have added will have both header and source files associated with it and you have to make these files visible for the compiler
      • Add the paths to all the header files
      • Add the source (.c) files to Project Explorer
    • Enable necessary peripherals and settings in the sdk_config.h file (look at the SPI examples to see what needs to be enabled)

    Some cases about merging:

    If anything is unclear, or if you are struggling with any of the steps above please tell me and I will explain more thoroughly.

    Best regards,

    Simon

  • Dear Simon,

    First of all, thank for your quick help.

    Let me explain my point to you.

    There is one master, and one slave. 

    In slave side i connected acceloremeter via SPI to nRF52840.

    My point is just, get one register value from my acceloremeter and send to the master via BLE

    I just want to learn which example code i need to use. 

    Please show way to do it to me

  • If you want to transfer strings over a BLE connection, from a peripheral to a central, you have to set some parameters which you provide to sd_ble_gatts_hvx():

    char my_array[] = "HEY";
    uint16_t length = sizeof(my_array);
    .
    .
    .
    
    params.p_len  = &length;
    params.p_data = my_array;  
    sd_ble_gatts_hvx(p_our_service->conn_handle, &hvx_params);

    On the central side, you will receive the data as ASCII number. In the case above, the central will receive 0x48 45 59. If you cast these hex values to a char's after receiving, you'll be able to read the string 

    Best regards,

    Simon

  • I really dont understand, 

    Either Nordic examples are very complex, or i dont understand.

    I am trying to send my data over ble almost with 2months but i still cant do it.

    I am just trying to sen "Counter = xxx" string to center unit. 

    It seems it is impossible...

  • I am trying to send my data over ble almost with 2months but i still cant do it.

    I am just trying to sen "Counter = xxx" string to center unit. 

    Could you be more specific on where you are stuck? Did you see my answer below? Did that make sense? If not, what specifically did you not understand?

    Could you provide some code? Then it will be easier for me to understand what you are trying to do.

    Best regards,

    Simon

  • Dear Simon,

    Thank you for your pasion and helpful answer.

    When i try to use, 
    nRF5_SDK_15.3.0_59ac345\examples\ble_central\ble_app_multilink_central
    and
    nRF5_SDK_15.3.0_59ac345\examples\ble_peripheral\ble_app_blinky

    It connect upto 20, can send led state, can send button state. Everything is good. Only i cannot send string instead of state (Temperature :30) (just example)

    When i try to use,
    nRF5_SDK_15.3.0_59ac345\examples\ble_central\ble_app_uart_c
    and
    nRF5_SDK_15.3.0_59ac345\examples\ble_peripheral\ble_app_uart

    It can only support 1 central, 1 peripheral
    When i try to change 
    NRF_SDH_BLE_CENTRAL_LINK_COUNT
    and
    NRF_SDH_BLE_PERIPHERAL_LINK_COUNT

    It gives error : NRF_ERROR_NO_MEM


    So, With these two ways i am facing some errors.

  • Ekmekci said:

    It can only support 1 central, 1 peripheral
    When i try to change 
    NRF_SDH_BLE_CENTRAL_LINK_COUNT
    and
    NRF_SDH_BLE_PERIPHERAL_LINK_COUNT

    It gives error : NRF_ERROR_NO_MEM

    Do the following:

    • Open the ble_app_uart example in SEGGER Embedded Studio
    • Change NRF_SDH_BLE_CENTRAL_LINK_COUNT and NRF_SDH_BLE_PERIPHERAL_LINK_COUNT appropriately
    • In sdk_config.h set NRF_LOG_BACKEND_RTT_ENABLED to 1
    • Build your application
    • Start a new debug session
      • Debug→Go→(Grren triangle)
    • The program will stop and you will see something like this:

    •  Change the RAM_START and RAM_SIZE as the log message specified
      • E.g. I have to change RAM_START to 0x20003D08 and RAM_SIZE to 0xC2F8
      • Follow section 4 in this tutorial, which shows you how to do this

    Best regards,

    Simon

Reply
  • Ekmekci said:

    It can only support 1 central, 1 peripheral
    When i try to change 
    NRF_SDH_BLE_CENTRAL_LINK_COUNT
    and
    NRF_SDH_BLE_PERIPHERAL_LINK_COUNT

    It gives error : NRF_ERROR_NO_MEM

    Do the following:

    • Open the ble_app_uart example in SEGGER Embedded Studio
    • Change NRF_SDH_BLE_CENTRAL_LINK_COUNT and NRF_SDH_BLE_PERIPHERAL_LINK_COUNT appropriately
    • In sdk_config.h set NRF_LOG_BACKEND_RTT_ENABLED to 1
    • Build your application
    • Start a new debug session
      • Debug→Go→(Grren triangle)
    • The program will stop and you will see something like this:

    •  Change the RAM_START and RAM_SIZE as the log message specified
      • E.g. I have to change RAM_START to 0x20003D08 and RAM_SIZE to 0xC2F8
      • Follow section 4 in this tutorial, which shows you how to do this

    Best regards,

    Simon

Children
No Data
Related