Getting maximum range out of XIAO nrf52840 with bluefruit.h

Hi

I use the bluefruit.h - library to connect two sensors to one sensor (all Seeed XIAO nrf52840). I installed an external wire antenna on all of them which helped, but it’s still tight with the range.

These are the important parts of my code (with help from @msfujino)

Bluefruit.configCentralBandwidth(BANDWIDTH_MAX);
Bluefruit.begin(0, 2);  //begin(uint8_t prph_count, uint8_t central_count)
Bluefruit.setTxPower(8);    //-40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +2dBm, +3dBm, +4dBm, +5dBm, +6dBm, +7dBm and +8dBm.

I don’t seem to notice any difference setting the tx-power. Am I doing it wrong?

Thanks
Raphi

I use setTxPower on both central and peripheral devices. Is that correct?

Hi there, So what’s the range you are getting as is?
Yes you would use tx power on both ends, unless it’s a broadcast or beacon type scenario.
HTH
GL :slight_smile: PJ
look here, From argenox.

https://www.argenox.com/library/bluetooth-low-energy/maximizing-bluetooth-low-energy-ble-range/#:~:text=The%20transmit%20power%20of%20BLE%20radios%20available%20today%20usually%20range,a%20few%20devices%20exceed%20this.

The transmit power of BLE radios available today usually range between 0 dBm to around 20 dBm, with the majority having an upper bound of 4 dBm or 5 dBm, but a few devices exceed this. As an example, Nordic’s nRF52832 can output +4dBm, while the nRF52840 can output +8dBm.

The output power limit of a BLE chipset is mostly dictated by design and the capability of the chipset process as we’ll discuss in a minute. Note that increasing transmit power on a single device won’t automatically give you better range. Bluetooth is bidirectional, so the other device needs to be powerful as well to make sure packets are received at the longer range. A Good BLE Gateway with powerful sensors can have amazing coverage.

One downside of higher transmit output power is the that it comes at the cost of power consumption. The peak output current will increase significantly (remember that dB is an exponential, not linear measure). A full +20dBm device can reach peaks of 100mA or more. This isn’t practical in many BLE designs. Many of them run on coin cell batteries which have a nominal 400uA current rate and rely on capacitors to make up the difference for a short period of time. This is one of the design decisions every product developer has to make.
—end–

Try more power supply or add a PHAT Cap on the Power input. IMO

Thanks @PJ_Glasso

I currently get a range of around 8-10m :open_mouth:
There’s not much I can do, the antenna is already optimized (32mm long soldered to the right side of the SMD-antenna)

I would hope for someone with real-world experience with the Seeed XIAO 52840 to help out, what is wrong with my setup?

Lowest RSSI-value I get is around -40dbm … I think something is just utterly wrong with these modules @Citric

anyone, please… I need some input what to try

Power supply is not the issue for sure

Hello,
What are you using for a power supply and how is it connected? You don’t give allot of info on setup etc.
but LOL it can only be two things the Antenna or the Power supply. Have you tried it with unmodified test units to get a baseline? is the Code proprietary? and the design? is it in a container or breadboard? (any pictures)
You see where I’m going.
I looked at seeeds own signal PDF’s as a start be sure you get a good baseline with hardware that agrees. I also used older LIB’s in my testing and with my PCB with a Xiao nRF52840 BLE Sense chip.
How confident are you on the antenna mod ? matching Z wise etc.?
HTH
GL :slight_smile: PJ

I will post a reduced version of my script here.

Basically just use bluefruit.h and connect two unmodified XIAOs and look at the RSSI. It‘s horrible (-45dB centimeters apart)!!

LiPo with 4.2V and/or USB doesn‘t make any difference.

Away from home now only on the phone, sorry :slight_smile:

rssi.zip (4,4 KB)

Here’s the code I use to test the range. 6-8m maximum with line of sight.

not very much tbh.

I read here that I can simply solder to the right side of the PCB-antenna-Pins, which I did, and then shortened it until it got worse again - I ended up with about 32mm of bare wire length (I simply used thin enamel copper wire because there is NO space left in the case where it needs to be)

Hi there,
Wacky, I loaded up both sketches , they connect up AOK,
something is not right The RSSI changes way to fast in nrf_connect too btw?
when I sniff the BLE , also a Unit with only a battery attached reached further (-91) than the same code in the Expansion boards chip.(-81) I get about 12 feet farther but still seems like it doesn’t change enough when I set TXPower (4)
Are you using the adafruit bootloader?
GL :slight_smile: PJ

