FIND (personalized indoor localization)

wifi
find
Tags: #<Tag:0x00007f6cefb4c018> #<Tag:0x00007f6ce5f8bea8>

(Markus Storm) #1

FIND

THE FRAMEWORK FOR INTERNAL NAVIGATION AND DISCOVERY

Find is an inhouse locator software to run on your Android mobile or other portable Linux device. A mobile to run FIND will detect WiFi access points in range and their signal strength that correlates with the distance to the access point. The set of signals can be compiled into a fingerprint which can be used to uniquely classify the current location of that device relative to the (immobile) set of WiFi APs in range.

You can extend the learnt data set at any time. It’s not limited to a building or area.
You can use your mobile to learn your workplace, school, supermarket, summer cottage or other favorite place you’re regularly staying at.
The only major requirement is to have stationary senders, so it might not work well in public places with many mobile users or cars if those provide a mobile (tethering) hot spot.
To get FIND to work with openHAB, you need at least a client and a FIND server.

Clients
The official FIND app client is available for Android only (sorry to iPhone users, but there’s an Apple policy restriction). Search Play Store for “find hypercube”.
Unfortunately this app is reported to have problems, namely that it does not update location when running in the background. Plus, the author himself is speaking of a number of Android permission problems that he is unable to and therefore will not fix these.
There’s a 3rd party enhancement said to have fixed this, to be found here. I have not used it yet so cannot confirm it’s working. Please let me know when you’ve tried it.

Another app to try is Room+. The original app’s author recommended this. It’s available on Play Store but Google does not let you download it from many (all?) countries.
You do can find alternative download places for it such as here. Note that in order to install the .apk, you need to allow for ‘installation from unknown sources’ in your Android settings.
Same as with the enhanced app: I have not yet used Room+ yet so cannot confirm it’s working. Please let me know when you’ve tried it.

Alternatively, you can still run the Linux findclient binary on any fully accessible ARM hardware such as a Pi Zero. There’s a number of devices suggested on the FIND website.

Server
If you’re running openHABian, there’s a menu option to install the FIND server. If you don’t, you can retrieve FIND server from Github and have a look at the install instructions at https://www.internalpositioning.com/server/. For a Raspberry Pi, select the ARM binaries.
If your Pi has WiFi and you want to use it as a client for learning, too, then also retrieve and install the fingerprint client from the FIND website.

Configuration
Once installed, fire up the app, select a username and eventually a group name (you can choose anything you want as long as there’s no one else using this on the FIND server). You can have multiple mobiles contribute to a common database on the FIND server, just use individual user names but the same group.

Learning mode
Click “Learn” and you’ll be prompted for a location (room) name. Once entered, the app will connect to the server and start submitting fingerprints. ‘Learn’ a room for 2-3 minutes, click ‘stop’, move on to the next room and repeat the procedure until you’ve fully learnt your house.
You can access the server dashboard at http://openhabianpi:8003/, enter your group name there. Use this to delete specific rooms if you feel there’s a need because say recognition rate is bad. This can happen if a sender (WiFi access point) is being moved (note ‘senders’ are mostly the APs of your neighbors, too, so you don’t get informed when they change).

Pi as a learning client
You can also use any Linux machine as a learning client to ‘train’ the FIND server by running the fingerprint client. It usually does not make much sense to use your PC or smart home server that’s connected to mains power because you actually cannot move it, meaning you can just learn a single ‘location’ (the room it is installed in). To use a phone is easier.
Still you might want to use a Pi running off a smartphone power bank for this.
If you encounter problems such as
14:27:35.615 scanWifi - INFO 008 Gathering fingerprint with '/sbin/iw dev wlan0 scan -u'
14:27:35.625 main - WARN 009 Scan failed, will continue after a rest
then try sudo ./fingerprint -iwlist.


openHAB integration

You need to use the MQTT Binding to get the data from findserver into openHAB.

MQTT binding
An example services/mqtt.cfg file using the FIND website’s MQTT server would be to

broker.url=tcp://ml.internalpositioning.com:1883
broker.clientId=OpenHAB
broker.user=YOURGROUP
broker.pwd=YOURPASSWORD

Running your own FIND server
Just to remind you: FIND server and mosquitto are available as optional components in openHABian.
If you don’t use openHABian (why not ?), you can still run your own find server like this:

pi@tvpi:~/find $ ./find-2.1-linux-arm -mosquitto mosquittoPID -mqtt mymqttserver:1883/ -mqttadmin finduser -mqttadminpass findpasswd tvpi:8003

