Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WirelessPowerSwitch

Remotely power on, power off, and monitor desktop PCs over Wi-Fi.

WirelessPowerSwitch is a small home-lab project made of two parts:

  1. Firmware for an ESP-01S (ESP8266) module that wires into a PC's front-panel headers and exposes a tiny HTTP API to simulate the power button and read the power LED.
  2. A JavaFX desktop application that talks to one or more of these modules, letting you start, stop, and monitor several PCs from a single dashboard.

Project Diagram


Table of Contents


Overview

Many desktops don't offer any built-in way to be turned on remotely (no Wake-on-LAN support, BIOS setting disabled, etc.), and a hard shutdown is sometimes needed for an unresponsive machine. WirelessPowerSwitch solves this with a small, cheap ESP8266 module wired directly to the motherboard's front-panel connector, controlled over the local network through a simple authenticated HTTP API and a friendly desktop GUI.

Features

  • Remote power on/off — simulates a normal front-panel button press.
  • Forced shutdown — simulates a long button press (~6 seconds) to force off an unresponsive PC.
  • Live status polling — reads the PC's power LED to report on/off state.
  • Multi-PC dashboard — manage any number of PCs from one GUI, each as its own card.
  • Shared-secret authentication — power actions require a matching SHA-256 key.

How It Works

 ┌────────────────────┐        HTTP (port 60000)        ┌───────────────────────┐
 │   JavaFX Desktop    │ ───────────────────────────────▶│   ESP-01S (ESP8266)   │
 │   Application       │◀─────────────────────────────── │   running the sketch  │
 └────────────────────┘        JSON-less plain text       └───────────────────────┘
                                                                │           │
                                                     PWRSW pin  │           │ PWLED pin
                                                                ▼           ▼
                                                        Power switch    Power LED
                                                        header (out)    header (in)
  • The ESP-01S connects to Wi-Fi and starts an HTTP server on port 60000.
  • One GPIO (PWRSW) is wired in parallel with the PC's power switch button; briefly pulling it low simulates a button press.
  • Another GPIO (PWLED) reads the PC's power LED header to determine whether the PC is currently on or off.
  • Every power request must include a key query parameter matching a SHA-256 hash pre-configured on the device.
  • The JavaFX GUI reads the list of managed PCs (name, IP, port) from config.txt, renders one card per PC with Start, Stop, and Force Stop buttons, and refreshes every PC's status every 5 seconds.

Repository Structure

WirelessPowerSwitch/
├── WirelessPowerSwitch.ino     # ESP8266 firmware (Arduino sketch)
├── GUI/                        # JavaFX desktop application
│   ├── config.txt              # Shared secret key + list of managed PCs
│   ├── Assets/                 # Images/icons used by the GUI
│   └── src/
│       ├── sample/
│       │   ├── Main.java         # JavaFX application entry point
│       │   ├── Launcher.java     # Plain-Java entry point (works around JavaFX packaging)
│       │   ├── Controller.java   # Loads config.txt, builds the PC list, drives status polling
│       │   ├── Computer.java     # UI card for a single PC (buttons + status)
│       │   ├── sample.fxml       # UI layout
│       │   ├── styles.css        # UI styling
│       │   └── Services/         # Async HTTP calls (JavaFX Service/Task)
│       │       ├── PowerService.java
│       │       ├── ForcePowerOffService.java
│       │       └── GetStatusService.java
│       └── META-INF/MANIFEST.MF
└── Doc/                        # Diagrams and screenshots (referenced in this README)

Hardware & PCB

A custom PCB (designed in EasyEDA) hosts the ESP-01S and interfaces it with the PC's front-panel power switch and power LED headers.

Schematic Layout
PCB Schematic PCB Layout

Wiring summary (see WirelessPowerSwitch.ino):

Signal ESP8266 pin Connects to Direction
PWRSW GPIO pin 3 PC power switch header Output — pulled low briefly to simulate a button press
PWLED GPIO pin 1 PC power LED header Input — read to determine current power state

Firmware Setup

  1. Open WirelessPowerSwitch.ino in the Arduino IDE.
  2. Install ESP8266 board support and the following libraries (all part of the ESP8266 Arduino core):
    • ESP8266WiFi
    • ESP8266WiFiMulti
    • ESP8266WebServer
  3. Configure your credentials directly in the sketch before flashing:
    • Replace <YOUR WIFI SSID> / <YOUR WIFI PASSWORD> in wifiMulti.addAP(...) with your network credentials.
    • Replace SHA256KeyHash with the SHA-256 hash of a secret key you choose (see Configuration — the GUI computes this hash from the same plaintext key you put in config.txt).
  4. Select the ESP-01S / generic ESP8266 board and flash the sketch.
  5. Wire the module to the PC's front-panel headers as described in Hardware & PCB, then power it on — it will connect to Wi-Fi and start listening on port 60000.

