What is the feasiblilty of a Wake On Lan device

Hello all, this is my first post on this forum as I am just starting out with Arduino. My question is how feasible is this:

An Arduino that would send a WoL package when the lights are turned on in a room. My plan to do this was by adding a photoresistor to the Arduino that would be used to measure amount of light at regular time intervals by analogWrite() 'ing the voltage of a constant current to the analog input. When the lights are on, I expect the voltage to increase. I would set a threshold that above, it would send the WoL packet and below it would just keep measuring the voltage every second or so.

Thanks,
RM

Very feasible, An UNO with ethernetshield and a LDR should be sufficient.

but you only told half the story. What should happen when the light drops in the room?

or consider robustness? Imagine a car passing by shining in the room with its head lights. Or moonlight?

That's great to hear. But you are right about it only being half the story. When the light drops in the room, I expect nothing to happen (I'll just turn the computer off myself). If I do more research and find a packet thats like "Sleep on Lan" then maybe I'll add that functionality in later. As for the headlight, I plan on making a 3 second delay (or however long seems correct) between the jump in voltage and the packet being sent. For moonlight, I expect to have the threshold above an amount that would trigger it (plus the room it's going in does not have too many windows to allow outside ambient light in.

This code will help you to read analog pin at specific values a relay will turn on/off
Just add your Ethernet shield code to send WOL command
By the way you can wake up your PC from serial port USB too :wink: without using Ethernet

int lightPin = A0;
void setup(){
  Serial.begin(9600);
}
void loop(){
  int lightReading = analogRead(lightPin); 
  Serial.println(lightReading);
if (lightReading <= 35) {
   digitalWrite (6,HIGH);
 }
 else if (lightReading >= 70) {
   digitalWrite (6,LOW);
 }
 delay(3000);
 }

narzan: ... By the way you can wake up your PC from serial port USB too ;) without using Ethernet

@Narzan: Do you have an example sketch? and how to config on PC side?

@Narzan: Do you have an example sketch? and how to config on PC side?

ok sketch & code will be here soon ;)

robtillaart: @Narzan: Do you have an example sketch? and how to config on PC side?

Though I have not tried it I assume you configure the Arduino (Leonardo?) as HID keyboard or mouse and simulate mouse move/button press or keyboard button press to bring PC out of standby. IIRC WOL will power on from shutdown so is the better option IMO and could maybe do several PC's at the same time.

Though I have not tried it I assume you configure the Arduino (Leonardo?) as HID keyboard or mouse and simulate mouse move/button press or keyboard button press to bring PC out of standby.
IIRC WOL will power on from shutdown so is the better option IMO and could maybe do several PC’s at the same time.

you can use that too to wake up a PC from sleep mode
If you want wake-up your PC from shutdown “of coarse that depend on your BIOS and motherboard if you have that option or not, most motherboard these days have it” to enable WOL command from wireless/Ethernet USB adapter Just let me back to my home :sweat_smile:

Also, if anyone has any suggestion on an ethernet shield, I'd be grateful to be let in on that knowledge. I've been getting mixed reviews about "off brand" Arduino shields.

PC side: The decision of whether or not to leave the USB port's power circuit enabled when the system is in ("Sleep" / "Suspend to RAM") is left up to the motherboard BIOS/firmware. It may even have a BIOS option you can configure for this purpose, to enable/disable the USB power when the system is asleep or even turned off.

USB controllers are usually connected to the CPU using something like PCI or PCI Express. PCI and PCI-E support Power Management Events, which are essentially what is used by an on-motherboard NIC to tell the system that it's being woken up due to a WOL. In theory, if the USB controller were receiving standby power from the PCI(-E) bus, it could then decode a wake on LAN magic packet from a USB device, and translate that into a PCI(-E) PME, which would trigger the wake.

BIOS First thing you must enable USB wake-up from BIOS and turn OFF eco/safe power management simply you can know if that work or not by connecting a mouse/keyboard to USB and look if your mouse work when your PC turned OFF

If there is no option for that just update your BIOS

Windows In Device Manager, go to the properties of your PCI-USB host controller, then go into the tab named Power Management. Here you have a Wake up option/Magic Packet , select that one

Now you can wake up a PC from both mode sleep/shutdown

Arduino side It's all about to send a Magic Packet over serial port but wait how Magic Packets work?! :o

The magic packet is a broadcast frame containing anywhere within its payload 6 bytes of all 255 (XX XX XX XX XX XX in hexadecimal), followed by sixteen repetitions of the target computer's 48-bit MAC address, for a total of 102 bytes.

The trick here is to make your Arduino have fake MAC & IPaddress to act like network adapter

ok everything clear, now for coding side

You need 2 PC on the same network first one will send WOL command the second for receiving the second PC will be ON too and running WOL packets sniffer

Now when the second PC receive Magic packet your sniffer will capture that code, and that's exactly the same command your Arduino will be use

run any command line from below inside CMD and don't forget to change it to your IP/MAC of the second PC WakeMeOnLan.exe /wakeup 192.168.1.25 WakeMeOnLan.exe /wakeup 40-65-81-A7-16-23 WakeMeOnLan.exe /wakeup Comp02 30000 192.168.0.255 WakeMeOnLan.exe /wakeup 192.168.1.25 20000 192.168.1.255

Run this program on the second PC download from here or use any sniffer you like

you will receive something like that on the second PC |500x385 copy the last section ROW DATA and use it inside your Arduino That's it :)

what about baud rate?! try all values and look witch one have the less errors.

If you want to wake up PC from sleep mode just send anything from your Arduino via serial port it's more simple

Many thanks for the instruction there, think I will be able to get it done from here. If not, you will see me back in here.

You are welcome ;)