Close
0%
0%

Remote computer wakeup device

A wired remote control device that can wake up a computer so the computer can wake from sleep by the time you walk to it.

Public Chat
Similar projects worth following
If your computer or peripherals take a while to start up after the computer wakes up from sleep and you can't get one of those fancy ARM based always on computers, this is the project for you. My monitor takes about 15 seconds to get ready after I press a button on my computer to wake it up from sleep, so I added this button outside my room that I can press and reduce the time that I have to wait for it to start while I walk there.

I used an inexpensive Digispark, though any microcontroller board with USB support should work.

Basically a push button enables a virtual serial device on the Digispark, and my USB hub sends a wake-up command and the kernel wakes up the computer. The wake-up flag on my USB hub is set using udev.

More details in project log.

50-wake-on-device.rules

Udev rules to make sure the computer wake for Linux (maybe works on Mac OS?) You will need to find the id of the usb controller as discussed in the guide and edit that in here.

rules - 178.00 bytes - 07/06/2020 at 01:16

Download

app.ino

Final Digispark code

x-arduino - 516.00 bytes - 07/06/2020 at 01:10

Download

  • 1 × Digispark
  • 1 × Ethernet cable Could've been any cable with more than two wires
  • 1 × Push button
  • 1 × Resistor As pull down resistor, anywhere from 1k to 10k should probably be fine.
  • 1 × USB Hub (optional) any existing hub with other things plugged in is fine.

  • Hardware

    Karmanyaah Malhotra07/06/2020 at 02:00 0 comments

    Not much here. I just soldered a cable connecting to a push button between 5v and pin 5 and a pull-down resistor to pin 5.

  • USB and software

    Karmanyaah Malhotra07/06/2020 at 01:59 0 comments

    USB setup:

    Disclaimer:

    1. I'm using Arch Linux but this should probably be portable to most mainstream Linux distros (Debian, Ubuntu, Fedora, etc).
    2. I am using an external USB hub because it stays docked on my desk and I don't trust my soldering enough to plug the Digispark directly into my computer.

    What I tried:

    I thought it would be as simple as asking the Digispark keyboard library to type something when the button press was detected.
    That didn't end up working out because the Digispark keyboard library doesn't have ( as I discovered later after a lot of wasted time and effort) a wake-up flag which means the Linux kernel never considers it to be a device that can wake up the computer.

    After that, I tried the DigiCDC library, which can emulate (from what I understand) more low-level USB functionality. I realized that I could just start a serial connection with the SerialUSB.begin() command, and it would (from what I understand) basically act as if a device was just plugged in. This seemed perfect because a device being plugged in seemed exactly like the sort of thing that the kernel would consider waking up the computer for.

    After figuring out what wake-up flags were (the capibality of a device to wake up a computer or not) I realized that my USB hub that enabled and it issued a wake-up request when a USB device was plugged in. Perfect! So any time a button was pressed, I issued these commands

    SerialUSB.begin();
    SerialUSB.delay(6000);
    SerialUSB.end();

    Looking at dmesg with `dmesg -w`, it seemed like the device was being unplugged each time this was happening. After that,

    I sent

    echo enabled > /sys/bus/usb/devices/1-3/power/wakeup

    I had previously figured out that 1-3 was my usb hub by looking at lsusb and seeing

    Bus 004 Device 004: ID 05e3:0749 Genesys Logic, Inc. 
    Bus 004 Device 003: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter
    Bus 004 Device 002: ID 05e3:0626 Genesys Logic, Inc. USB3.1 Hub
    Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 007: ID 8087:0a2b Intel Corp. 
    Bus 001 Device 006: ID 06cb:0081 Synaptics, Inc. 
    Bus 001 Device 004: ID 04f2:b61e Chicony Electronics Co., Ltd Integrated Camera
    Bus 001 Device 032: ID 046d:c534 Logitech, Inc. Unifying Receiver
    Bus 001 Device 038: ID 16d0:087e MCS USB2.1 Hub
    Bus 001 Device 030: ID 05e3:0610 Genesys Logic, Inc. 4-port hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

    I figured that MCS USB was my Digispark because that showed up every time the Digispark's SerialUSB was activated. Also, the Logitech reciever was the only other thing plugged into that particular hub so it made sense that they would be devices 30 and 3[1-9]. Then, I had to investigate a bit to find out how to relate the numbers in /sys to these ID's but it worked out by `grep . /sys/bus/usb/devices/*/idProduct`.

    I set up a systemd action to do this on each boot,

    And it works!!!!!!

    .

    .

    .

    Not so easily, I realized after a few hours and my USB hub being unplugged once for unrelated reasons, each time the USB hub is unplugged, these settings reset themselves. Thankfully though, on my adventures across the internet search for what would end up being the wake-up flag, I had learned about udev. Basically, udev is a utility that does stuff when any peripheral is plugged in (read the Arch wiki page for more info). So, I set up a udev command that whenever the usb device '05e3:0610' is plugged in,

    ACTION=="add", SUBSYSTEM=="usb", DRIVERS=="usb", ATTRS{idVendor}=="05e3", ATTRS{idProduct}=="0610",  

    udev sets its wake-up attribute to enabled.

      ATTR{power/wakeup}="enabled"
    

    And it works!!!! (As of writing this I haven't rebooted my computer after making this change so I don't know if it will persist yet. In principle this should be pretty robust.)

  • Rationale behind the parts

    Karmanyaah Malhotra07/06/2020 at 01:23 0 comments

    This will explain the why of things. To see just the final product look at the build instructions.

    Digispark:

    This was an obvious choice since I had it lying around and am mostly familliar with it's USB functionality (or at least I thought so before I started this project). It is small in size and has a few IO pins in case I need to add more functionality in the future.

    Ethernet:

    Used it in case I need to add more buttons in the future and because I had some partly broken ethernet cable lying around. Could be replaced with any 2 wire cable.

    Pushbutton:

    No rationale just a generic push button.

View all 3 project logs

  • 1
    Circuit
    1. Solder wire 1 to 5v on the Digispark
    2. Solder wire 1's other end to the push button
    3. Solder both wire two and the pull-down resistor to pin 5.
    4. Solder wire 2's other end to the other end of the push button.
    5. Solder the other end of the resistor to ground.
  • 2
    Upload code to the Digispark

    Set up the Digispark environment with instructions from http://digistump.com/wiki/digispark/tutorials/connecting


    Upload the code in the attached ino file to the Digispark.

  • 3
    Figure out which device is USB hub
    Use the output of `lsusb -tv` to figure out which device is the USB hub. In my case the following was part of the command output
    /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
        ID 1d6b:0002 Linux Foundation 2.0 root hub
        |__ Port 3: Dev 40, If 0, Class=Hub, Driver=hub/4p, 480M
            ID 05e3:0610 Genesys Logic, Inc. 4-port hub
            |__ Port 4: Dev 42, If 1, Class=Human Interface Device, Driver=usbhid, 12M
                ID 046d:c534 Logitech, Inc. Unifying Receiver
            |__ Port 4: Dev 42, If 0, Class=Human Interface Device, Driver=usbhid, 12M
                ID 046d:c534 Logitech, Inc. Unifying Receiver
    

    I figured that since the Logitech reciever was plugged into the same hub I was going to use for my Digispark, 'ID 05e3:0610 Genesys Logic, Inc. 4-port hub' is probably the target USB hub. As far as I know if the target USB hub is an external USB to USB hub, it probably won't be a top-level (or root) device. The ID 05e3:0610 is the main takeaway from this step.

View all 5 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates