I'm detecting if a person enters or exits a room using iBeacon. The implementation is as follows:
1. Two beacons are placed per room. One in the door and the other is inside near the door.
2. To detect entry, the user must pass the door beacon then the one inside the room. For exit, it's the other way around.
Issue:
In case that there are rooms that are too adjacent with each other, an overlap will occur causing an error in the detection
Planned Solution:
Use RSSI to detect which one is the last nearest beacon when the inside room is detected. I'm thinking of checking the skewness of the distribution of the RSSI on a given time, say around 1 to 2 seconds since the user detected an inside beacon.
Is there other statistical analysis or any data analysis that can be used to determine or check with a probability which room the user entered?
Unless the rooms are very large (which it sounds like they are not based on the troubles you are having) I think any technique you find will have a high error rate. You might be able to get this error rate down far enough to be acceptable by recognizing cases where you simply cannot make a determination and refusing to do so in these cases to avoid false determinations.
Your best bet is to sample multiple RSSI measurements from different beacon packets (a minimum of 10 to filter out noise), then average them, perhaps throwing out the highest and lowest value before doing so. If this average RSSI is strong enough, say < -80 dB (and it is the strongest signal you have seen from all beacons) there is a high probability you are in the room indicated by the beacon.
The RSSI may drop off if you go far away from the beacon in the room so just because the criteria above are not met does not mean you are not in the room.
Keep in mind that it is impossible to determine which beacon is closest if all signals are weak -- noise becomes more important than signal. So make no conclusions unless one beacon has RSSI stronger than, say -85 dBm.
Make sure your beacons are transmitting as strongly as possible and advertising as often as possible. The latter will ensure that you get enough RSSI samples in a short time.
Finally, keep in mind that different Android phones have different Bluetooth antennas and receive the same beacon packets more or less strongly. A Huawei P9 Lite detects BLE signals at an RSSI 20 dB weaker than a similarly placed Moto G4+. Regardless of this, phones typically do not detect beacon signals weaker that -100 dBm and below -90 dBm the measurement is so weak as to become almost useless for relative distance determination.
Related
I'm trying to use RSSI values to create a positioning system in my home.
I'm using the neXenio library as a base, the only changes I have made from this have been implementing logging to a database:
https://github.com/neXenio/BLE-Indoor-Positioning
I'm using 4 Minew I7's for the beacons and they are currently set to broadcast just iBeacon type adverts at 300ms. They are positioned in a square shaped room and a cross type layout and each beacon is around 2.2m apart. There are no obvious obstructions other than normal living room furntiure. For each test run I do I place my phone in the centre of the room and gather data for around 10-15 minutes at a time. Data gets sent to a database for me to look at after.
The issue I'm having is the singal strength fluctuates massively all the time, to the point the data is basically unusable.
Graphs from a typical test run.
Should there be that much difference when the phone is completely still ? I'd expect there to be some slight differences from just the nature of signal propagation but not this much.
Is this to be expected or can these be improved upon somehow ? If this is expected then I will have to look at combining some other sensor data to help improve accuracy.
Thanks
Edit:
After running some more tests, I compared values over time (I had previously only compared rssi,distance and mac address). This has led to find a consitant osscilation pattern Newest test run.
This has also led me to this overstack question:
Is there an explanation for the regular oscillation experienced in Bluetooth RSSI
If I am only advertising iBeacon type adverts then this wouldn't apply? But it seems strange how it matches me issue.
RSSI values fluctuate a lot and there is not much you can do about that. That's why the new features in Bluetooth 5.1 were created that use other techniques than signal strength for positioning. Unfortunately the adoption has been slow.
You can't do much with currently used devices. Even if you stabilize the signal statically, there will be a lot of noise during movement. You can try to:
thicken the signal to 100 ms. Urfotunately, this will affect battery consumption,
BLE transmits packets on 3 channels (37, 38, 39). The antenna probalby isn't tuned to all 3 the same. If you have the option to change the advertising channels, try to test on different settings.
if you have option of soldering or connecting an external anntena, direcational antennas may be helpful for indoor positioning system.
There are many methods to stabilize the rssi signal. If you are interested in this topic, I recommend looking at the articles:
https://scholar.google.com/scholar?hl=pl&as_sdt=0%2C5&q=stabilization+rssi+method&btnG=
In my opinion, this mothod will be most useful to you:
https://www.wouterbulten.nl/blog/tech/kalman-filters-explained-removing-noise-from-rssi-signals/
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5461075/
AoA and AoD methods may also interest you:
https://www.bluetooth.com/blog/new-aoa-aod-bluetooth-capabilities/
I hope this will be useful
Its practice approach, I tried and implemented.I got the proper results, so that`s why writing the solution. If possible try the same.
I implemented it on one BLE router and one Beacon tag.
I need to do the calculation for up to 3 meter means 3*3.2 foot.
I minimized the fluctuation with out using the kalman filter.
For above implementation we need to go through the steps as follows,
Step 1. Keep Beacon tag at 1M of distance and take 10 [Max] number of readings of rssi & store it in one excel.
Step 2. Keep Beacon tag at 2M of distance and take 10 [Max] number of readings of rssi & store it in second excel.
Step 3. Keep Beacon tag at 3M of distance and take 10 [Max] number of readings of rssi & store it in third excel.
Now you have 3 excel.
Take one excel and observe the rssi value, compute the median for the same.
Same thing need to calculate for other two excels.
My Becon tag freq is 4 dbm.
I got the readings of RSSI from above excel as listed below:
From one excel: -58
From two excel: -64
From third excel: -70
As you see, there is difference of 6 as I change the meter.
Now I written logic by using above results like if value is fluctuating between -58 to -64 then it is represented as 1 m. same for 2m & 3m.
But this is not the proper way to do the calculation.
So I used the log for the
calculation like for the value between -58 to -64
result = log(rssi*-1,58). i.e 58 as base.
actual distance = result *1(meter)*3.2(ft)
Same for 2 meter, but for 2 m base of log is 64
result = log(rssi*-1,64). i.e 64 as base.
actual distance = result *2(meter)*3.2(ft)
Same for 3 meter, but for 3 m base of log is 70
result = log(rssi*-1,70). i.e 70 as base.
actual distance = result *3(meter)*3.2(ft)
This can be done by programming. I got the proper results with stability of rssi signal.
In my app,I use ble(Bluetooth Low Energy) to scan and connect to a nearest bluetooth device(There exists two similar bluetooth devices nearby).I use RSSI to make sure which is nearest and in most cases,it works fine.But I find it not 100% correct when the distances are short.During my test,one is 2 meters away from me and the other is 3 meters,and the RSSI of the farther one comes to be bigger,about 1 in 10 times.Is there any better idea to replace RSSI?
Your problem is very well known and it appears in any localization algorithm using ble beacons. Even if two devices are very close together, they may have different RSSI value due to the Fast fading effect.
The Fast fading originates due to effects of constructive and destructive interference patterns which is caused due to multipath.
To mitigate this problem, you can :
Compare the RSSI during a longer time. Especially if things are moving around, the radio-waves may interfere in a different way. If your receiver is a smartphone for example, the user is not static and a few more RSSI sample will give you a more accurate results.
Add spacial diversity. This can be done by adding another chip with another antenna that will also advertise. If the two antenna are not at the same place, you will have more RSSI data, coming from different path that will interfere in a different way. By doing the mean of the two value you should have better result (ideally combine with a longer acquisition time). But of course it is only possible if you are designing the hardware of the advertising device. Note that this can also allow your reciever to catch more adv for the same time-frame.
Frequency diversity. Make sure your advertiser is configured to use the 3 adv channels.
And of course if the two distances are very different the slow fading will be greater than any fast fading effect and you should not have any trouble.
I have followed the tutorial from RadiusNetwork to get the distance from a beacon using Android Beacon Library. I have read that it gives some fluctuations but I have three beacons in a room that is 7m x 7m one in each corner. With this, while sitting on a corner i have one in front of me (less that 0.2m) the other one at 10m (aprox, that's the diagonal of the room) and the other one at 7m. I tried to look for a solution here, but seems like everybody gets a better distance.
I did an app with that tutorial and when measuring the distance it tells me that the one that is 0,2 m away is 1.6m away, the one that is 10m says is at 70-90 m away and the other at 7m is at 40-60m.
I thought it was due to the power of the signal, which I tried to change but it wasn't the solution, since it was broadcasting the maximum power.
Anybody with the same problem that found a solution?
I made a measurements with the app with the Android Beacon Library. The phone was 1m away from the phone, and I got the following results:
I cannot specify the RSSI value at 1 meter, I can only pick one of the Transmission power (dBm and distance). The following is how the beacon's settings (in the owner app) looks like:
Beeks Toolkit App
I am using Beeks beacons from Bluvision.
According to the company:
"The txPower calibration for Eddystone broadcasts is done internally by our beacons and SDKs. When configuring Eddystone broadcasts, the picked calibration value will automatically match the advertisement's transmission power."
davidyoung is right. If you're using the Radbeacon dot, you can configure the advertised RSSI using the Radbeacon app (link is for the Android version).
With the app open, and the beacon on, hit scan. Once you see the beacon you want to calibrate, enable connections on the beacon (in the case of the Radbeacon dot, hold the button down for a couple seconds. The led will flash).
Tap on the beacon result in the app, and tap the menu icon in the top right. Select calibrate. Allow the calibrate function to run. If you are using Altbeacon or iBeacon frame types the phone should be 1 meter away. If you are using Eddystone the phone should be at 0 meters.
Note the RSSI value it returns, then tap back and enter that value in the Calibrated Power field. Save your changes, and you should be all set.
Make sure not to confuse the calibrate power value with the transmit power setting. Once you've set the calibrated power, if you change the transmit power you'll need to re-calibrate.
Also note that your distance values can vary quite a lot. Small rooms can complicate matters due to multi-pathing and other issues. You can experiment with various filtering methods, but the distances will rarely be spot-on.
I am trying to understand what exactly txPower is and how to use it, since I am planning to develop and Android app that uses Beacons.
I have seen 2 definitions online:
1.The transmitted power of the beacon.
2.The received power 1 meter away from the beacon.
How are these two definitions related?
Also, when transmitting a Beacon signal from a device using an app such as QuickBeacon, how do I determine what to set the power (txPower) to?
Most beacon formats contain a single byte in the transmission that indicates what the expected signal level should be when you are one meter away. This byte is sometimes called txPower (short for transmitted power) and sometimes measured power.
Do not confuse this with a second configuration setting on some beacon models that lets you vary how strongly the transmitter actually sends its broadcasts. This is typically called transmit power, which is why measured power is a less easily confused term.
The measured power field is used to make distance estimates. If the phone sees that its signal level is the same as the measured power field transmitted by the beacon, it knows it is exactly one meter away. If it has a stronger signal, it knows it is closer. If it has a weaker signal it knows it is further away. Using a formula, you can get a rough idea of the distance in meters.
Making this distance estimate accurate requires having the measured power field set properly to the expected signal level at one meter. It is often pre-configured into the beacon by the manufacturer, but it is typically adjustable. Why would you want to adjust it? If you place the beacon inside a cabinet, it might attenuate the signal. If you place the beacon against a metal wall, it might increase the signal due to reflections. For this reason, it is recommended that you calibrate a beacon by measuring and setting its measured power value after installation.
Calibration involves using a phone to measure the beacon signal level (using a measurement called the Received Signal Strength Indicator or RSSI, which is measured in dBm). To calibrate, you hold a phone with a typically performing bluetooth receiver (ideally an iPhone 6, but Nexus devices work well too) exactly one meter away from the beacon, and measure the average signal strength over 30 seconds. Many beacon configuration apps and tools like Locate for iOS and Android have calibration utilities.
Once you have the calibration value, you need to configure it inside your beacon per the manufacturer's instructions. This will give you more accurate distance estimates.
Check that issue maybe it helps:
Get Tx Power of BLE Beacon in Android also you could check out some devBytes from Google about BLE
https://www.youtube.com/watch?v=vUbFB1Qypg8
If you are using specific BLE beacons you need to referenced the datasheet and check how tx power is measured. As you already mentioned there is different definitions for it. During my dev I found that most suitable is that : txPower is measured in some distance from transmitter with way without obstacles. So if there is a wall for example txpower will be lower. Consider that.
txPower has defined the range of the Bluetooth signal to transmit the beacon.
I'm using my iPhone as an iBeacon device, and on the other side I have an Android 4.4.2 device scanning for the Bluetooth LE iBeacon signal from the iPhone. I searched for a good and easy way to calculate the distance between iBeacons and my Android phone, but I couldn't find anything that can help me with this.
Could you help me on this matter?
It's impossible to measure beacon distance accurately, I'm afraid, which is why Apple's own code just says "Immediate", "Near", "Far" and "Unknown". The best you can do is set up a reconstruction of the conditions you expect then do trial and error tests to map signal strength to probable distance. Trust me: I've spent a lot of time trying to do beacon distance measurement using a range of hardware.
Remember that the LE in Bluetooth LE means "Low Energy" – this stuff really is designed to use as little power as possible. That means the signal from iBeacons gets interrupted by people, walls and other objects. So, if I'm holding a beacon in my hand and put my phone next to it, I'll get a strong signal. If I move the beacon behind my back, the signal strength will collapse. If I just turn around, that has the same effect (for the same reason).
If you want to go down the "best you can do" approach, you effectively have to recreate at least partially the environment where your app will be used. So, if your app will be used in an office, find an office and place some beacons around there. Same for being in a shop.
Then get your app out and measure beacon strength at various distances to the beacon, potentially with obstacles in the way. With some averaging, you end up with something like "at 1 metre my signal strength was X, at 5 metres it was Y, at 10 metres it was Z", etc, and you then feed that into your distance calculation. It is, effectively, an educated guess.
If you find any library that claims to do beacon distancing for you, it just means they've taken their own educated guess based on their own signal strength testing.
One tip: if you're able to, stick your beacons to the ceiling. This minimises the chance of obstacles (read: people) getting between your beacon and your app.
We built a distance estimation formula into the Android Beacon Library of the form: d=A*(r/t)^B+C, where d is the distance in meters, r is the RSSI measured by the device and t is the reference RSSI at 1 meter. A, B, and C are constants. You can read more about it here. To use it with the library, you range for a beacon and then simply call:
beacon.getDistance();
This returns a distance estimate in meters. The library code is open source, so if you don't want to use the library you can copy the formula and use it directly.
As #TwoStraws notes, distance estimates are pretty rough guesses of how far a beacon is away, and the results you get vary with lots of factors:
The gain of the antenna on the receiving device. (Every Android device model is slightly different)
The noise on the A/D converter inside the phone that measures bluetooth signal strength.
The radio noise in the room.
Any obstructions between the transmitter and receiver.
Any surfaces (especially metal) that reflect radio signals.
Just be sure you set your expectations properly. Distance estimates are good for deciding if a beacon is close or far, or whether one beacon is closer than another. But they are less useful for measuring absolute distance.