Wake on Lan using ESP8266
Are you tired of always having to practically crawl under your desk to turn on your PC? Or maybe you need to turn your computer on or off from another location (where there is Internet access)? Then I think this solution will interest you.
The main goal was to have access to my home PC in case I forgot something. The first thing that came to my mind was to combine an ESP8266 and a Telegram Bot for this. But how can you turn on a PC with this? For example, you could connect it to the PC’s motherboard inputs for the switch. But that’s too cumbersome. It turns out there’s a simple solution - WOL (or wake-on-lan). WOL, as the name suggests, can “wake up” something over LAN.
For implementation, we will need:
- ESP8266;
- VSCode;
- PlatformIO;
- Telegram Bot token;
- Internet access (via Wi-Fi);
I used this model, and it’s more than sufficient for this project. Wemos D1 mini.
To “flash” the code, we will use VSCode and PlatformIO. For more details on how to set it up, see the instructions here.
The source code of the project is available here. There, you can also find a brief explanation of the configuration and comments on the code.
The main idea is to listen for “commands” from a Telegram Bot and send a “magic packet” to the device.
and if there are no errors, upload it
By switching to Serial Monitoring, you can see the logs. If the board successfully connects to the internet and receives messages, you will see this:
Now you can go to the Telegram Bot and test it. Enter the previously created bot and send commands:
The use cases are not limited to this, as you can turn on any device that supports WOL. However, I use it for a personal computer in conjunction with the Parsec program for remote access.