Bicycle iPhone and USB Charging – USB Connections

Now that I’m making the right electricity, I need to send it through the right connectors.

There are many online suppliers for bare USB connectors. Most suppliers want you to buy them in quanitities of 100 or more, but there are some good hobbyist websites that will sell them one at a time. They arrive in a plastic bag and look like little rectangles of metal with sharp teeth on one face, and you would need to build or purchase a board with the correct holes to solder them on.

If I were a pro, I would design a custom circuit board in my computer, have the board printed via mail-order, and solder four bare USB connectors into place, making a nice clean part. There would be other pieces to solder in as well – capacitors and some resistors (for reasons I will explain soon) – so I’d basically be reproducing a section of a USB hub, like the kind you get for 10 bucks at the computer store.

Would it be possible to use a store-bought USB hub as-is, hooked directly up to some batteries that match the voltage of the hub’s DC adapter? You’d get the power regulation built-in…

It’s possible, but there are some complications. The first is that almost all commercially available USB hubs will supply NO power to their ports when they are not uplinked to a computer. There may be some tricky way around this – soldering an extra wire somewhere maybe – but I don’t know what it is.

The next problem is power management. Store-bought USB hubs ask for 12 volts, or sometimes 7.5 volts, on their DC inputs, and then they convert this internally to 5 volts for the USB connectors. The main reason they do this is to filter the electrical “noise” out of the incoming power. It’s like taking the spray from a sputtering hose and pushing it through a funnel to make a solid stream. But I’m supplying voltage from batteries – just about the cleanest power you can get. I don’t need to do any filtering, so I don’t need to supply a voltage much higher than the 5 volts I’m after. Why crank it up to 12 volts if I don’t need to?

Also, since I’m working with Lithium-Ion style batteries, I DO need to worry about my MINIMUM voltage. The hub is designed to be supplied with a steady 12 volts, but over time, my batteries would drop from 12, to 11, to 10 volts, and so forth, as they run down. Since I’m using rechargeable batteries, they would eventually reach their “empty” voltage — the point where draining them further could cause damage — and at that point, the drainage needs to STOP. The regulator I’ve chosen for my design does this. Does the circuitry inside a random USB board do the same? I have no idea. Why take the chance?

I don’t need to power the data-transmission chips, the status LEDs, the connection negotiation circuitry, et cetera, that comes with a USB hub. I’d want to rip those parts out, or at least scratch off the connections that power them. I’d need to modify the hub to supply power when no computer is connected. I’d also need to make it cut off at a minimum voltage, which may not be possible without getting my own regulator anyway. Taking all this into account, it’s easier to use my own regulator. But on the other hand, a cheap USB hub is a good way to get four connectors in a row, already soldered to a board…

In fact, why not just get a cheap USB hub and tear off everything but the connectors? USB hubs are so cheap that it would actually cost less than buying the connectors separately.

Sounds like a good idea. But for iPhone users, there’s a catch.

iPhone Voltage

There are only two ways to get an iPhone to charge. You either hook it up to a USB hub that’s connected to a computer, or you hook it up to a charger specially designed for the iPhone.

In the case of a computer, the iPhone does some auto-negotiation over the data lines of the USB connection to ratchet its power up to 1/2 amp. The auto-negotiation is what lets the iPhone know that it’s okay to charge. If it can’t auto-negotiate, it will sit there and do nothing.

In the case of a special iPhone charger, a circuit inside the charger supplies the USB data lines with two specific voltages, which the iPhone is able to sense. These voltages are a kind of signature that tell the iPhone it is connected to a charger, and that it is OK to charge and draw 1 full amp of power.

Does Apple do this in order to exclude certain chargers so that you’ll have to pay more to buy theirs?

That’s a pretty cynical question. Without doing auto-negotiation, the iPhone is only supplied with 35 milliamps of power from a standard USB port. That’s not enough to charge anything. And without some way to distinguish a power adapter from a regular USB connection, the iPhone would not be able to tell if it’s okay to pull 1 amp down the wire. Trying to do so without notice could cause a USB hub to behave unpredictably.

Stalwart geeks out on the internet have disassembled an iPhone power brick, and exposed the circuits that generate the special voltage. Turns out the secret is a grid of four resistors. So if you want to charge an iPhone, you need to supply 5 volts on the power line of a USB connector just like you’d expect, but you also need to get four resistors and wire them up between the data lines, the power line, and the ground wire so that you’re supplying 2 volts and 2.7 volts on the data lines. (Apparently this sort of circuit is called a “voltage cascade”.)

