Tutorial 42: Who is Home: Network IP Scanning
This is the first of three tutorials that works on turning your Raspberry Pi into a home greeter bot. The idea is: whenever you return home after work or school your Raspberry Pi sends you a text message welcoming you home. The first step in this project is trying to figure out when you're home without you having to purchase expensive sensing gear or manually interacting with something.
Smart phones are ubiquitous these days, as is Wifi. Everyone has a smart phone on their home wifi network. This can be taken advantage of by having your Pi scan your home's network to see if your cellphone's IP address shows up. In this tutorial I show you how to assign a static IP address to your phone, and how to scan your LAN to see if the phone is on the network.
import os from time import sleep phoneIP = "10.0.1.25" # Change this to match your phone's static IP while True: response = os.system("ping -c 1 " + phoneIP) if response == 0: print("Phone is online!") else: print("No phone detected") sleep(2)