Pages: [1]   Go Down
Author Topic: Detect if a device is present on the network via MAC address  (Read 823 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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/ -
Logged

Rob Tillaart

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

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Earth
Offline Offline
Edison Member
*
Karma: 52
Posts: 1761
My browser no longer is binding static IP, Floating is the way to go.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

New River, Arizona
Offline Offline
God Member
*****
Karma: 19
Posts: 928
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
void getRemoteIP_address(uint8_t * addr);           //added
void getRemoteMAC_address(uint8_t * addr);          //added

Then these two routines go in EthernetClient.cpp

Code:
/* 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.
Logged

Trying to keep my house under control http://www.desert-home.com/

Pages: [1]   Go Up
Jump to: