BLE距离问题

nick.yao
Posts: 14
Joined: Mon May 13, 2019 11:23 am

BLE距离问题

Postby nick.yao » Thu Nov 28, 2019 7:34 am

目前用ESP32-WROOM-32做一个产品,ESP32做BLE的client去连接另一个设备(这个设备与手机通讯时的距离大于30米),发现2者之间的距离只有7~8米,不能满足需求,请问有什么办法可以增加这个距离呢?

ESP_Island
Posts: 36
Joined: Thu Jun 29, 2017 7:20 am

Re: BLE距离问题

Postby ESP_Island » Thu Nov 28, 2019 8:58 am

nick.yao wrote:
Thu Nov 28, 2019 7:34 am
目前用ESP32-WROOM-32做一个产品,ESP32做BLE的client去连接另一个设备(这个设备与手机通讯时的距离大于30米),发现2者之间的距离只有7~8米,不能满足需求,请问有什么办法可以增加这个距离呢?
Hi, Nick

你可以使用 esp_ble_tx_power_set 来调大发射功率, 使用参数 ESP_PWR_LVL_P7 可以调到最大的 +9dBm.

Thanks,
Island

nick.yao
Posts: 14
Joined: Mon May 13, 2019 11:23 am

Re: BLE距离问题

Postby nick.yao » Thu Nov 28, 2019 10:55 am

for(i=0; i<ESP_BLE_PWR_TYPE_DEFAULT; i++){
ret = esp_ble_tx_power_set(i,ESP_PWR_LVL_P7);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s set ble tx power failed: %s\n", __func__, esp_err_to_name(ret));
return;
}else{
ESP_LOGE(GATTC_TAG, "%s set ble tx power success\n", __func__);
}
}
程序中加入以上代码后,测试距离,没有什么变化啊!!

ESP_Island
Posts: 36
Joined: Thu Jun 29, 2017 7:20 am

Re: BLE距离问题

Postby ESP_Island » Fri Nov 29, 2019 3:02 am

nick.yao wrote:
Thu Nov 28, 2019 10:55 am
for(i=0; i<ESP_BLE_PWR_TYPE_DEFAULT; i++){
ret = esp_ble_tx_power_set(i,ESP_PWR_LVL_P7);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s set ble tx power failed: %s\n", __func__, esp_err_to_name(ret));
return;
}else{
ESP_LOGE(GATTC_TAG, "%s set ble tx power success\n", __func__);
}
}
程序中加入以上代码后,测试距离,没有什么变化啊!!
Hi,

对于连接的情况, 需要连接成功后去设置才会生效. 你是连接后才去设置吗?

设置后, 你看下手机端收到的 RSSI 是否变大了? 一些软件会显示收到的 BLE 包的 RSSI.

Thanks,
Island

nick.yao
Posts: 14
Joined: Mon May 13, 2019 11:23 am

Re: BLE距离问题

Postby nick.yao » Mon Dec 02, 2019 11:44 am

在gattc_profile_event_handler的ESP_GATTC_CONNECT_EVT中将代码改写成:
case ESP_GATTC_CONNECT_EVT:
ESP_LOGI(GATTC_TAG, "ESP_GATTC_CONNECT_EVT: conn_id=%d, gatt_if = %d", spp_conn_id, gattc_if);
ESP_LOGI(GATTC_TAG, "REMOTE BDA:");
esp_log_buffer_hex(GATTC_TAG, gl_profile_tab[PROFILE_APP_ID].remote_bda, sizeof(esp_bd_addr_t));
spp_gattc_if = gattc_if;
is_connect = true;
spp_conn_id = p_data->connect.conn_id;
memcpy(gl_profile_tab[PROFILE_APP_ID].remote_bda, p_data->connect.remote_bda, sizeof(esp_bd_addr_t));

for(i=0; i<ESP_BLE_PWR_TYPE_ADV; i++){
ret = esp_ble_tx_power_set(i,ESP_PWR_LVL_P7);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s set ble tx power failed: %s\n", __func__, esp_err_to_name(ret));
return;
}else{
ESP_LOGE(GATTC_TAG, "%s set ble tx power success-------------------------------------------------", __func__);
}
}

esp_ble_gattc_search_service(spp_gattc_if, spp_conn_id, &spp_service_uuid);
break;
经测试距离有所增加,从8米增加至10米,再远就不行了。

Who is online

Users browsing this forum: No registered users and 39 guests