I wanted to verify these findings with my own equipment, so I took apart a crappy USB memory-stick reader that I got for two bucks at the electronics store, exposing the wires inside the USB cable. Then I plugged the cable into my iPhone power brick, and poked the wires with my voltmeter. Sure enough, I got:

  • 5.0 from the red wire to the black wire
  • 2.02v from the green wire to the black wire
  • 2.713v from the white wire to the black wire
Are the wires inside USB cables always colored the same way?

Almost always, yes. The four wires inside a USB cable will probably match one of these color patterns:

+5V DATA- DATA+ GND
Pattern 1:
Pattern 2:
Pattern 3:

Just the same, I recommend you measure with your voltmeter to be absolutely sure. The most important wire is the +5 wire, and you’ll be able to find that one easily.

These voltages are created by connecting four resistors up in a square shape, with 5 volts on one corner, ground on the opposite corner, and a data line on each remaining corner. If you follow the links above you can see several schematics describing this. The four resistors used to create the voltage cascade inside an iPhone adapter are:

  • 75000 Ohms – 85C, 75k, Violet-Green-Orange (4-band), Violet-Green-Black-Red (6-band)
  • 43200 Ohms – 62C, 43k2, Yellow-Orange-Red-Red (5-band)
  • 49900 Ohms – 68C, 49k9, Yellow-White-White-Red (5-band)
  • 49900 Ohms – 68C, 49k9, Yellow-White-White-Red (5-band)

The names after the dash are alternate labels for the same value of resistor. The values can also be expressed as colored bands, and there are even more labeling methods for surface-mount resistors. The fellow behind the counter at your electronics store will accept any of these labels and steer you to the correct drawer. If he can’t, then you’re probably in an appliance store that just has the word “electronics” in the name in order to sound cool and exciting. Tell the clerk to go get a job with some dignity, and then go look for a real electronics store. Or you can buy resistors online by (for example) entering these values directly into the Amazon search box.

Since I had an iPod charger sitting around, I tried measuring that as well. Turns out it supplies the same voltages. The iPod expects the same secret circuitry that the iPhone does. (Still, you shouldn’t just plug any old iPod accessory into an iPhone. Some accessories may be wired to supply voltage at Firewire levels. That could damage your iPhone pretty badly. Measure first! Your voltmeter is like Sherlock Holmes’ magnifying glass.)

I had a spare iPhone charger sitting in my desk drawer, so I pried it apart and threw away everything but the portion of the circuit board with the resistors and the iPhone-style connector. I soldered a few wires to the board and connected it to my regulator, to see if that’s all it would take…

I plugged in the iPhone. ABRACADABRA! It chirped merrily and started charging! I measured the voltages, and everything looked good.

I got very excited and ran downstairs to tell Sherrila. She came upstairs and I connected the phone again to show her… But nothing happened. Uh oh. What was going on?

Turns out I’d damaged the circuit board when I’d chopped it off from the rest of the power adapter. It worked about half the time, if I lifted it up and dropped it onto the table first. I was curious to see how bad the damage was, so I asked Tavys to take a picture of it through his fancy microscope:

Look at that sloppy mess.

Burned rosin everywhere. Hairline cracks. Bulging lumps of solder. The resistors are leaning like rotten teeth. No wonder it wasn’t working half the time. I would not want to put this component inside my charging box.

Still, it represented proof-of-concept. With four resistors and some USB sockets, I could charge an iPhone off my batteries. Time to build something more robust.

Getting Connectors

I dug around in a storage box and pulled out a USB 1.1 hub. Sorry, Belkin, your stuff is about to be sacrificed on the altar of Do-It-Yourselfing.

The board is covered with traces and components already, and I need an open space to work on. So I’m going to take a big bite out of the middle of the board and glue a prototyping board on top of it, then saw off the excess. Nice and crude.

What’s a prototyping board, and where can I get one?

A prototyping board, or “development board”, or “workshop board”, is a small flat chunk of non-conductive material with a bunch of tiny holes drilled through it in a regular pattern. Typically each hole is ringed with a little bit of metal, so solder will stick to it easily.