then it’ll connect to a MQTT server on mymqttserver port 1883 with a ‘mosquittoPID’ being the process ID of the mosquitto server process, using credentials ‘finduser’ and password ‘findpasswd’.
For usage in scripts, replace mosquittoPID above with `pgrep -x mosquitto`.

CAVEAT1: you need to start the findserver in the working directory where you have extracted the install zip package (or you need to move the data, too, to from where you want to start it)
CAVEAT2: this working directory needs to be writable to the user you start it as and you also need another writable directory data inside.

If you’re using mosquitto (probably everybody does, no?), you can add authentication using curl -X PUT "http://<yourfindserverip>/mqtt?group=YOURGROUP and then FIND will automatically manage the passwd file and restart mosquitto using a SIGHUP signal. You can also use mosquitto_passwd <passwordfile> finduser to add credentials. mosquitto_passwd might not be included in your Raspian mosquitto distribution, you eventually need to g**gle where to find it.
Find publishes to mqtt channel ‘YOURGROUP/location/YOURUSER’.
You can watch mqtt events like this: mosquitto_sub -v -h mymqttserver -p 1883 -t 'YOURGROUP/location/#'

openHAB items

You need to add the username of the person to track to get the information in.
The JSONPATH definition will pull in the current location.

location.items file

String	mqttfind_johndoe			"John Doe is @ [%s]"	(All)	{mqtt="<[BROKER:YOURGROUP/location/USERNAME:state:JSONPATH($.location)]"}

Make sure you replace BROKER by how you named your MQTT server in services/mqtt.cfg, and to use YOURGROUP and USERNAME as you did in the FIND app when learning.
Ensure JSON transformations are enabled (install addon by adding it to the transformation line in services/addons.cfg or via transformations category in PaperUI)

Links to docs

Main Page : FIND

Github : FIND

MQTT Documentation : FIND


Bluetooth Beacon Indoor Navigation & openHAB Connection
openHABian v1.4 released!
Defining and architecting Presence
(Ben Jones) #2

How do you find the battery drain on your phone if you run the app in the backgroud/fulltime?


(Markus Storm) #3

Haven’t done any measurements but haven’t particularly noticed additional drain either. Note FIND does not need to actively ping anything (like e.g. GPS) but works passively. I suggest you run it without the server first and see for yourself.


(Lukas) #4

Are there any other portible devices able to youse find? I have looked a while ago and only found srh like the photon. Instead of my phone (which i leave lying around all the time) i would like yousing some watch or similiar, or even sth the size of a bt beacon?


(Markus Storm) #5

Well the findclient and fingerprint binaries run on every WiFi-enabled Linux ARM device, so you should be able to get a Pi0, nanoPi or similar. There’s a couple of pointers over at the FIND website.


(Rahul Pandey) #6

Hi, I want to use Pi as a leaning client. But it is not sending any finger print on server. I have created a cluster of 2 Pi devices
Can you please help me.


(Markus Storm) #7

What sort of answer do you expect to a question with a lazily short explanation like this? Download and use the fingerprint client as described in the tutorial.


(scott dee) #10

looks good.


(mcqwerty) #11

Hi @mstormi,
I’m looking for some advice if I may -

I have a local find server up and running and everythign works great. I have experimented with different Android apps but none have fit my needs.

  • I tried the standard FIND app but as is well documented it does not update in the background.
  • I tried this app (also called FIND) on github, compiled and installed it but I also has issues updating in the background despite what is stated in this discussion. I made a comment on that discussion asking for clarification but have not yet had a reply.
  • I tried Room+ as also suggested in the github discussion linked above. I was unable to install it from google Play as the site displays ‘Sorry! This content is not available in your country yet.’ - I am in the USA. So I sideloaded the APK found on another site (I checked that it was the latest version). I see that this app requires the ‘Pro’ licence in order to enable background tracking - If I click the ‘Buy Pro’ link in the app I get: ‘Error - The item you requested is not available for purchase’. I emailed the author of the app but I have not had a reply.
  • I tried Zanzito and it works pretty well, even in the background and with the screen off. However it only updates every 30s and there is no way to configure this. I would like to have it update more frequently, and ideally have this interval controlled based on if the phone detects motion. I emailed the author of the app but I have not had a reply.

I have a moto x4 phone running Oreo.

The ideal app for me would:

  1. Report my fingerprint to my FIND server even when the app is in the background and the phone screen is off.
  2. Allow me to configure the interval that the app reports to the FIND server
  3. Add additional configuration that uses the phone’s other sensors to detect movement and report more frequently. So a report interval when not in motion setting and a report interval when in motion setting would be ideal.

