3

I would like to let the PI know that I am home so that it starts a set of scripts to turn on my projector (I could loop it, but that would be expensive).

Clearly, I have my phone with me all the time, so I could check whether my phone is close by.

What is the best way to do so?

One way I found is using arp-scan

#!/bin/bash

# Checks if the phone is connected to the wifi network
# Loops until the phone is found

MAC_ADDRESS="XX:XX:XX:XX:XX:XX"
arp-scan --interface=wlp2s0 --localnet | grep $MAC_ADDRESS

while [ $? != 0 ]; do
sleep 60 
arp-scan --interface=wlp2s0 --localnet | grep $MAC_ADDRESS
done

then if this script return, another one will take care of doing things with the PI.

One thing I am not too happy about, is that this thing will not be robust to e.g. lag in connecting to the wifi and disconnection. So maybe checking for my phone coordinates would be better, but I have no idea how to do implement it. I have an Android phone, if relevant.

  • It also wouldn't trigger when your phone battery died. – Helmar Jan 14 '17 at 11:42
  • Yeah, but I don't worry much about it, phone is on charge at work. If that where an issue then I would have to look for a completely different solution – Three Diag Jan 14 '17 at 12:03
  • 1
    I think this looks like a pretty good use case for IFTTT. You should be able to set up separate events for WiFi, Bluetooth and GPS on your phone (covering all of your location/range options), and use a little Python on the Pi to listen for the incoming event messages and trigger your projector. There are a couple of IFTTT/GPS/Pi projects around already, but I'm struggling to find one with any accompanying example code. – goobering Jan 14 '17 at 22:23
  • That sounds cool! I can see triggers for android location, but I don't know how to construct a "that" part for the raspi. There's not many available, which means that you'd require some hack through another server like gmail or dropbox or something similar – Three Diag Jan 14 '17 at 23:48
  • 1
    @ThreeDiag Is your Pi accessible over the net? You could implement a web hook from IFTTT for the 'that' part. – Tim Malone Jan 18 '17 at 19:56
1

I'm also considering doing something like that. My idea that crossed my mind was to connect a NFC tag reader to the Pi and when I scan a NFC badge, to perform the required actions.

I have found this article and this article, that is somehow close to what I want. Of course the first dude took it to the next level... I'm not going to make it so complex. RFID and NFC readers are rather inexpensive in eBay, so most likely I'll go for it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.