6

Is it possible to wake up a Windows PC from standby/hibernate via a USB event originating from a Raspberry Pi?

When my Windows PC is in standby and I move my mouse then the PC wakes up. This is exactly what I want to do with an application running on my Raspberry Pi (if I connect the Raspberry Pi to the USB port of my PC).

  • I will add my solution soon @ppumkin ... I have worked out something similar based on the current answers. Thank you all! Of course I will accept an answer – seveves Sep 6 '15 at 20:48
4

You have, potentially, three options:

  • USB to USB (not possible as RPi can only act in Host mode);
  • USB to Arduino to GPIO (See below)
  • USB to GPIO (See NOTE)

NOTE: If you are going to connect the GPIO to USB then you must use opto-couplers or voltage levellers, such as the 74HC4050 hex buffer, as USB runs at 5V and the GPIO is 3V, so without them you would run the risk of frying the RPi

If you use an Arduino (Leonardo, Due or Micro) as an interface then yes. There are Mouse and Keyboard libraries, that allow the Arduino to send key and/or mouse events to the RPi.

If you use an Arduino Pro Mini designed to run at 3.3V then the requirement for opto-couplers or voltage levellers is reduced. On instructables.com is a plan for connecting an Arduino Mini to a RPi, by making a Hoody. I have made this device and it works great.

Hoody - Arduino Micro to a Pi

Once you have built the Hoody, then with the addition of a FTDI to USB interface and the libraries you should be good to go.

FTDI to USB interface

The Arduino Pro Mini connected to (and powered by) a SparkFun FTDI Basic Breakout Board and USB Mini-B cable. Note that on earlier Pro Mini boards the orientation of the 6-pin header may be reversed; check that the words GRN and BLK align on the Pro Mini and FTDI Basic Breakout.

As I have already stated, I built this already - for less than £10, sourcing materials from eBay.

Be careful to note, get a 3.3V Pro Mini, and NOT the 5V, otherwise voltage level shifting and opto-couplers will be required.

ADDENDUM: I am not 100% sure that the Keyboard/Mouse libraries will work with a Pro Mini (as they require 32u4 devices), however, it would be easy enough to write a sketch that fires the appropriate signals to the FTDI.

As David Freitag points out in the comments below, the Pro Micro is compatible with the libraries and also runs at 3.3V and so would make a most suitable choice.

UPDATE: I have just purchased one of these 3.3V Pro Micro clones, from that well known auction site, in order to mess about, emulating mouse clicks.

  • 1
    Hm I don't have an arduino yet but a beaglebone black. But this way looks very promising. – seveves Jul 13 '15 at 11:11
  • Your addendum is correct, the USB libraries will not work for the Pro Mini because it uses an Atmega328 which does not have any USB peripherals. The board you should have suggested is the Pro Micro 3.3V. sparkfun.com/products/12587 – David Freitag Jul 13 '15 at 15:42
  • @DavidFreitag - There is apparently some confusion in the naming convention in used across the different manufacturers. I was referring to the Pro Mini 3.3V. To be fair, they are probably much of a muchness, and the main point that I was tying to get across was that using a 3.3V Arduino requires less glue logic... However, yes, the Pro Micro would be much more suitable as it is compatible with the key and mouse libraries. Thanks for pointing that out. I shall look into purchasing one. :-) – Greenonline Jul 13 '15 at 16:30
  • 1
    @Greenonline There isn't really a confusion, the same part exists as an Arduino device. The only problem is that they only offer a 5V device. See here: arduino.cc/en/Main/ArduinoBoardMicro – David Freitag Jul 13 '15 at 16:45
3

