Skip to content

Latest commit

 

History

History
92 lines (78 loc) · 3.75 KB

README.md

File metadata and controls

92 lines (78 loc) · 3.75 KB

ESP32/ESP8266 Wake-on-LAN Bridge with Alexa and Telegram

This project allows you to create a bridge using an ESP32 (or ESP8266) that can send Wake-on-LAN (WOL) magic packets to specific devices on your local network. The bridge can be controlled using Alexa voice commands or a Telegram bot, enabling you to remotely wake your computers or other devices. The project utilizes the WakeOnLan library for generating WOL packets and integrates with Alexa through fauxmoESP and Telegram bot API.

Features

  • Send Wake-on-LAN magic packets via Alexa voice commands.
  • Control via Telegram bot to wake up multiple devices.
  • Works with ESP32 or ESP8266 microcontrollers.
  • Can act as a network bridge to receive packets and trigger WOL.
  • Easy setup for local network configuration.

Libraries Used

This project makes use of several libraries. Install them through the Arduino Library Manager or PlatformIO.

  1. WakeOnLan - Generates and sends magic packets to wake devices on the same network.
    lib_deps = https://github.com/a7md0/WakeOnLan.git
  2. fauxmoESP - Allows Alexa integration for controlling ESP devices.
  3. UniversalTelegramBot - Enables communication with Telegram bots.
  4. ArduinoJson - Handles JSON parsing required by the Telegram bot.

Hardware Requirements

  • ESP32 or ESP8266 module.
  • Local network access (Wi-Fi).
  • Alexa-enabled device (e.g., Amazon Echo) for voice control.

How to Use

1. Wi-Fi Configuration

Update the Wi-Fi SSID and password in the code:

#define WIFI_SSID "your_wifi_ssid"
#define WIFI_PASS "your_wifi_password"

2. Alexa Integration

The project integrates with Alexa using the fauxmoESP library. You can add virtual devices to be controlled by Alexa:

fauxmo.addDevice("PC_TO");
fauxmo.addDevice("PC_PE");

Commands like "Alexa, turn on PC_TO" will send a WOL packet to the configured device.

3. Telegram Bot Integration

Configure the bot by setting the token and MAC addresses for your devices:

#define TELEGRAM_BOT_TOKEN "your_telegram_bot_token"
targetDevice devices[] ={
  {"50:EB:F6:1F:CF:95", "PC_TO"},
  {"18:31:BF:B6:1E:4F", "PC_PE"}
};

The bot responds to commands such as /wol to display a list of devices to wake.

4. Wake-on-LAN

The Wake-on-LAN functionality is implemented using the WakeOnLan library:

const char *MAC_TO = "50:EB:F6:1F:CF:95";  // Replace with your device MAC
WOL.sendMagicPacket(MAC_TO);

Ensure that WOL is enabled on the target devices and they are connected to the same network.

Installation

Arduino IDE

  1. Install the required libraries from the Arduino Library Manager.
  2. Flash the code to your ESP32/ESP8266 using Arduino IDE.

PlatformIO

In your platformio.ini, add:

lib_deps = 
  https://github.com/a7md0/WakeOnLan.git
  fauxmoESP
  UniversalTelegramBot
  ArduinoJson

Telegram Bot Setup

  1. Create a new bot using BotFather.
  2. Obtain the bot token and replace it in the code:
    #define TELEGRAM_BOT_TOKEN "your_telegram_bot_token"
  3. Send /start to your bot, and it will respond with available commands.

Alexa Setup

Ensure that your Alexa device is on the same network as the ESP32/ESP8266. Devices will be automatically discovered by Alexa.

Sources of Inspiration

This project was inspired by the following tutorials: