Go Down

Topic: Detect if a device is present on the network via MAC address (Read 3958 times) previous topic - next topic


I've built a lighting controller, based on a Lightwave RF web module, an arduino uno and an ethernet shield. There are a number of sensors on the arduino, the data from which is logged via the ethernet shield on a mysql database running on a server. Depending on data from the sensors (i.e. light) the arduino sends UDP strings to the Lightwave RF module in order to turn lights on or off.

What I want to do now, is detect if my, or my girlfriends phone is on the network (by it auto-connecting to the wifi at home) and then turning on lights accordingly.

How could I achieve this? Setting static IP's on the phone is an option if that would be easier than detecting by MAC.

Any help would be greatly received!

Thanks in advance!  :smiley-mr-green:


To check on MAC address you might need to implement ARP but that is not for the faint of heart ;)

ICMP is the answer when you want to use ip addresses.
check - http://labby.co.uk/2012/08/arduino-visual-icmp-ping-server-monitor-icmp-echo-request/ -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


I (owner of http://labby.co.uk) have been helping him over on reddit at http://www.reddit.com/r/arduino/comments/180neq/detect_if_a_device_is_present_on_the_network_via/

If (when!) it works I will post the source here to help others.


By use Router which support Static DHCP, then it always get same ip address as long as mac address impact. ( You could change mac address of  a lot device if not all of them)
Static DHCP (aka DHCP reservation) is a useful feature which makes the DHCP server on your router always assign the same IP address to a specific computer on your LAN. To be more specific, the DHCP server assigns this static IP to a unique MAC address assigned to each NIC on your LAN.

An other way, Could use Bluetooth V 4.0. It is new and cool.


I wanted to do somthing similar so I added routines to the ethernet library to support this.  First in EthernetClient.h add these two lines down in the area where they fit (you'll see it):
Code: [Select]

void getRemoteIP_address(uint8_t * addr);           //added
void getRemoteMAC_address(uint8_t * addr);          //added

Then these two routines go in EthernetClient.cpp

Code: [Select]

/* Added these two routines to be able to get incoming ip addr & mac */
void EthernetClient::getRemoteIP_address(uint8_t * addr){ // added
   W5100.readSnDIPR(_sock, addr);   

void EthernetClient::getRemoteMAC_address(uint8_t * addr){ //added
   W5100.readSnDHAR(_sock, addr);
/* end of added code */

I'm not sure why these routines aren't part of the library already, they keep leaving them out with each release.  Now, you can get the IP address or mac for a device connected to the arduino.  The problem still remains of how you're going to connect to the phone from the arduino.

Oh, the mac address won't be any good for a machine connected from outside your home network; you'll always get the mac address for your router instead.  The IP address will be ok.


I have also been trying to attempt this. I'm new at Arduino as of yesterday but I've built a relay switch that seems to work ok.

What I would like to do is program the arduino to trip two relays which will open the garage door (the door mysteriously opens itself if it has power) so one relay would provide power and the other would switch.

So the idea is that when my wife comes home and her phone connects to the network the arduino will trip these two relays.

I have searched and searched and even tried to reprogram a solution but starting from scratch is hard when I am new to the scene. While searching the Google I keep getting this site:


which from what I understand it seems that it would have provided the perfect solution howeverthe page has been removed.

I would be eternally grateful for a solution or to be pointed in the right direction.


@allthenamesweretaken: try https://labby.co.uk/arduino-visual-icmp-ping-multiple-server-monitor-icmp-echo-request/

Go Up