Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to run find-lf on a single RPi? #10

Open
boonhapus opened this issue Jan 13, 2017 · 14 comments
Open

Is it possible to run find-lf on a single RPi? #10

boonhapus opened this issue Jan 13, 2017 · 14 comments
Labels

Comments

@boonhapus
Copy link

schollz,

  • Presence Detector
  • Internal Positioning (seems 2-3s delay)

I am hoping to use find-lf for two purposes, in order of importance above. I am running HomeAssistant and as I'm sure you're already aware, reliable presence detection has always been a challenging problem to solve. To my understanding, FIND works by allowing an Android user to connect to the platform via an app. find-lf works much the same, but without the app. Please correct me if I am wrong!

If this is the case, find-lf seems more attractive, as it would work better with both Android and iPhone users.. however I know the intention is to emulate the LF sonar system which implies multiple polling devices. So, in saying all of this..

Is it possible to run find-lf on a single RPi?

@schollz
Copy link
Owner

schollz commented Jan 13, 2017

@SupahNoob

Yes, depending on your priorities. If your main priority is Presence Detection (which I assume you mean to monitor who is on the network), then you don't need FIND-LF at all, but you could simply use nmap to scan which devices are currently connected and report that to HomeAssistant.

You listed a second priority as Internal positioning - which is what FIND-LF is designed for and good at. Yes, you can run it on a single RPi, but with one caveat: you can only classify a few locations (maybe ~3) with any confidence in their gelocating resolution. I.e. you can classify one location as being "close" to the Pi,, one as being "kind of close" and one as being "far away". With 2+ RPis you can do more triangulation and classify more locations with precision. However, if learning ~3 location is good enough, I'd say one RPi will work well.

Don't hesitate to let me know if you need more explanation!

@schollz schollz changed the title Use on a single RPi Is it possible to run find-lf on a single RPi? Jan 13, 2017
@boonhapus
Copy link
Author

This is a great explanation. nmap is slow and not as reliable as I'd like it to be, especially with iPhones -- granted there are plenty of ways to defer automation rules from going off in various situations. Additionally, nmap is timed-based, whereas find-lf is event-based which makes it vastly superior.

The second priority is more of an "icing on the cake" feature for me, but still extremely useful and interesting. I don't know that it is responsive enough to be able to completely replace motion sensors, and certainly not with it relying on web I do live in a fairly small apartment, and has 4 total rooms in it so while 1 RPi would still work, it's also not the ideal situation either. Have you tested find-lf on the RPi Zero w/ adapter that can be put into monitor mode? This could work very well in my situation as it's not cost prohibitive in multiples and still a lightweight solution (ie. I can hide the suckers just about anywhere!).

@schollz
Copy link
Owner

schollz commented Jan 13, 2017

I didn't realize the reliability of nmap is not optimal. In that case I think find-lf would work well for you.

Yes, I've tested find-lf on a RPi Zero with adapter in monitor mode. It works well but has a drawback because it only has a single WiFi card. The drawback is that, in order to send the information to the server with a single WiFi card, a Pi has to stop tshark and then reset the WiFi adapter back to managed mode so it can connect to the network and upload the data. Then it switches the WiFi adapter to monitor mode and re-engages tshark. This means that there is an added ~5-10 s delay for sending fingerprints for the switching to take place. Currently scan.py automatically will determine if this is the case and perform single-wifi tracking.

@boonhapus
Copy link
Author

My understanding is that nmap only scans the IPs. If your router doesn't consistently tie the same device to the same IP, then tracking a user is not a sure thing. In order to make sure you're recording the correct device's presence on the network, you'd have to then ping the device for it's MAC address and add it to a registry of sorts and refresh this every time you scan the network. This could also be done with ARP requests, but I don't how how reliable this is comparatively.

How does RPi Zero differ from using find-lf on a RPi2 or 3 - I assume it doesn't? Are we assuming that the documented scenario were using a Pi cluster of 3s that also have a WiFi adapter?

Thanks for all the insight here! This is really useful information.

@schollz
Copy link
Owner

schollz commented Jan 13, 2017

The only difference between RPi Zero and RPi2/3 are the number of USB slots. On the Zero, you only have the one USBmicro (which you can adapt to USB for the WiFi monitor adapter). On the RPi2 you have more USB slots, so you can have the WiFi monitor adapter AND another cheap USB WiFi adapter so that you can be connected to the internet so scanning/uploading can occur at the same time. RPi3 is the best in these terms because its got built-in WiFi so you can use the built-in for being connected, and then you can connect the WiFi monitor adapter for the scanning.

@boonhapus
Copy link
Author

So, find-lf is doing both scanning and uploading simultaneously, whereas find does them individually, is that correct? If so, I think I will likely go forward with find-lf and build multiple RPi3 with adapters as this seems like a great solution for my needs.

@boonhapus
Copy link
Author

boonhapus commented Jan 22, 2017

@schollz Your documentation looks like it's to set up on a server of some sort, then issue commands to the pis via SSH. In which case, following the instructions would not work if I wanted to run something like cluster.py locally. I suppose I'll just look at your code and learn it, and modify it for my needs :)

I just looked through scan.py and it makes enough sense. However I'm unable to see my dashboard, for whatever reason. Eventually I'll want to either do comms based on who is home, or matching MAC addr to a username of sorts -- so I think I'll need to use your MQTT setup which I assume requires the dash to be active?

@schollz
Copy link
Owner

schollz commented Jan 23, 2017

If you can't see your dashboard it means that fingerprints haven't been learned yet. Make sure that you set your system to "learning". I.e. Goto https://lf.internalpositioning.com/, enter your group name, and enter a device and where the device is and click Learn.

@boonhapus
Copy link
Author

boonhapus commented Feb 2, 2017

@schollz Got my dash, got everything the way I like in python. Scans run and locally maintain a whitelist of macs I'm trying to keep track of... but now I'm stuck on the MQTT aspect. I keep getting ConnectionedRefusedError -- assuming due to user/pass restrictions.

import paho.mqtt.client as mqtt

self.client = mqtt.Client()
self.client.on_connect = self.on_connect
self.client.on_message = self.on_message
self.client.username_pw_set(username='not sure what this should be', password='<generated via find-lf dash>')
self.client.connect('ml.internalpositioning.com', 1883, 60)
self.client.loop_start()
...
self.client.loop_stop()

When setting up a mqtt client in python via paho ... what would my username be?

@pedrolucasoliva
Copy link

Have you tested with Raspberry Pi Zero W? (Embedded wifi and USB wifi)

@schollz
Copy link
Owner

schollz commented Aug 11, 2017

@pedrolucasoliva No I have not. That certainly should work though!

@schollz
Copy link
Owner

schollz commented Aug 11, 2017

@SupahNoob Your username is your groupname. You will also need a password. To get your MQTT password, you just need to make a request:

curl -X PUT "https://ml.internalpositioning.com/mqtt?group=YOURGROUP"

@mmsylvester
Copy link

Any update on using pi zero W? I'm planning to get an additional monitoring mode capable USB adapter and then use the built in wnet to communicate back to the server? Should this just work or changes are necessary? Thanks, this is a very interesting project!

@boonhapus
Copy link
Author

boonhapus commented Sep 16, 2017

@mmsylvester Pi0w should work fine in terms of computational power. What you're asking about should do pretty well! I don't use find-lf anymore but that seems completely do-able.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants