WOL Device

Hey guys. I am automating my room, and wanted to be able to turn on my PC from X10. I am considering using Wake-on-Lan, but I want it to happen from an Arduino. Can an Arduino be directly connected to an Ethernet port on a PC without a router in between and send packets to the PC if it has a static IP?

You would need to have an Ethernet Shield to be able to connect the Arduino to a network.

However, the WOL magic packet is usually sent through UDP, but this isn't supported by the current libraries. It can also be fairly difficult to get working depending on the target network card / OS etc.

An alternative is to control the power to the computer. Most of the modern bios chips have a feature which powers up the computer when the power supply is resumed. You could use a relay controlled by the arduino to actually turn on the power to the computer, and this would make it automatically boot.

what you need is the ethershield. you can then connect them up.

WOL however doesnt use IP addresses it uses MACs the network card in every device has a mac and you send magic packets to this mac (wikipedia for an explainaition)

Shouldnt be too hard if your programming is up to the job and using a crossover cable you can connect the 2 together without a switch/router.

I use a different method to get the same result.

I have a FreeBSD based NAS. and run a webs erver on it. i wrote a php code (3-4 lines) that sends the magic packet to the PC’s NIC’s MAC and boots it up, the NAS box serves all my files etc to my network. It runs on a nice bit of kit call freenas (freenas.org)

not sure if you need X10 exclusively tho

You can hook your ethernet shield equipped arduino directly to a PC (a crossover cable instead of a standard patch cable will probably be required).

Some sort of datagram (e.g. UDP or ICMP) for the ethernet shield is the missing link here, although someone has implemented DHCP, which uses UDP.


isn't there an unofficial one with udp?

There is an unofficial DHCP library and an unofficial UDP library (not sure if they are related) for the official hardware.

I haven't used them personally.


I would personally use a relay or transistor etc in parallel with your pc on switch (assuming it is a tower). Then the computer could be set to shut down/sleep etc on power button press and turned on by just writing an arduino pin high.


I was considering this, but I would not like to make any internal modifications. That's why I wanted to use WOL. If I use an ethernet shield with a patch cable and give my ethernet card a static IP, it should work, right?

I would say so in theory but I have not had much experience with ethernet.


I have actually gotten this working. It’s a little complicated. You have to download two files: UdpBytewise.cpp and UDPBytewise.h from here:
http://bitbucket.org/bjoern/arduino_osc/src/14667490521f/libraries/Ethernet. You then have to edit the UDPBytewise.h file to change the maximum packet size. There are two lines in the file which read:


You must change to 32 to a larger size to allow for the WOL packets.
I used 128. Note that this will increase the RAM memory requirements for your sketch.

Once you have these files, they have to be installed in the directory containing the Ethernet library for the Arduino. On the mac, this is in

Once you have all that, here is a sketch that will send a wake on lan packet. You need to specify the IP address of your internal LAN, and
the MAC address of the machine you want to wake up.

static uint8_t ip[] = { 192, 168, 1, 64 };   // IP address of this Arduino
static uint8_t bcast[4] = { 192,168,1,255 };   // broadcast IP address 
static uint8_t wake_mac[6] = { 0x00,0x17,0xf2,0x04,0x65,0x19 };  // mac address of WOL machine
static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };    // mac address of this Arduino

#define WOL_PORT 7

void setup()
  Ethernet.begin(mac, ip);

void send_magic_packet(uint8_t macaddr[]) {
    int i,j;
    UdpBytewise.beginPacket(bcast, WOL_PORT);
    for (i = 0; i < 6; ++i) UdpBytewise.write(0xFF);
    for (i = 0; i < 16; i++) {
       for (j = 0; j < 6; j++) {


// wait for some event like a button push or sensor 



If I use an ethernet shield with a patch cable and give my ethernet card a static IP, it should work, right?

Technically you don’t need an IP on either end, although the arduino shield still needs a valid MAC address, and the libraries may add other restrictions.

WoL is a layer 2 packet; it’s just usually easier to get it out on the wire from a traditional computer using UDP.


If I use an ethernet shield with a patch cable ...

If you are using the official Ethernet shield you can use a standard (non-crossover) cable as the shield is auto-sensing.