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. ben says:

    Hi, great site, you have amazing curiosity. I don’t want to insult you but I have a half baked idea that started as a joke, but after talking to a few people its mademe curious and I like to follow things through … the idea that involves iphones powering a UVC lamp… (to kill germs) via the addition of a case. That is an iphone app that uses the devices portability rather than any other feature. With out any knowledge of circuits that an iphone battery could power a 3W DC Lamp … is it that simple? I believe they generate around 1500mAh, which I notice is the same as produced by 4 aa batteries in the specs for this product: http://www.alibaba.com/product-gs/337036900/Portable_UVC_Wand_UVC_Sanitizer.html. It seems the LED technology is available and can be manufactured very cheaply … If yes, what are the power implications etc

    Am I kidding myself, or if I can get the hardware small and light enough, within a practical iphone case, and organise someone to do the app side – ie an interface to switch the lamp on and off, get some cash for some prototypes and get it to market etc etc … in your esteemed opinion, could that be more than half baked?

    Hope I’m not wasting your time –

    regards

    Ben

  2. ben says:

    I sent you a link that wasn’t LED … something like this would be a better component ?
    http://www.alibaba.com/product-gs/486249570/2011_hot_selling_280nm_Germicidal_UVC.html

  3. cameron lowellpalmer says:

    Interested in selling the burned out tunecharger?

    • Hrmm. Well, I do still have it here, in a box. But I really don’t know how much use it will be to you, since I don’t know what’s been burned and what hasn’t.

      But hey, why not. What’s it worth to ya?

  4. conlan rose says:

    I’m doing a similar project to your, making a Ipod/Iphone/phone charger using a 9 volt battery, and a voltage regulator, how do other devices react to the resistors? Like droid phones or reg phones. Also is heat an issue drawing so many amps?

  5. David Dean says:

    I love the enormous capability of what you made – being able to charge a laptop and have so much of your own capacity is a pretty impressive system.

    If you ever find yourself looking for a smaller, simpler system, you should check out the Bright-Bike Revolution. There’s no internal battery, but it’s a terrific USB charger. Plus it’s got an internal protection circuit so it will work through any downhill run (sorry to hear about the TuneCharge).

    In full disclosure, I do work for Bright-Bike, but I thought it was worth mentioning in case you need something smaller for your next trip. It can certainly handle the iPhone or anything else that charges over USB.

    If you have any questions you can email me – david (dot) dean (at) brightbikelabs (dot) com, or check out http://www.brightbikelabs.com.

    – Dave

    • Impressive – all that in 37 grams of weight! I might consider this for my next long-range tour.

      Another few questions for your FAQ:

      – Can it be connected to a small solar panel?
      – How long is the wire? Are the ends stripped?

      • David Dean says:

        Sounds good. Do you have a tour planned yet for 2013? I like the blog and it would be fun to follow. I just got back from a short ride down the Florida Keys, haven’t yet decided on a big trip this summer.

        I’ll also mention that we do a pretty good job with iPhones. You correctly pointed out that the iPhone is particularly picky about what it will charge from, but a few different bits of our circuitry result in a good iPhone charging experience.

        Some answers:
        – Yes, it can be connected to a solar panel. Whatever voltage (AC or DC) is generated will be converted to 5V, and that works for a solar panel just as well as any other power source.
        – The wire is 36″. That’s long enough to mount anywhere on the front half of the bike or in a handlebar bag. Is that enough length for your setup? We are happy to include an extra piece of wire or connect the extension for the user if they’re not comfortable with a soldering iron.

        Thanks,
        Dave

        • Well, the site is changing a bit … I’ve got some time to work on it again, so I’m moving a trip from 2009 (Crater Lake to Idaho) onto the site from elsewhere, as well as a 2011 trip to Australia, and a bunch of day trips or overnight trips from that same era. So those will be new to the site, but not really new. I have a handful of day trips and an overnight trip planned for this summer, but unless a miracle occurs and I get a bunch of time off work in the fall, I won’t be taking any longer trips until the beginning of next year. There is the pie-in-the-sky “trip around the world”, of course, but don’t we all have one of those brewing?? :D

          Thanks for the answers. I wish your product enormous success. :)

      • David Dean says:

        Forgot to mention – yes, the ends are stripped.

Leave a Reply to ben Cancel reply

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