1

I have an old raspberry B, and I'd like to connect it to a computer with USB. Not for data transmission, but to detect if the computer is turned on. I just want the Pi to do something as soon as that computer is started.

I could use the network, run a ping or arp or whatever to check if the computer is turned on. But that takes time until the Pi recognizes the computer: First, I'd have to run ping in a loop, and I don't want to clutter my network with pings, second, this would only recognize the computer as soon as it has fully booted and established a network connection. I'd like the Pi to recognize the computer as early as possible.

I was thinking about running a USB cable between the computer and the Pi's GPIO pins. Since I can configure the computer to not deliver power when turned off, but then immediately after pressing the power button, it should be possible to just measure if something is connected.

Now, I've already read that I can't just put 5V from USB onto a 3.3V GPIO pin. But what other solution(s) could I use? Can I run the two USB data lines to the Pi to somehow detect if they are "active"? What would be the easiest way check if a USB port supplies power using the Pi? Can I use "common items" like a resistor to get those 5V down to acceptable 3.3V?

2 Answers 2

1

If you have some resistors you could form a voltage divider to drop the USB 5 volts to a Pi GPIO safe 3.3 volts.

Any resistors with a ratio of 2 to 1 should be fine (for a perfect drop from 5 volts to 3.3 volts), or any pair of resistors with the same value should work (to drop from 5 volts to 2.5 volts).

3
  • Looked through my resistor bin to see what I have. A 1k resistor between 5V from the PC and the GPIO and an 1.5k resistor between that GPIO and ground should then be enough to bring it down to 3V right? Commented Mar 4, 2017 at 21:21
  • @FlorianBach Yes, that will be fine.
    – joan
    Commented Mar 4, 2017 at 21:40
  • Soldered it together, checked with a multimeter, 2.99 V. Seems to be perfect. Will test that on my Pi tomorrow. Commented Mar 4, 2017 at 22:54
0

You could consider using the 5V signal you get at power up as the control signal on a relay.

Connect one side of the relay to a +3.3V pin on your Pi, and connect the other side of the relay to an IO pin on your Pi.

When the PC is turned on, switch will close, and the pin you chose for digital input will read high. (i.e. the relay gets triggered when the pc is turned on)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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