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

nRF52832 notify every 20ms at 50 meters

Hi,

My setup :

  • nRF52832
  • Soft Device S132 v5
  • SDK14.2

My use case involve me to send data to to a central device at 50 meters. I need to send only a small data : one int16_t. I have a timer set up to do a SAADC conversion then send data (sd_ble_gatts_hvx) every 20ms.

It's working great on close range. But as soon as I am further than 5 meters I got a NRF_ERROR_RESOURCES.

Since it's not really a problem if I miss few data, my first try was to ignore it :

/* It's not a problem if we loose few data */
if(retval == NRF_ERROR_RESOURCES){
  retval = NRF_SUCCESS;
}

return retval;

It work great meaning that it does crash the board now and it keep sending data but at a very low speed and multiple packet at a time it looks like on the nRF Connect app log.

So I know that this error means that the queue is full. But why is it related to the distance from the central since it's a notification so we do not expect an acknowledgment or anything!?

Also when I go to ~25 meters (outside) not only I have very slow notification update on my central, but I got disconnect (Timeout).

What are the optimizations I can do to increase my range and keep my transmission speed constant?

Thanks

Parents
  • So I know that this error means that the queue is full. But why is it related to the distance from the central since it's a notification so we do not expect an acknowledgment or anything!?
    As points out you probably have a HW problem. Notification packets don't require acknowledgments from the application layer, but all BLE packets are actually acknowledged on the Link Layer. If your notification packet doesn't successfully reach the peer, it is retransmitted over and over again until the packet is either received successfully or until the supervision timeout times out and your device disconnects. This is probably why your queue fills up and why your link eventually breaks when you move out of range. 

  • The designer of the board tells me that there is no HW problem, he is used to work with nRF52 and he advised me to do an antenna tuning to take into account the materials and package surrounding my custom board. How am I suppose to do that?

    Also, he tells me that we can optimize the software to the detriment of the battery autonomy to increase the range. Do you know what is he referring to ?

    Thanks for your help

  • If you have changed or added packaging the designer is absolutely right. A device should always be tuned after it is placed in its intended enclosure. Nordic offers free tuning and if you want I can give you an address you can ship it to and we will do the tuning in our lab. 

    He could be referring to the TX power. The default TX power (at least in our examples) is 0 dBm and you can try to increase this to 4 dBm. That should increase your range, but the radio will also consume ~40% more power: Radio current consumption (Transmitter)

  • Ok, should I use the sd_ble_gap_tx_power_set like in the ble_app_proximity example ? I will give it a try

  • Yes, that is correct. Just remember to use it after you have initialized the Softdevice. Otherwise your setting will be overwritten and set back to 0 dBm. 

  • Still got  <error> app: ERROR 19 [Unknown error code] for sd_ble_gatts_hvx function as soon as I am > 5 meters.

    sd_ble_gap_tx_power_set doesn't change my results.

    Tw power -> RSSI :

    • -40 : -90dBm
    • -20 : -80dBm
    • -16 : -75dBm
    • -12 : -67dBm
    • -8 : -64dBm
    • -4 : -60dBm
    • 0 : -55dBm
    • 3 : -55dBm
    • 4 : -51dBm
  • I was able to reach little less then 20 meters just by changing the connection interval max from none to 20ms so I guess this is more important than I thought.

    I have a question about it. I use a timer, every 20ms it send data with a call to sd_ble_gatts_hvx.

    How should the connection interval configured for that ? Does the connection interval (time between when it accepts connection?) needs to be synchronized with the timer to avoid trying to send when the connection interval is not "ready".

    For now I have min and max connection interval set to 20ms (no for fewer since I want to send 1 data every 20ms right ?).

    Thanks for the clarification

Reply
  • I was able to reach little less then 20 meters just by changing the connection interval max from none to 20ms so I guess this is more important than I thought.

    I have a question about it. I use a timer, every 20ms it send data with a call to sd_ble_gatts_hvx.

    How should the connection interval configured for that ? Does the connection interval (time between when it accepts connection?) needs to be synchronized with the timer to avoid trying to send when the connection interval is not "ready".

    For now I have min and max connection interval set to 20ms (no for fewer since I want to send 1 data every 20ms right ?).

    Thanks for the clarification

Children
  • sd_ble_gap_tx_power_set doesn't change my results.
    Unless you do your measurements in an RF test chamber, then measurements like these aren't going to be very accurate. But in your list one can obviously see that the RSSI changes when you change the TX power, so at least you know that you are setting the TX power in the correct way. 

    The connection interval defines how often the peripheral and central turn on their radio to talk to each other. So in your case, every 20 ms there is what we call a connection event. This event is by default 2.5 ms long (but this can be increased). This 2.5 ms period is called the connection event length, and the two devices can exchange as many packets as they want within this period. Hence, you can potentially send many short notifications (or one long one) in each connection event. So in other words, you don't need to synchronize your timer and the connection interval. The Softdevice will handle buffering of your notifications.

     

     

Related