This is the script for the arduino component of a three-parts project where an API, an arduino and a mobile app communicate together in order to enable users to remotely control the power state of their desktop computer(s).
Make sure the computer's motherboard supports standby USB power so the arduino stay on even when the computer is off.
Item description | Amazon link |
---|---|
Arduino board with wifi capabilities | Arduino Uno R4 WiFi |
Split female to male jumper wires | Single female to dual male jumper wires |
Male to male jumper wire | 40 PCS 20 CM jumper wires |
Motherboard USB header to USB A adapter | Female 9 pin USB 2.0 to female USB A adapter |
USB-C to USB-A cable | Amazon Basics 3 feet USB-C to USB-A cable |
- Download and install the arduino ide
- Update the arduino firmware
- Clone the repository:
git clone https://github.com/sqrrrrl/pc-power-arduino.git
Open the project in the arduino IDE and create a file named environment.h with the following variables:
#define SECRET_SSID "example-wifi" //The wifi network name
#define SECRET_PASS "password" //The wifi network password
#define API_ADDRESS "pcpower.example.com" //The ip address or domain name for the API
#define API_PORT 443 //The port the API is listening on
#define DEVICE_ID "abcdef" //The 6 characters long device id assigned to the device by the API
#define DEVICE_SECRET "abcdefghijqlmnop" //The 16 characters long device secret assigned to the device by the API
- Read the computer's motherboard manual to locate the required pins and use the split jumper wires to connect a motherboard pin to both the arduino and the case switches/LED
- Connect the positive power switch pin
POWER SW+
to thedigital
pin#3
- Connect the positive reset switch pin
RESET SW+
to thedigital
pin#5
- Connect the positive power switch LED pin
POWER+
to theanalog
pin#4
- Connect the reset pin of the arduino to the
digital
pin#11
- Use one of the USB ports on the computer as the power source for the arduino
The script can be compiled and flashed on the board with the arduino IDE.
Distributed under the GPL-3.0 license