I realise such an app likely does not exist but I would appreciate your insight and suggestions in getting closer to this ideal.

Thanks


(Markus Storm) #12

I’m afraid I can’t comment on any alternatives because I’ve only ever been using the original FIND app.

Please keep sharing your FINDings (hah!), I’ll be happy to add them to the tutorial.


(scott dee) #13

Yeah I’m finding this app to be pretty useless. If it’s not going to update in the background it doesn’t serve a purpose other than another app. Going to be trying out some from the post above.


(Simon) #14

Hey @mstormi ,

maybe you can help me.

I don’t get my find server wired up with mqtt…

I am using openhabian and installed mosquitto and find server via openhabian-config.

mosquitto is running and working. I already control my sonoffs with it. FIND server is also running and via website i can see all the information.
But somehow i cant combine FIND and mqtt…

my item:
String mqttfindSimon "Simon is @ [%s]" (All) {mqtt="<[simonbroker:sasi/location/simon:state:JSONPATH($.location)]"}

mqtt.cfg
simonbroker.url=tcp://localhost:1883
simonbroker.user=openhabian
simonbroker.pwd=xyz

findserver is stating:
MQTT is setup!
Your password is: zCeAcu
You can listen on topic 'sasi/location/USER'

Can you help me? what am i missing? :confused:


(Markus Storm) #15

Do a tail -F on /var/log/mosquitto/mosquitto.log, then sudo systemctl restart findserver.service
journalctl -u findserver.service should tell you findserver output, check what it is saying.
If that doesn’t show anything useful, check what’s the parameters findserver runs with (use ps -ef), stop it (sudo systemctl stop findserver.service), cd to /var/lib/findserver and manually start it there. See what it tells you. Maybe it stops, maybe it tells you Not authorized (meaning mosquitto does not know the user findserver is trying to connect as).

Finally, connect to mosquitto using mosquitto_sub, track for topic ‘#’ and start the FIND app.


(Udo) #16

I following this thread a awhile.
For my application it would be very helpful to know if persons arriving, are in the room or leaving.

But so far I’m discouraged by the thing that the android client dosen’t update while in the backround.
To me it seems to restrict these nice idea verry much.

So I’m interested in any ideas.


(Markus Storm) #17

I’ve updated the client section of the tutorial. In particular, see the download link for Room+.

I would like to request any of you to help by testing Room+ and the enhanced version of the original app.
Please share your findings here.


(mcqwerty) #18

I did a mini-review further up this thread on all of the apps I could find that integrate with FIND.

I see that @mstormi recommended you try a couple of apps - see my post for the issues I encountered with them, (and others), and please let us know if you are able to make any progress.

I think that Zanzito is our best bet but the author of the app seems to have either abandoned it or is busy with other projects. Maybe if a few of us contact him with similar requests it may convince him to pick it back up.


(Udo) #19

I’ll give it a try - 30s update is quite acceptable.


(Graham Knights) #20

I love this integration, but as someone else mentioned, it’s ridiculous trying to search for relevant topics with ‘FIND’ as a keyword :smiley: I’ve been trying OpenHAB for a few weeks now, and after some steep learning curves, really like the potential this has for going into my new house in the near future. I’m finding lots of helpful guidance within the forums, but I’ve hit a speedbump recently - it seems that anytime I reboot my RPi (running openhabianPi 2.2.0 stable), the findserver.service looks like it starts up before mosquitto, since it doesn’t pull any events from MQTT, and gives me the following error via

journalctl -u findserver.service

Feb 03 07:37:44 openHABianPi findserver[336]: DEBUG: 2018/02/03 07:37:44 mqtt.go:48: Network Error : dial tcp [::1]:1883: getsockopt: connection refused

but connects fine if I restart the findserver.service (after everything else starts up).

I know how to create service dependencies in Windows, but still learning the nuances of linux. :slight_smile: Is there an easy solution to create this dependency? Any help is greatly appreciated - cheers!


(Graham Knights) #21

Update: I edited findserver.service with systemctl edit and added the mosquitto dependency as:

[Unit]
Description=FIND internal positioning server
Documentation=https://www.internalpositioning.com/server/
After=mosquitto.service

Consistently now gets updates from mqtt upon boot, without connection error. Is there an OpenhabianPi setup script that should have this added, or is my case abnormal? I suppose it would depend on how mqtt was previously installed?


(Markus Storm) #22

Thanks for raising. I’ve made an openHABian PR of it.