Building & flashing with arduino-cli (alternative to the Arduino IDE):

# One-time setup
arduino-cli core update-index --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json
arduino-cli core install esp8266:esp8266 --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json

# Compile
arduino-cli compile --fqbn esp8266:esp8266:generic WirelessPowerSwitch.ino

# Upload (replace COM3 with your ESP-01S's serial/USB-adapter port)
arduino-cli upload -p COM3 --fqbn esp8266:esp8266:generic WirelessPowerSwitch.ino

GUI Setup

The GUI (folder GUI/) is an IntelliJ IDEA JavaFX project (see JavaFxApplication.iml), not a Maven/Gradle build.

  1. Prerequisites: JDK 15+ and the JavaFX SDK 17 downloaded locally.
  2. Open the GUI folder as a project in IntelliJ IDEA.
  3. Add the JavaFX SDK as a project library (File > Project Structure > Libraries) pointing to the lib folder of the SDK you downloaded — the project expects it under GUI/javafx-sdk-17/ (already excluded via .gitignore).
  4. Add the required JavaFX VM options when running Main/Launcher, e.g.:
    --module-path "<path-to-javafx-sdk-17>\lib" --add-modules javafx.controls,javafx.fxml
    
  5. Make sure config.txt and the Assets/ folder are present in the working directory when you run the app (see Configuration below) — both are loaded using relative paths.
  6. Run sample.Launcher (or sample.Main) to start the application.

Building & Running from the Command Line

If you don't want to use IntelliJ IDEA, the GUI can be compiled and run directly with the JDK, once you have downloaded the JavaFX SDK 17 and extracted it locally:

# From the GUI/ folder — set this to wherever you extracted the JavaFX SDK
$javafx = "C:\path\to\javafx-sdk-17\lib"

# Compile all sources into ./out
javac --module-path $javafx --add-modules javafx.controls,javafx.fxml `
      -d out (Get-ChildItem -Recurse -Filter *.java src | ForEach-Object { $_.FullName })

# Copy non-Java resources (FXML, CSS) next to the compiled classes
Copy-Item src\sample\sample.fxml, src\sample\styles.css out\sample\

# Run (config.txt and Assets/ must be in the current working directory, i.e. GUI/)
java --module-path $javafx --add-modules javafx.controls,javafx.fxml -cp out sample.Launcher

To package a runnable JAR instead of running from out/ directly:

jar --create --file WirelessPowerSwitch.jar --main-class sample.Launcher -C out .

java --module-path $javafx --add-modules javafx.controls,javafx.fxml -jar WirelessPowerSwitch.jar

The JAR still needs to be run from a working directory that contains config.txt and Assets/, since the code loads both via relative paths.

Configuration

The GUI reads its setup from GUI/config.txt, a simple comma-separated text file:

HashKeyword
NAME 1,0.0.0.0,1000
NAME 2,0.0.0.1,1001
Line Format Description
1 <secret key> Plaintext shared secret. The GUI hashes it with SHA-256 at startup and sends that hash as the key parameter on every power request — it must match SHA256KeyHash flashed on each ESP8266.
2+ <name>,<ip>,<port> One line per managed PC: display name, ESP8266 IP address, and HTTP port (60000 by default).

If config.txt is missing or contains invalid lines, the GUI shows an error dialog (creating an empty file if needed) and exits so you can fix it before relaunching.

HTTP API Reference

The ESP8266 firmware exposes the following endpoints on port 60000:

Endpoint Method Query params Response Description
/power GET key 200 OK / 400 Simulates a short (~1s) button press — toggles power on or off
/powerOffForced GET key 200 OK / 400 Simulates a long (~6s) button press — forces the PC to shut down
/getStatus GET — 1 (on) or 0 (off) Reads the current power LED state
(any other path) any — 404 Not Found Fallback handler

Requests to /power and /powerOffForced are rejected with 400 unless key matches the SHA-256 hash configured on the device.

Security Considerations

  • Authentication is a single shared-secret hash compared with the key query parameter — this is lightweight, not a substitute for real authentication (no TLS, no per-user credentials, no rate limiting).
  • Treat each ESP8266 module as trusted-network-only: keep it behind your home router/firewall and never forward port 60000 directly to the internet.
  • The secret key is stored in plaintext in GUI/config.txt on the client machine — protect access to that file.

Screenshots

GUI dashboard — one card per configured PC, with live status color (green = on, red = off) and Start / Stop / Force-Stop buttons:

GUI

Class diagram of the JavaFX application:

Class Diagram

Tech Stack

  • Firmware: Arduino (C++) for ESP8266 / ESP-01S
  • Desktop app: Java SDK 15, JavaFX 17
  • PCB design: EasyEDA

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages