I want to calculate distance Bluetooth Paired device from android mobile. I am new in Android Bluetooth Concept can any one suggest me it's possible or not possible in android sdk.if it's possible post any code or tutorial link!
The Bluetooth signal strength distance relation depends on the devices (built-in Bluetooth device, antenna, actual orientation of device), current way the persons hold their devices, objects in-between... You could measure this for a pair of devices for a given situation and use these information.
A larger and more general solution would incorporate an external Bluetooth network. Bluetooth triangulation is the basic concept, that will help. The link will give an insight on certainties that are achievable with such a setup. Take is as an upper limit, a device to device approach will be worse.
The EE Stack Exchange site has a more complete answer which includes a mention of Apple using 802.11v for determining if Apple Watch is close to a MacBook.
Bluetooth uses radio, and radio travels at the speed of light. A 1cm round trip will take less than 100ps. Timing something that short will be tricky, probably you'll want a 10GHz clock, though there are other options. But even then, Bluetooth isn't designed to instantly echo the radio message. If you receive, process and re-transmit the message, then the processing delay will be much longer than the time of flight, and will vary randomly by at least the period of the clock used with the Bluetooth chip.
You can't. Maybe, you can get approximate value from signal indicator but it's too much subject because of envirounment - is there something between connected devices, some reflection surfaces, etc.
There is a way you can research, is coding a response time. just calculate the bluethooth response time in nano secs, physically measure the distance between the devices and make a tree rule... is the same concept of GPS. This is a Laboratory work. I have a project that i have to develop it, in schedule i will taking it in a month.
OFC, its possible. It just requires ultra precise app, build to calculate "pings" between the two objects - kinda like ekko-location or laser distance measurement - its about how much time a specific signal travels back and forth.
Related
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 am developing an Android application that requires devices to be laid side by side and/or above and below each other.
I know I can use the Nearby API to detect devices "Nearby" however I need something a little more "Finer Grained".
My app needs to be able to identify a device laying either on the left side, above, right side or below. While all devices are laying flat on a table (for instance).
I can find nothing on the web that describes this use case.
Is it possible?
UPDATE
My use case is that I want Android devices to be able to detect any number of "Other Devices" laying either to their left or right. The devices will be laid out horizontally with a "small" gap between each one.
In the same way that you might layout children's lettered blocks to spell out a word or phrase, or numbered blocks to make a sum.
not only should the line of devices be able to detect their immediate neighbours to their left and right the two devices at either end should be able to detect they they are the start and end (reading left to right) of the line.
Using proximity sensors is a likely way to solve your question. TYPE_PROXIMITY will gives the distance from a near by object. TYPE_MAGNETIC_FIELD gives the geomagnetic field strength on x/y/z.
For more read Position Sensors.
Making your own Mock GPS (Local PS to be exact). I don't have a link for this but its definitely possible. Check out how GPS works to get an idea. Wifi and Bluetooth are signals. but you know what else is a signal?
A: SOUND
make each phone make a large beep in turn and measure audio strength using receivers. This might work better than wifi/bluetooth. once you measure relative distances between every pair of phones, it only takes a good algorithm to find relative positions
A Possible Alternative Solution : use image processing. Get something like OpenCV for Android and setup one phone as a master. This will work only for a 2D Layout.
Another "idea" - use the cameras. Stick A board on top of your surface with 4 QR codes in each corner. (This will help identify the edges and orientation of your phone). If you're looking for a 3D layout and the phones have sufficient in-between space, you could stick a QR behind every phone and show a QR on the screen of every phone.
All of these are solutions. Maybe you can use individual ones. Maybe you can use a combination. who knows.
An idea, in case it's relevant for your use case:
Setup phase
start your app on each device in "pairing mode".
Each device will show a QR code containing the key required for communicating with the device (for example via Firebase), and screen details: size in pixels. It will also draw a rectangle at the screen boundaries.
A different phone, external to this layout will run your app as a "master", taking a picture of the phones from above.
Now you need to write an algorithm to identify the screens and their locations, orientation and extract the QR codes for analysis. Not easy, but doable.
Interaction phase
now all the phones (this should work on more than two phones) can collaborate screens to show parts of the same movie, for example.
Seems not, if You have only 2 devices, but if You have external sources (with known position) of any signal (audio, vibrate, BT or WiFi radio, etc.), which can be detected by devices with adequate accuracy, and devices time is synchronized, You can do this comparing time of signal start (or signal strength) on both devices like on this picture:
Or, if You can add some sensors to one of devices, You can create "other device locator", for example like this sound locator.
UPDATE
In a updated formulation, the issue is also not solvable: it's possible to determine which two devices are at the edge, but you can not determine which one is on the left and which is on the right side. It is necessary that at least one device knows that it, for example, is leftmost - then other devices, for example, generates a sound, the others receive it and determine their order according to the difference in arrival time. But the anchor point and synchronization of time are necessary.
By understating your use case, it is possible to find number of devices surrounded by host device, using Nearby Api, other techniques. But find how many devices each side!!! I don't think it is possible with the current mobile hardware and technology. Because, by considering all factors, magnetic sensors are only the least possible solution. But the current mobiles have no such capability.
The following point I made based on above answers.
TYPE_ACCELEROMETER, TYPE_LINEAR_ACCELERATION, TYPE_MAGNETIC_FIELD, TYPE_ORIENTATION these sensors are react to the magnetic field around the device (compass react to the magnet). You can try an app using TYPE_MAGNETIC_FIELD, test how it will react to other device when close to it (I think it will react).
But the point I am trying to make here is, if you put three devices to once side and 4 devices to other side, the MAGNETIC_FIELD sensor reads relative magnetic field. So we can't identify how may devices each side, Until unless you have made some scientific calculations.
The second point is, some one suggested TYPE_PROXIMITY sensor, but it is not meant to serve this purpose. Current mobiles, measures the proximity of an object in cm relative to the view screen of a device. This sensor is typically used to determine whether a handset is being held up to a person's ear.
Another least possibility is using location sensor, it can identify the coordinates relative to your device coordinates, you communicate between each device coordinates with host using NFC. But the problem is, your use case says those devices are very close to each other, so it is not measurable distance using location service.
To conclude, it is not possible to identify number of each devices each side of a host device, with the current mobile hardware. It will can archived by using external sensor that will extends the mobile capability. For example, a phone case that equipped with such a capability, this will open window to other use-cases and application as well.
I think a way but it may require a a bit work. First check if 2 devices are laying by getting device orientation and using accelerometer or rotation vector to check pitch, roll, etc.
When you are sure that they are laying send data from one device from one to another using BT or wifi. Data should include send time. Check retreive time on other device also you should check for latency for sending and retreiving data. If you can have a noticible time differences in ms for small distance differences between devices it would be easy to check how approximately close they are. Also you may ask users to hold their device 1 meter or fixed distance from each other to get a time of travel for BT or wifi signal you send to other.
I am testing out a positioning system using iBeacon and Altbeacon. I have found that my triangulation results are actually pretty accurate, but sometimes it takes upwards of 5 seconds to see the proper results.
For example, say I am currently standing at Point A. Altbeacon + my triangulation has me properly placed very close to Point A. However, when I move 5 meters away to Point B, I remain around Point A for around 6 seconds and all of the sudden I snap into place right near Point B. Is this an issue with Altbeacon, or possibly the communication between my iBeacons and my Android tablet?
Note: I am using a Kindle Fire 10, running FireOS 5.1.1 on top of Android. The Bluetooth iBeacon technology is BLE, and broadcasts at around 1Hz.
The issue of time lag that you describe may be caused by averaging intervals on the signal measurement. You do not say what scanning framework you are using, or if you are using raw RSSI or a distance estimate as input to your algorithm. The Android Beacon Library by default uses a 20 second averaging interval (configurable) for its distance estimates. Other framework's use similar averaging.
Reducing the averaging interval will lessen the lag, but increase the noise as an input to your algorithm.
EDIT: To reduce the distance estimate sampling interval to 3 seconds from the default 20 seconds, call:
RunningAverageRssiFilter.setSampleExpirationMilliseconds(3000l);
I have tried previously what you were trying to do. There was a lot of issues making it impossible to get correct triangulation results.
Theoretically it should work, but
Practically you will have a lot of challenges, like the fact the Bluetooth Beacon uses the 2.4GHz frequency, almost all Bluetooth Beacon has non-directional antenna, which means that you might risk not measuring the signal source but the reflection of the signal surrounded by the beacon.
The other fact is the noise from other sources or Bluetooth Beacon in your environment.
Depending on the Android phone model, the receiver antenna of Bluetooth is not necessarily mount same place in the phone, that means how you hold the phone will change the RSSI reading
Holding the phone in hand or near human body might also give different readings or no reading at all, since the human body contains water that is a signal reducer/killer for Bluetooth signal.
So even thus you improve your latency time of Bluetooth Beacon by software, you will still have these challenge make it almost impossible to get the right results.
I have seen a new directional Bluetooth Beacon I have not testing it yet, but it sounds like it solving some the mentioned issues.
It is correct what #davidgyoung wrote, but that won’t change the fact of real world scenario.
Btw, I have worked with Altbeacon a very nice and respected tool, and I used both RSSI and distance estimate with different type of Bluetooth Beacon and different phones and it did not help much, it is not Altbeacon the problem.
And regarding the university project I mentioned in my comments, we ended up using Bluetooth Beacon in different way to help us finding directions to target for visually impaired people, and we have developed scientific paper on it.
Finally for inspiration of what you are doing and what I mentioned in my answer, see this video it shows triangulation experiment, the provider of this video is btw also a user at Stackoverflow.
Note: my answer here is focusing on the context of triangulation and the challenges here make it as not a sweet solution.
The project objective is something like this:
We would have a locomotive robot having on-board GPS on it.
Now using that GPS we want to track the position of robot and trace it on android cellphone.
(as they provide best interface with Google services)
Not only that
We even want to control the robot from android cellphone.
Is it possible to send control signal from android cellphone to that robot so that robot can make a move according to control signal.
How can we make a connection between android cellphone and on-board GPS of robot.
(We are somewhat newbie to robotics)
Any better ideas, suggestions are most welcome.
Check out Dension Wirc module:
WiRC module by Dension
It works for RC controlled platforms by sending a pulse width modulated train, allowing you to control servos and electronic speed controllers. There are 8 channels. I'm using it to control 2 tracks and a pan/tilt turret, it works great. I emailed the support team, and they sent me an iPhone project, which got me running in a matter of hours. The WiRC kit comes with a camera, so I can drive my robot remotely via wifi.
In terms of GPS, I did a test on iPhone, under clear sky, and the GPS signal drifts badly. The accuracy is indeed somewhere between 30-50 feet, it is not enough to track position of a small robot precisely. I will post a screenshot of my experiment.
Check out this screenshot: I'm walking along the white paths on the map with the phone in my shirt pocket. Every second it places a pin on the map. You can see how badly the red pins deviate from the white path. This is 30-50 feet off path. For a 2 feet long robot, this is a major trouble. If it tries to correct it's path with such resolution of GPS, it is likely to become very confused.
I've seen a differential drive equation on wikipedia (a motor with slit encoders), counting the number of slits that passed past encoder in a certain interval of time. This may help correct the GPS, but requires additional hardware
I am working on something same like this
I am trying to make an autonomous robot capable of moving itself based on some extensive robotics algorithms but certainly you don't need that.
But I think it will be better for you to mount the Android phone on the Robot and then control it with your laptop via WiFi or any other medium.
Mounting an android phone will have many advantages like:
Having a nice GPS and where there is no need to do extra work to integrate it with other hardware and software.
And you can have other hardware like accelerometer, proximity sensor, gravity sensor etc. which can be useful in many ways.
Now there is a lot of data for making Robots based on Android. Here is the Cellbots
they work on making robots from android and control them remotely from laptops or Android.
I am developing a project that is intended to use the GPS capabilities of an Android phone and a nearby station to compute positioning to a much more precise degree (cm), using RTK DGPS technology.
So far, I haven't been able to see anyone saying they actually managed to perform a similar task (apart from #GPSmaster, who doesn't explain how), and the APK doesn't seem to offer any information from the GPS chip other than location and NMEA message updates. I need, if possible, pseudo-ranges and carrier phases.
I was wondering if:
It would be possible to look for lower level hooks on my phone using native code, or other lower level snooping;
It would be possible to send RTCM corrections to the GPS chip present on one of these devices;
Any ideas?
Generally speaking DGPS is a technique that improves real position accuracy by canceling out most of the atmospheric effects on the GPS signal. In a typical direct GPS measurement there is about a random error in the ranges computed to the satellites due to atmospheric effects. This is why a GPS receiver that is left collecting data in a fixed location will seem to wander with in an error ellipse. For two receiver stations in the same area the atmospheric effects are almost identical and they will wander in parallel within their similarly sized and oriented error ellipses. If one of the two receivers is at a know location then the differences in their apparent GPS locations can be taken and plotted from the true location of the known station to find the true location of the unknown station.
Back in the day (circa 1992) when we had to accomplish DGPS by "post processing" we used to take the raw NEMA data collected at the two stations match up the times, compute the baseline vector and apply it to the known point to find the unknown point. I think the NEMA data we were using was only recorded to the nearest 10 sec. The math isn't really that hard.
I suspect that NEMA GPS messages [http://developer.android.com/reference/android/location/GpsStatus.NmeaListener.html ] from a tablet at a known point (with a clear sky view) could probably be sent over an internet socket to a smart phone (also with a clear sky view), which could then compute the difference and achieve a sub-meter relative location over a distance of few km, even if the assumed Internet transit times were ignored. This technique would probably still work even if the tablet and smart phone were both applying broadcast DGPS adjustments.
With the andvent of Android 7.1, the raw data from GPS chips will be available to developers. (http://gpsworld.com/google-to-provide-raw-gnss-measurements/)
Others seem to have done something similar to what you wish to accomplish (http://gpsworld.com/innovation-precise-positioning-using-raw-gps-measurements-from-android-smartphones/)
No, it is not practical to get any lower level access to the GPS device by an Android application. This has several reasons:
The application has no other means of accessing the GPS device as through the Java based API. Native code is forbidden to use most devices and usually needs a Java wrapper to tunnel through the sandbox for Android sensor devices. This makes up the main security concept.
If native code would have access to the GPS device on a lower level, it would have to cope with several different manufacturers protocols now not abstracted by the API. Best chances are to get access to custom NMEA codes, which may still have device dependent caveats.
Even if lower level access would be possible, one loses the integrated merging of other location sources like WLAN and cellphone carrier, that are presumably merged in native code below the Java API but above the NMEA protocol.
You can use DGPS corrections in Europe via custom application for SISnet receiving correction signals from EGNOS augmentation satellites(http://egnos-portal.gsa.europa.eu/news/egnos-gets-invite-your-smartphone-11). It does however need a subscription (which isn't really open to public yet) to SISnet to obtain username and password for connection to their servers. There's some of SDK published which you may find useful. Just remember that you are limited to C/A signals only (pseudoranges) and you CANNOT get phase data (L1/L2) from those cheap chips inside smartphones.You'd need a precision GNSS receiver such as Trimble BD910 (http://www.trimble.com/gnss-inertial/bd910.aspx?dtID=overview) to be able to access L1 carrier phase signal for GPS & GLONASS. There are however cheaper chips that support SBAS but none are yet installed natively in phones.
Umm. Your android probably has such a crap GPS antenna that achieving cm accuracy is impossible. Maybe if you average the position for days.. usually DGPS support is not published and not many chipsets support it. Last time I saw DGPS implemented it involved hacking the actual GPS chip firmware to add support. Even getting A-GPS to work on a random chipset is iffy since they might not support a documented way of feeding the assistance data.
It should be related with the hardware implementation , rather than the software implementation.
In the reality, GPS is usually accompanied with Wi-Fi or 3G to assist in searching the current position.
RTCM correction can be sent to your android phone using NTRIP 'provider'. Then you need to apply it to your raw GPS in your android.