Go Down

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

velkrosmaak

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:

robtillaart

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.

sonnyyu

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.


draythomp

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.
Trying to keep my house under control http://www.desert-home.com/

Go Up