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

Please tell me how to connect one nRF51822 and another as Central and Peripheral. In the future, I would like to connect one Central and multiple Peripheral.

I am new to BLE.

My question is similar to the one below.

https://devzone.nordicsemi.com/f/nordic-q-a/22596/nrf51822-central-connect-and-communicate-with-2-peripherals

But the link to the answer was broken and I couldn't find it, so I'll ask.

I am using two nRF51822 and SDK12.3.0. I want to run them as Central on one side and Peripheral on the other. 

Probably by a method called GATT communication.(It means communication in a connected state.)

My goal is to record  RSSI and receiving time in Central when it receives an empty packet from Peripheral.

I would like to receive packets at intervals of 1msec to 10msec,

so advertising with long transmission intervals and randomly staggered transmission times would not achieve my goal.

In the future, I would like to receive packets from about 6 peripherals and record the RSSI of the packets.

Please let me know if there is a sample program or code that fits my purpose.

I'm not very good at English, so I use translation software to create my texts. I'm sorry if I don't make sense in some parts.

  • But this time I can't change the board.

    Looking at https://no.mouser.com/datasheet/2/396/TY_BLE_CN_EVBManual_V1_5_20180530-1324564.pdf the UART pins used, does not match the pins we use on the DK.

    EBSGCNZWY board:

    So in sdk_config.h, change the nrf_log uart pins to match your board,

    for the DK, the configurations looks like this:

    You need to use pin 0,1,2,3 instead.

    ----

    If this board don't have LF crystal, you also need to configure the SoftDevice to use the internal RC oscillator instead.

    Snippet:

    static void ble_stack_init(void)
    {
        ret_code_t err_code;
    
      
    	
    	    nrf_clock_lf_cfg_t clock_lf_cfg = { .source  = NRF_CLOCK_LF_SRC_RC,
                                            .rc_ctiv = 4,
                                            .rc_temp_ctiv = 1 };

    Also, note this from page 8 in the module user guide:

  • Thank you for your advice.

    But I failed.

    "COM3" is central, "COM4" is peripheral.

    Also, note this from page 8 in the module user guide:

    I have fixed it in "system_nrf51.c" in the first setup when I bought it.

  • I was able to run the central "ble_app_uart.c" which is not "ble_app_multilink" and the peripheral programs.

    I was able to confirm the reception of advertisement packets from peripheral.

    However, I haven't been able to establish the connection between central and peripheral and check RSSI.

  • I can't change the board.

    You don't need to change the board for your final project.

    What I'm saying is that before you start on that board, you should spend some time on the Nordic Dev Kits getting used to the product, the SDK and the tools.

    After you've done that, you will then be in a position to move on to the 3rd-party board.

    It's always best to take small steps at a time - don't try to do too much all at once.

  • What you say is true.

    I think I have been challenging myself step by step in that.

    I learned about the communication theory of BLE.

    I used the board as "peripheral" and sent data to it using nRFToolbox.

    Central read advertisement packets from peripheral and other BLE devices.

    The "ble_app_uart.c" of both central and peripheral were connected.

    As the next step, I want to send packets from peripheral to central and get the rssi at that time.

    I'm going to use "ble_app_hrs" and "ble_app_multilink_central" or "ble_app_uart" for the connection state, since 1:1 is fine for now.

    The problem is that I don't seem to be able to establish the connection state between "central" and "peripheral".

    The combination of "app_multilink" and "app_hrs" does not show any response, and the combination of "app_uart" and "app_hrs" continues to read advertisement packets and does not move to the connection state.

    The "app_uart_c" of peripheral  and "app_uart_c" of central only show the sign of connecting, and there seems to be no packet exchange beyond that.

    Do I need to write a function in my "peripheral" side to send an empty packet when it receives a poll, for example?

Related