I have a microcontroller-based widget connected to my home network that monitors some sensors and controls the garage door. I'd like for it to work one way if I'm home and a different way if I'm not home. It could determine if I'm home by looking for my cell phone on the local network. Is there a simple way to do this? The prefered senario is to find the phone at any IP address (using MAC ID?), but I could have the router assign it a fixed IP. Also, it would be better if I didn't have to run an app on the phone, since that will require Android programming and battery drain.

Dani AI

Generated

A practical, reliable approach is to combine router-side data with short active scans and passive listening. For 's microcontroller widget, the router's connected/DHCP client list is the best single source of truth — as suggested — and a DHCP reservation for the phone's MAC gives a stable IP without hardcoding addresses on the phone.

Implementation notes:

  • Query the router for connected clients via SNMP, the router's HTTP/REST/SSH interface, or a vendor API and look for the phone's MAC or reserved IP. This is the least invasive and usually fastest method.
  • If router queries are not possible, do an active ARP probe or ICMP ping sweep of the subnet and check the ARP cache (arp -a) or use nmap -sn from a test machine. On a constrained device send ARP requests for the last-known IP and wait for layer‑2 replies.
  • If the network interface supports promiscuous mode, passively record the last-seen timestamp for the phone's MAC so presence can be detected immediately when the device transmits.

Caveats and tips:

  • Many APs have client-isolation; that prevents sniffing between clients. Phones may sleep and ignore pings. Privacy features like MAC-randomization make MAC-based checks unreliable. Combine methods (router poll + quick ARP sweep + passive last-seen) for best results and aim for a 30–90 second detection window. If absolute reliability is required, use a tiny low-energy background app or a BLE beacon as a presence token.
# every 15s (example)
if router_reports(mac) then state = HOME
else if arp_probe(ip_or_range) then state = HOME
else if passive_seen(mac within 90s) then state = HOME
else state = AWAY

Recommended Answers

All 3 Replies

First I understand what you asked. Next if you hard assign the phone IP address you break what could be a way out. That is, your app on the widget could query the router for a list of current DHCP clients and change depending on if the client is there or not. I won't go over issue of lag in that scenario.

If the lag is an issue then the widget tries to ping the phone which you have to test if that works.

So that's all on the widget to perform and we don't need to write or install an app in the phone.

Thanks for the reply . But I do not know how to "query the router for a list of current DHCP clients" in C++ code, and hence the reason for my post. And the lag may be an issue if it's more than a few minutes.

That query changes with router models. I can't be specific. Maybe just hard assign and ping when you feel the need.

PS. Added with edit. Part of what you asked was kicked around at https://robpickering.com/using-hazel-python-lingon-and-arp-to-determine-if-a-device-is-on-your-network/
Notice the slight ding about SNMP removal from some product.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.