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 Reply Children
  • Actually,

    Multilik central and peripheral example is OK for me.

    But, all these examples just are sending button state and led state (1bit) 

    I need to send data (variable, counter, etc) and when sended data in receiver side i should compare this data ( if (rec_data == "Hello World!")) 

  • 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.

Related