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

regarding the distance for the bluetooth range for scan and advertisement for nrf52840

Hi Nordic,

I am using the two nrf52840 units to test adv and scanning in a pair for the development. I am using BLE_GAP_PHY_CODED for both scan and advertisement. But when I test it, seems the package lost get very high when distance is longer than 70 meters. Any way to improve it? Also, is it possible to use the antenna signal amplifer for improve the receiving and advertisement distance?

  • Hi,

    • There is a mistake for  init.evt_handler = on_adv_evt; is stated twice. I have fixed this part 
    • for BLE_GAP_EVT_CONNECTED case in the ble_evt_handler() function:  1. I am using the "bsp_indication_set" to control the LED blinking to indicate the connection status. 2. sd_ble_gap_rssi_start is used to check the connection signal strength RSSI 3. nrf_ble_qwr_conn_handle_assign to do the connection handling  

    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        uint32_t err_code;
    	int8_t tx_power = 8; //niklas
    
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_CONNECTED:
                //NRF_LOG_INFO("Connected"); 
    	    status=1;
    	    status_connected=1;
                
                #ifdef UART_LOG_ENABLE1
                printf("Connect");nrf_delay_ms(1);
                #endif
                
                //interrupt_pin_init();//niklas
                err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
                APP_ERROR_CHECK(err_code);
                //reference https://jimmywongiot.com/2019/11/30/how-to-get-the-rssi-change-on-the-nrf5-sdk/
                //https://devzone.nordicsemi.com/f/nordic-q-a/69366/regarding-about-the-connection-rssi-for-signal-strength
                err_code = sd_ble_gap_rssi_start(p_ble_evt->evt.gap_evt.conn_handle,1,2);//niklas
                APP_ERROR_CHECK(err_code);
    
                m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
                err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
                APP_ERROR_CHECK(err_code);
    	    //err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, m_conn_handle, tx_power); //niklas
    	    //APP_ERROR_CHECK(err_code);
                ble_connect_fg = 1;
                break;
    
            //case BLE_GAP_EVT_RSSI_CHANGED:
            //     rssi_value=p_ble_evt->evt.gap_evt.params.rssi_changed.rssi;
            //     printf("RSSI=%d\n",p_ble_evt->evt.gap_evt.params.rssi_changed.rssi);
    
            case BLE_GAP_EVT_DISCONNECTED:
    	    status=2;
    	    status_connected=2;
                NRF_LOG_INFO("Disconnected");
    	    
                #ifdef UART_LOG_ENABLE
                printf("Disc");nrf_delay_ms(1);
                #endif
                //interrupt_pin_init();//niklas
    			
                // LED indication will be changed when advertising starts.
                m_conn_handle = BLE_CONN_HANDLE_INVALID;
    
    			if(nrf_gpio_pin_read(PIN_INTERRUPT))
    			{ 
    			 printf("In AA");nrf_delay_ms(1);
    			 //in_pin_handler();
    			}
                //advertising_start();
                ble_connect_fg = 0;
                break;
    
            case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
            {
                status=3;
                //NRF_LOG_DEBUG("PHY update request.");
                printf("PHY update request.");nrf_delay_ms(1);
                
                ble_gap_phys_t const phys =
                {
    
                #ifdef LONG_RANGE_ENABLE
                    .rx_phys = BLE_GAP_PHY_CODED,//BLE_GAP_PHY_AUTO,
                    .tx_phys = BLE_GAP_PHY_CODED,//BLE_GAP_PHY_AUTO,
                #endif
    
                #ifdef SHORT_RANGE_ENABLE
                    .rx_phys = BLE_GAP_PHY_1MBPS,//BLE_GAP_PHY_AUTO,
                    .tx_phys = BLE_GAP_PHY_1MBPS,//BLE_GAP_PHY_AUTO,
                #endif
    
                };
                err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys);
                APP_ERROR_CHECK(err_code);
            } break;
    
            case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
    		     status=5;
                // Pairing not supported
                err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GATTS_EVT_SYS_ATTR_MISSING:
    		    status=6;
                // No system attributes have been stored.
                err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GATTC_EVT_TIMEOUT:
                // Disconnect on GATT Client timeout event.
    			status=7;
                err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gattc_evt.conn_handle,
                                                 BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GATTS_EVT_TIMEOUT:
    		    status=8;
                // Disconnect on GATT Server timeout event.
                err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gatts_evt.conn_handle,
                                                 BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
                APP_ERROR_CHECK(err_code);
                break;
    
            default:
    		    status=9;
                // No implementation needed.
                break;
        }
    }
    

    The 32.768kHz crystal  I am using type is Epson Q13FC1350000200. The load capacitor, I am using the 12pf CC0402FRNPO9BN120 from Yageo for C4 and C5 in the picture below. 

  • Do you know the specific load capacitance of the crystal you're using? According to the Epson Q13FC1350000200 datasheet CL can be 7, 9 or 12.5pF, and it it's the latter, you might wanna consider larger capacitors (20pF), as we generally go by this formula where Ccap is the best capacitor value for a crystal: Ccap = CL * 2 - 4pF. Although it seems strange that this would affect the range of your application. Do you have an nRf52840 DK available to test on, to see if you get the same range out of a DK as the modules? 

    Do you see any disconnect reason when the devices disconnect at the maximum range (280 meters)? Are you seeing the expected timeout or some other error? Also, what RSSI values are you seeing at the higher ranges?

    Best regards,

    Simon

Related