I want to setup two expansion boards with RSSI display and battery only, over the next couple days, interested to know what the ArduinoBLE LIB gets?
:v:

1 Like

Thank you so much for testing. I’m not sure I understand everything you wrote :smiley:
With nrf_connect, do you mean the desktop application?

About the expansion board, I am not using one, my application requires super small setups, in the end I use a 50mAh LiPo and a very tight 3d printed case around it. Right now, I am testing with bare modules.

How can I see which bootloader I currently use? Sorry, I think I don’t know enough about these topics…

Ok, I connected it in bootloader-mode and got this in INFO_UF2.txt:

Model: Seeed XIAO nRF52840
Board-ID: Seeed_XIAO_nRF52840_Sense
Date: Nov 30 2021
SoftDevice: S140 7.3.0

I found this page Releases · adafruit/Adafruit_nRF52_Bootloader · GitHub but as of now, I do not understand how to flash this bootloader. The ZIP-file does not contain a UF2-file

Ok, another edit to this post: I just flashed the bootloader using Arduino IDE. I think I see an improvement when using the Adafruit-bootloader, but I need to test this thoroughly. Is it even possible that this makes a difference?

To use it on my real application, I would need to remap the pins. I have a display, GPS, speaker, DCDC-switch etc. connected to the Xiao. Pin-mapping seems to be different with the Adafruit-firmware. Is there some matching-table so I can make this work?

Ok, afaics, the Adafruit-FW seems to better handle reconnects.

I shield the board/antenna until connection breaks:

  • Seeed-FW: reconnection 9/10 doesn’t happen until reboot of boards
  • Adafruit-FW: reconnection happens immediately without any problems

I use this

However, what is still missing is pin-map so I can transfer my code between the firmwares…

I got the Wire-library which I need to read a sensor working by matching the physical pin-numbers of the Xiao-board I use to the feather-board (whose firmware I use). Is this the correct way to go?

I tried to do it like this:

  • look for hardware-pin on seeed-schema
  • look for same pin on feather-schema
  • use pin-number of feather
  • example: A4 → P0.04 → 14/A0

image

circuitpython_Adafruit_Feather_nRF52840_Pinout.png

However, this does not work for certain pins, as I do not find them on the Adafruit-schematic.

For example, D9 / P1.14 does not exist on Adafruit.

I am really lost, any help appreciated

@PJ_Glasso

ok, after much back and forth (see the other thread about pin numbers) I was able to get my full script running. I do not see much, if any difference between the Adafruit and the Seeed-firmware. They disconnect at the same (much too close) distance, and they connect at the same distance again.

So I think it must be a hardware issue, and Seeed (@Citric) is not listening.

Disappointing!

I really apologize for any inconvenience caused. We will expedite our testing in the near future. Thank you for your feedback and understanding!

1 Like

Thank you @Seeed_Seraphina

Please get back in touch here in this thread.

Hello,

In what environment did you conduct the test? It is important to consider that indoor environments often contain various obstacles that can adversely affect the actual range of Bluetooth. I would recommend testing the device’s performance in an open outdoor setting.

In response to your feedback, we have conducted tests on the device. The testing was carried out in an open area on the rooftop of our company building. We flashed the example code from the Wiki onto the XIAO nRF52840 sense and evaluated the specific range of its Bluetooth connection by monitoring the connection status with a smartphone.

Based on our testing, the Bluetooth functionality of the XIAO nRF52840 sense in our hands was able to communicate at distances of up to 66 meters, as shown in the accompanying image.

Hi @Seeed_Seraphina and thanks so much for testing.

I of course did test in an outdoor-environment. In fact, my main use of it is outdoors in a perfectly open space.

However, there are several major differences in what you tested and what I noticed:

  1. you seem to connect a Xiao to a smartphone, I need to connect a Xiao with a Xiao
  2. you seem to be connecting a Xiao Sense, I use a Xiao (without Sense) nrf52840
  3. you use the ArduinoBLE-library, I use bluefruit.h (it’s even in the title of this thread)

Could you retest with my code (https://forum.seeedstudio.com/uploads/short-url/egpPEy4TjlhsrXK49dozhsZz3KL.zip), and flash one sketch to one Xiao, the other sketch to the other Xiao, and repost your results?

Thanks
Raphi

Hi raffiniert,
I measured the maximum range using two XIAOnRF52840s.
It was 25m in an outdoor location with good visibility.
After 25m, the RSSI becomes <-85dBm and the connection is lost.
For reference, the RSSI at the nearest 1cm is -16dBm.

1 Like