0
\$\begingroup\$

I have a project that I need to complete for work. We have been working on this project for a while, however I have come to a bit of a road block. I'll first lay out the important points.

  • We have a Raspberry Pi & a USB Hub with Charge Only cables plugged into it.
  • We want to be able to turn the power from the USB Hub to the device on/off depending on certain conditions.
  • The USB Hub, we want to detect if a device (e.g. Smart Phone or Portal Battery Charger) has been plugged into one of the charge cables. We have charge cables currently, they plug and receive charge straight away.
  • I'm currently using uhubctl to turn on/off ports.
  • Using Linux, I need to detect a device being plugged in/unplugged

Problem: When I use Data & Charge cables, I fall into 2 issues.

  1. iPhone require their users to "trust" the device first before it will accept charge.

  2. It opens a vulnerability in terms of juice jacking which I'd like to avoid.

Solution: Don't use Data & Charge cables, use charge only. Problem with this approach is I cannot detect a device being plugged in.

With that information, I have hit a bit of a roadblock in terms of available hardware to achieve our goal.

So, my question boils down to this:

  1. Is the approach and I'm taking correct. What I mean is: Using the USB Hub & Charge Only cables.

  2. Is there any available solutions out there in the market that you could suggest I investigate?

  3. Is there another potential approach I have not considered that you could suggest?

  4. I don't need any data, so charge cables are a perfect solution if possible (not mandatory though). But, I need to be able to detect if a device has plugged into the USB Hub (or other device that is capable of doing so).

\$\endgroup\$

closed as off-topic by Chris Stratton, Elliot Alderson, RoyC, Dwayne Reid, Finbarr Jan 20 at 23:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on the use of electronic devices are off-topic as this site is intended specifically for questions on electronics design." – Chris Stratton, Elliot Alderson, RoyC, Finbarr
If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ well, you could put some form of current sensor on the power rail. \$\endgroup\$ – Hearth Jan 15 at 2:37
  • 2
    \$\begingroup\$ First you need to explain your actual goal. Forget for the moment about mechanism (especially as most of what you've described won't work) and explain the external behaviour of the device. What's the point of "turning off" empty ports anyway? \$\endgroup\$ – Chris Stratton Jan 15 at 2:49
  • \$\begingroup\$ So users cannot just plug in their device. There is a requirement to first perform an action on a touch screen display before the user can receive power from the USB Hub. \$\endgroup\$ – Tim Jan 15 at 3:18
  • \$\begingroup\$ "juice jacking" - what do you mean here? \$\endgroup\$ – Ale..chenski Jan 15 at 3:19
  • \$\begingroup\$ Further, if I can detect the device, then there is actually no need to turn port power on/off. The power was a temporary solution until we could detect devices being plugged in. Juice Jacking is when say 2 mobile devices are plugged into the same usb hub. 1 user can execute malicious code to try and hack into the other device. \$\endgroup\$ – Tim Jan 15 at 3:20
1
\$\begingroup\$

USB wasn't designed the way you want. The connect event is simple: host keeps VBUS on; if deice is plugged in ("attached"), it senses the VBUS and asserts pull up on one of data lines. This is the "connect".

The detection of "attach" is always challenging. In some later USB development (particularly with advent of "battery charging"), there were proposals of special 5-pin USB connectors with additional "sensor contact" pin, see this FCI drawings.

enter image description here

But this is all gone, history.

USB 3.0 detects the attachment by sending short pulses into Rx wires, and measuring resulting RC, the circuit is built into transmitter.

You can try to detect the extra massive ground/vbus by doing something similar (RF pulses), but again, it is splitting hairs and can't cover all variety of cables.

In short, in 25 years of USB development, engineers haven't invented a cheap and reliable method to detect attached cable without powering it up, or having extra contacts in connector.

\$\endgroup\$
  • \$\begingroup\$ It's actually not the USB Cable -> USB Hub. The charge cable is already plugged into the USB Hub, it's detecting if a device is plugged into the charge cable. Or further, detect if a device is plugged in. So let's imagine we were using normal usb cables with both data & charge. Now that actually works. However the problem that occurs with that is that iPhone requires you to "trust" the device first before it will accept charge. But we don't want that prompt to occur. On Linux, I was unable to find a viable way to disable the data connection that would allow charge and prevent the "trust" \$\endgroup\$ – Tim Jan 15 at 4:37
  • \$\begingroup\$ @Tim, I am not sure I am following your idea. People specifically worked hard to let iPhone to be charged from trusted sources, and not from some arbitrary junk. If you are making a trusted source, then you need to provide a software on Linux side that properly responds to iPhone trust request. If you don 't provide trust signature (whatever it is, I don't know), the iPhone won't charge to it's full capability. \$\endgroup\$ – Ale..chenski Jan 15 at 5:41
  • \$\begingroup\$ Hi Ali, here is a youtube video showing exactly what I'd like to do. -- youtu.be/sRlyeFe7Uyg?t=45 -- If you refer to 0:45 - 0:53 seconds into the video, you'll notice that they are plugging in a mobile device and detecting on the screen. This is exactly what I'm trying to do, however I'm not sure how to go about it. \$\endgroup\$ – Tim Jan 15 at 22:28
  • \$\begingroup\$ @Tim, search SE for "charging signature" topics. You can't charge various phones without providing them with proper signature or handshake protocol, which is done over D+/D- in most phones. You can't do this without applying default VBUS voltage first. \$\endgroup\$ – Ale..chenski Jan 16 at 0:23

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