Read this. It seems that raspi may not be slave device (work as mouse - sending such data through usb will be impossible). But there are other options to USB, some PCs have option 'Wake via LAN', which means it is possible to wake PC via LAN signal, like here.

  • 2
    Naturally you can try to break down usb cable on one end and connect it to GPIO. Then you can simulate whatever you wish, but requires probably a lot of knowledge. – Piotr Kamoda Jul 13 '15 at 10:38
  • Thank you for your answer but WoL or other techniques are not allowed for my use case. In any other use case that would be my first choice, too :) – seveves Jul 13 '15 at 10:57
  • @Piotr - However, if you are going to connect the GPIO to USB then you should use opto-couplers or voltage levellers as USB runs at 5V and the GPIO is 3V, so without them you would run the risk of frying the RPi – Greenonline Jul 13 '15 at 10:58
  • @Greenonline thanks for clarification, but that was only general proposal, not a full solution. – Piotr Kamoda Jul 13 '15 at 11:02
  • Using an existing mouse (hid interface), breaking down the usb cable and powering it via GPIO wouldn't work? – seveves Jul 13 '15 at 11:04
3

Actually I think that this is possible. I don't want to go into the details what to do at the PC side of this plan, but for the Pi:

The USB port of the RPi is technically an On-the-go (OTG) chip and should support both a reduced set of host and client functionality and could therefore play the role of an USB slave such as an HID. However the B/B+ types of the RPi do not support the device mode which is related to the included USB hub and the fact that the ethernet is tunneled through USB (see).

But... the Human Interface Devices (HID) such as mice only need the USB 1.1 Low Speed with 1.5 MBit/s data rate. So there are many solutions out there that use software based USB stacks to emulate an USB device. Those examples typically use microcontrollers that are way less "powerful" than the RaspberryPi (but of course they also have a significantly lower overhead). Examples include the Igor Plug (an IR remote control receiver based on an Atmel microcontroller) or microcontroller based "fake" keyboards or "key loggers". It should be really possible to do this with a Pi.

If we believe How fast is GPIO+DMA? Multi I2S input then 1.5 MBit/s should be possible on the GPIO with DMA.

0

Windows and the bios of many pc's support 'wake on LAN' events. See your bios menu options to see what is there. Also check that your router is not blocking 'wake on lan' messages. How to send one from a raspberryPi B via ethernet is unknown to me, but I'm much more confident that it could than anything usb.

The reason is that usb has a 'computer' end, usually with the broad letterbox flat-four connector and a 'perhipheral' end for camera's and other slave devices. To cut up two usb cables to make a double-master-ended cable would be nasty and should be unrecognised by at least one end. The 5V micro-usb supply to the pi is using only the +5V DC and GND wires with the other two not connected, so I wouldn't waste time trying to get data through it.

The other way is to download a few things on the pi until you can switch an LED on pinboard from the GPIO pins on the pi. You'll need a transister as well and set that up on your pinboard to switch a 5V or 6V battery and another LED. When you can switch a 5V device on pinboard via the 3.3V GPIO, solder some extra wires parallel to the main power switch on the front of your pc. For most of the time, those are +5 and GND, except while the switch is being pressed. Now, get your pi to switch ON for 0.6 seconds, like someone just pressed the main on switch of the windows machine. I'm not sure yet whether that will do what you want. If you need to do the same to a usb cable whose master is the pc, there might be a way.

-1

Have you worked with the /dev folder in linux before? If not, there is a table on this page (http://www.tldp.org/LDP/intro-linux/html/sect_03_01.html) that nicely describes each directory in root (/).

The /dev folder contains linux files that pertain to your devices (i.e. hard drives, monitor, ram, etc.). When you connect a device, in your case the usb, to the computer it should show up under this folder.

I would:

  1. ls in the /dev folder before and after connecting the usb from the pi to the windows machine to figure out which file in /dev pertains to the usb port.

  2. Then, write a simple script to write data to this file. Example:

    • echo "1234" >>{filename}
  3. Then, call this file from another program or whenever you want to wake up the pc.

    • To test this out you could type the command manually into the terminal.

See if this works. My idea is that the activity in the usb will trigger your windows machine to wake up. I am curious so if I get a chance I will try this with my own pi / windows machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.