I haven’t made any meaningful changes to the code, but I finally got around to putting the USB hub DED together. I wasn’t able to get the switches for the ports working as inputs for the Arduino; I may work on that again later now that I’ve refreshed a lot of my Arduino knowledge on other projects, but most likely I’ll just leave it as is and that can be an exercise for the reader.
Here’s what the insides of the hub look like:
The Arduino fits nicely over the middle two ports, although you need to trim down one of the edges of two of the buttons in order to let them still be fully pressed.
The button on the left hasn’t yet been trimmed, but the one on the right has, so you can see what the end result will roughly look like. The pencil lines in the above picture show the point by which I needed to stop trimming. To get the exact line, mark the entire visible section of the switch with a pencil while the hub is fully assembled and the button isn’t pressed, and then make sure that you don’t cut away any of the marked section. That’ll minimize the chance that the change is externally observable.
To wire the Arduino in, get a spare microUSB cable and cut it open. The micro end will be used to wire in the Arduino, so make sure you leave at least a couple inches of wire attached to it. The full-size end won’t be used in the final product but is useful for testing that the micro end is properly wired in.
Now, flip over the PCB of the USB hub and it’s time to start soldering.
(Unfortunately I don’t have good pictures of exactly what I did, as the first time through I was too sloppy and the version that I photographed didn’t end up working. In the photos I’m attaching magnet wire to the USB contacts on the PCB, but that was too weak and not flexible enough so I eventually switched to just directly soldering on the wires that came attached to the microUSB connector.)
You can figure out which wire to solder to which contact by plugging in the full-size plug from the disassembled cable. The order of the contacts on the PCB matches the order of the wires that you can see through the hot-glue-like material in the photo, and you can verify the order by checking with a voltmeter to see which wire connects to which contact. Also, the USB cable has a metal sheathing in addition to the four colored wires. This corresponds to the outside of the connector and should be connected to one of the solder points at the very edge of the board, on either side of the 4 primary pins.
(Note: Because of how the circuit is set up, the data lines aren’t 100% isolated from each other, so if you’re using a noise-based resistance check setting like I usually do, you’ll get a bit of a signal even when checking pins that aren’t the same. However, the signal will be much louder when the mapping from wire to contact is correct.)
(Another random note: In the above photo the cable is plugged into the port closest to the hub’s cable, but in reality I used the port furthest from the hub’s cable as that end is a bit less crowded.)
At least in my hub, there’s a cutout in the corner of the PCB that makes it easy to route the cable from the bottom of the board where it’s connected back to the top of the board where the Arduino will be.
(Again, those aren’t the wires I ended up using in the final version). I’d also advise using either superglue or hot glue to reinforce the solder points, as otherwise they’re prone to breaking. (On a related note, while the case is opened, be careful with the hub’s cable; the solder points are pretty weak and I had them break while I was working on it. Due to the spacing and my shaky hands resoldering it was doable but annoying.)
Once you have the wires properly connected, plug the microUSB connecter into the Arduino. (Important note: put a piece of electrical tape on the bottom of the Arduino to prevent it from shorting on the metal ports it’ll be sitting on.) Test that it’s properly connected before closing up the case. You’ll need to hit the button to enable that port of the hub, of course, and you can also use that to disconnect or power cycle the Arduino once it’s in hidden in the case. The other three ports should still be fully functional.
Once you’ve finished putting it all together and you’ve closed the case back up, it’ll mostly look just like the hub always has. There are just a couple ways to tell that something’s different. If you aren’t careful when prying the case open, there’ll be marks in the plastic. In addition, the blue light that illuminates the buttons is slightly obscured by the Arduino board, so that’ll look odd. Lastly, at least in mine the case is ever so slightly bulging and the button presses feel slightly sticky, but both of those could probably be avoided by being a bit more careful and less impatient than I am.