The idea is, you take all the components in your electronic project and arrange them on the board by putting the connectors and wires through the holes, and once you’ve got everything lined up the way you want it, you solder the parts together. The solder on your components sticks to the metal rings, anchoring them to the board. Sometimes you can connect the parts on the board together electrically by soldering the rings together in chains, creating a sort of printed circuit without the printing. (An example of that can be seen here.)

You can purchase prototyping boards in all different shapes and sizes from all over the web. SparkFun Electronics has an assortment of them, including some with diagnostic or communication circuitry built-in. (I didn’t need any of that for this project.)

To make the chomping operation easier I drilled a bunch of scoring holes around the section I didn’t want. Then a few snips with the pliers and the offending section fell right off.

See that tiny collection of components clustered near each of the USB ports? Each port has a large capacitor, a small capacitor, and a lesser-known component known as a "ferrite bead", used in signal filtering. Ferrite beads are interesting, do read more about them. My intention is to re-use all these components to increase the quality of the signal I send out of the USB ports, because … well, why not?

Is that really necessary?

Nope. The electricity coming straight off a battery is generally the cleanest you can get. The only justification for this extra filtering is if I hook some horribly designed or damaged device to one of the USB ports, and it leaks intense signals back into the board. Not very likely at all. But, the components are already there, so…

Since I had wood glue and document clips hanging around, I used those to stick the boards together. Then I inserted my resistors, and threaded the leads in and out of the board, making plenty of spots to solder wires on. I threaded the capacitor in as well, but then realized that it would make the whole piece too tall. I’ll have to find some other way to install it.

The next day I got to work wiring the resistors to all four of the USB sockets via the underside of the board. It’s a lot of wiring – more than I expected, really – and it took about three hours.

If you decide to solder wires, remember that you can make things much easier for yourself by taping the wires in place!

Here you can see I’ve connected my 5-volt regulator up to the + and – regions on the board, and am charging one first-generation iPhone (upper right) while the second-generation iPhone (lower right) is registering "charged". This is a very good thing – it means that the phone is actually able to fully charge and then stop charging at the appropriate time. This pleeeases me, yeeees.

I decided to leave the middle USB connectors with their "data" lines unwired, just in case I used some USB device that actually complained if it detected strange voltages on those lines. I don’t see myself connecting more than two Apple products at a time anyway.

With all this extra room on the board, I decided to cut a notch of space for the voltage regulator and glue it into place. The capacitor that I’d soldered onto the voltage regulator made the whole thing too tall, so I decided to snip the capacitor off and substitute it for another one (which I also cut a notch for).

Here you can see the capacitor I’ve inserted, and the little red wire I added that connects all the extra components of the USB board up to the ground in my circuit. With that wire in place, the eight capacitors and the ferrite beads are now active.

So now I’ve got a set of four USB ports, two of which can charge Apple gear, with an integrated regulator and a nicely stabilized signal. Also, none of the components is taller than the TuneCharger board, which will be important when I build an enclosure.

Here’s the USB board arranged with the TuneCharger board and the other components, fitting on top of a LiFePO4 battery:

And here’s a shot with the other battery stacked on top. This is my plan for the enclosure. Three compartments, with the circuits sandwiched in the middle. USB ports on one side, plugs and switch on the other.

You’re probably looking at that and thinking exactly what I’m thinking: "Damn, that’s an awful lot of battery."

Over the course of the project, I’ve test-charged iPhones and iPods on the batteries, and gone through half a dozen charge cycles. I’ve even hooked up a laptop cooling station and run it for many hours, just to test the regulator. And even though the voltage regulator will "allegedly" use just 3/4 of the battery capacity, I have not approached that limit yet. The batteries still put out around 6.0 volts, about a .6 volt drop from a couple of weeks ago. I now have to face an unexpected dilemma: Too much capacity.

I’m carrying an entire pound of Lithion-Ion battery material here. Have I overdone things?

Only road-testing can answer that question. Before I can do that, I’ll need an enclosure.

To Building An Enclosure

11 Responses to Bicycle iPhone and USB Charging – USB Connections

  1. Pingback: ben

  2. Pingback: ben

  3. Pingback: ben

  4. Pingback: cameron lowellpalmer

  5. Pingback: conlan rose

  6. Pingback: David Dean

Leave a Reply

Your email address will not be published. Required fields are marked *