Hi guys. I'm trying to make WOL using Arduino.
I use the Arduino Nano and the HR911105A module, built on the ENC28J60 microchip.
I tried to use this code:
But it does not work. The controller is initialized successfully, but the packet is not sent.
I added the EtherCard.h library to the desired directory. The MAC target is replaced by the MAC address of my network card. The port speed was reduced to 9600 baud.
Moreover, as far as I understood, this example needs a DHCP server. I connected the Ethernet shield to the router distributing IP by DHCP (the router is configured correctly and works as expected), in conjunction with the computer that needs to be awakened.
Maybe I did not configure the port settings for the correct operation of the broadcaster = a broadcast request?
In the port monitor, I see that the IP, mask and gateway have been successfully issued, but in wireshark there is no necessary wol packet, after repeated pressing "w". The computer also does not start from wol because the package does not come. In this case, the computer is configured correctly, I can wake it through an Android application running on WI-FI.
I also connected the system directly to the computer, without a router, but it also does not lead to anything either.
In my project, I just need to wake the computer on a magic packet using a local network, without external access. As far as I understand, for this I do not need to give out the IP address and other parameters to my module on ENC28J60, it only needs to send a broadcast packet, or am I wrong?
In any case, I want to use a static IP on my ENC28J60.
I noticed that there is an error in the library itself, it is indicated that the CS pin from the ENC28J60 controller must be connected to the 8 Arduino pin, but this is not the case, pin 10 should be used, otherwise the Ethernet controller will not be able to initialize.
The library itself is working, I checked it on this code:
void setup () {
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println( "Failed to access Ethernet controller");
ether.staticSetup(myip);
}
static word homePage() {
long t = millis() / 1000;
word h = t / 3600;
byte m = (t / 60) % 60;
byte s = t % 60;
bfill = ether.tcpOffset();
bfill.emit_p(PSTR(
"HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\n"
"Pragma: no-cache\r\n"
"\r\n"
"<meta http-equiv='refresh' content='1'/>"
"<title>RBBB server</title>"
"<h1>$D$D:$D$D:$D$D</h1>"),
h/10, h%10, m/10, m%10, s/10, s%10);
return bfill.position();
}
void loop () {
word len = ether.packetReceive();
word pos = ether.packetLoop(len);
if (pos) // check if valid tcp data is received
ether.httpServerReply(homePage()); // send web page data
}
I also found these options: Wake on LAN | Download | MegunoLink but I do not understand how to work with it.
Another example: YUTAKA Life net: arduino WOL Repeater - there is a problem with one of the libraries, as far as I understand it is too old (those versions I found were old) for my arduino ide. In addition, here, apparently, you need to flush the port in the router.
What's my mistake? I could not find anywhere a detailed example where the step-by-step implementation of WOL using Arduino is described, I really need this option for my project. I am hope for your help.
Sorry for my bad English.