Today I was asked how it could be possible to resume a PC from standby at a given hour… It was enough to connect an Arduino Pro Micro to an RTC module, write some code and the WakeMeUP project was born…
WakeMeUP is a USB device that sends a wake signal to the connected PC at a given time. The configuration is performed through a serial connection: the Arduino I chose (Pro Micro) is indeed able to become a composite USB device, that implements:
- a virtual serial port (CDC)
- a human interface device (HID), like a keyboard or a mouse
I added a realtime clock module (RTC) sold by SparkFun. That module is based on the DS1307 chip, connected to the Arduino via the I2C bus.
All the project was built on a perfboard and both the Arduino and the RTC module were inserted in an IC socket:
Wake and System Power States
A personal computer may be in different power states, identified by ACPI codes:
- S0 (working), normal working state
- S1–S2–S3 (sleeping), different sleep states (the PC is suspended in RAM memory)
- S4 (hyberntion), the PC seems turned off, its state is saved on an hard disk
- S5 (soft off), the PC is turned off, only some components (network card, USB devices…) may be powered
- G3 (mechanical off), the PC is switched off using a mechanical switch, nothing is powered
Usually, all the mother boards support the wake from S1-S2-S3 states, while only a few support also the wake from S4-S5 (wake from G3 is obviously impossible: no device is powered in that state).
You normally configure this feature in the mother board’s BIOS, where you can also enable the USB power in the different states (often used to recharge connected USB devices even if the PC is switched off):
It’s also important to verify – in the HID device properties – that the option allow this device to wake the computer is selected:
The sketch for Arduino is available in my Github repository.
For Arduino to be able to send the wake signal to the PC, you have to replace the USB library shipped with the IDE with the one modified by Mike T and available on the official forum.
The zip file (also available on my website) contains 4 files, that must be placed (overwriting the existing ones) in \hardware\arduino\avr\cores\arduino (within the main folder where you installed the IDE).
The sketch leverages also the RTCLib library from Adafruit to read data from the RTC module: you can use the new Library Manager to install it in your IDE.
WakeMeUP implements two simple commands you can send through the serial monitor:
- T, displays the actual time, read from the RTC module
- Whhmm, set (and stores in the EEPROM) the time when the wake signal will be sent
The modified USB library allows to send the wake signal with just a line of code: