Projects

Raspberry Pi Media Centre with KODI

Part 2

Mike Lewis & Daniel Koch

Issue 30, January 2020

This article includes additional downloadable resources.
Please log in to access.

Log in

This month, we complete our media centre with hard drive storage, a suitable power supply and 3D printed case.

BUILD TIME: 2 Hours (Not including 3d Printing Time)
DIFFICULTY RATING: Intermediate

Having introduced you to Kodi and explained the use of the Raspberry Pi to utilise it, it is time to demonstrate our build for the Media Centre, which contains the power supply, hard drive(s), cooling fans, and our USB power distributor and hard drive interface. We’re also describing how to make the case look a bit less 3D-printed, although deadline pressure meant we didn’t get the finish as smooth as we wanted to - but you can!

POWER

The Raspberry Pi series need fairly precise power requirements. If the voltage falls below around 4.8 volts, the Pi will reset. This occurs any time large loads are drawn on a power supply that cannot maintain the current required, and the current available through the USB micro B connection is minimal. The size of the wires involved does not help, and voltage drop can easily occur at larger loads on thinner wires. Additionally, it may be desirable for people to use more than one hard drive. For this reason, a Switch Mode Power Supply (SMPS) board was chosen, which can take a 12V 2.5A input and yield a consistent 5V at 5 amps, although the 12V, 2.5A plugpack we used will allow around 4.7 amps out of the SMPS after efficiencies and losses are accounted for.

CREDIT: POLOLU

Using one HDD from the USB port sometimes generated a low-power warning when running the Pi from its USB micro-B power input. The breakout board presented is constructed on strip prototyping board, and features an input for the SMPS power supply, and pass through for two USB cables. While the original USB standard handles simply parallelling devices, USB 2.0 and USB 3 do not accept this. More interrogation of connected devices goes on in the later standards, and USB hubs have internal circuitry to do so. As such, our design has the data busses connected straight through for each USB connection, with two USB micro cables for two drives, and two USB A cables for connection to two USB ports on the Pi.

There is a common ground for all cables and the power supply, but the +5V wires from the USB A cables (from the USB sockets on the Pi) are left unconnected. The system does not like having 5V externally connected to the USB port on the Pi. Instead, the +5V pins for the drives are connected only to the SMPS. This prevents issues where Drives will power up but not communicate with the Pi, as happens if the +5V from the SMPS is connected to the USB ports on the Pi as well. We have also taken power for the Pi from here. We used speaker wire with PCB Pin sockets to connect to the Pi, and used two GPIO pins each for GND and +5V, to avoid voltage drop on the pin connections.

HARD DRIVE CHOICES & CHALLENGES

You can choose to use internal or external 2.5” drives for this project. If you use internal drives, you’ll need a SATA to USB converter. These devices vary wildly, from some clipping to the back of the drives, to others that more resemble add-on modules for Arduino or Raspberry Pi. Not many of these modules that we found are sold within Australia, so another option which we have seen used is to remove the electronics from the case of a retail-purchased SATA to USB converter. This opens up more local sourcing opportunities. In either case, these converters often need 12V DC. We suggest wiring directly to the controlled side of the power switch.

We have used USB 2.0 Micro B cables, while the hard drives are often supplied with USB 3 Micro B cables, which feature an extension to one side. A USB 2.0 Micro B will fit into a USB 3 Micro B socket. The drive will function as a USB 2.0 device, limited to a mere 480MB/s. That’s still fast enough to stream HD video, and we tortured our test rig without failure. The reason we chose this option was the difficulty in working with the USB 3 cables. This standard can function at 5Gbps, but does so with the addition of five more wires: Two for transmission, two for reception, and one common ground. These wires are tiny, and constantly broke while being stripped. They are incredibly delicate to solder, and a total of nine rows of protoboard meant a lot of exposed cable to stretch the distance down the rows to connect all nine. That, in turn, meant a lot of unshielded cable and difficult wire stripping and soldering, for what was ultimately no real-life performance gain.

Note: Some external drives use other connection types. If this is the case, you’ll have to do your best with the supplied cables. These are not common.

Because of this, while you may be willing to challenge yourself with the cable that came with your external drive, we suggest buying two reasonable quality USB 2.0 A to Micro B cables, and cut these in half instead. In either case, you can trim the length as desired to fit well inside the case. The higher quality cables have thicker wires that are easier to work with. Besides that, you can also make up a cable to power the Pi through the GPIO. To do so without voltage drop, do not use plug-and-socket jumper leads. The connections are too poor and the wire too small. We used speaker cable and PCB pin sockets to do the job, and made two connections to each rail so that a total of four pins share the current, not two. We connected these to the GND and +5V rails of our USB power supply board.

ATTACHING THE HDD

We picked up a pair of WD Elements SE Portable 2TB from JB HiFi. To use a SATA HDD, you would need a USB to SATA adaptor.

Connect your HDD to the Pi. Our HDD came formatted as NTFS, which is supported with this build of Linux, so it’s ready to go.

To load the HDD with your own media, assuming this media is on another computer and you’re a Windows user, simply connect the HDD to your PC and copy the media over as Windows supports NTFS. OS X is not able to write to NTFS but there are software packages available that allow you to write to this file system.

An easier and more convenient approach is to transfer the data onto the HDD over your home network using Samba.

To enable Samba on the Pi (if you didn’t already during the setup wizard) from the Kodi dashboard, click on the settings cog then select LibreELECT.

Scroll down to Services and enable Samba

If successful, you should see the media centre on your home network, and you can copy your files across.

THE 3D PRINTED CASE

The 3D print files are available for download from our website.

CASE BASE

Print time / Filament used: 12 hrs, 25.4m

CASE LID

Print time / Filament used: 9 hrs 15 min, 21.5m

BUTTONS

Print time / Filament used: 6 min, 0.06m

HDD INTERNAL

Print time / Filament used: 3 hrs, 3.8m

Used for internal type 2.5” hard drives. Plate and bracket in one print.

HDD SHELF

Print time / Filament used: 46 min, 1.8m, 0.25mm, no brim.

The shelves to hold external type hard drives. They mount in the HDD Plate. There are four shelves in the .stl, so you only need to run the print once.

HDD PLATE

Print time / Filament used: 1 hr 45 min, 4m

Plate to hold the four shelves for external hard drives.

The case was designed with some flexibility in mind. Because hard drive options vary, we decided to go with a screw-down frame to hold the drives. We have designed two different frames. One holds internal 2.5” hard drives with space between for airflow. This is a single print, which screws down to the floor of the case.

The second frame is a flat plate with slots, into which fit F-shaped shelves. These accommodate different widths and thicknesses of 2.5” external hard drives. The shelves are places around the drive(s) before being lowered into the slots in the plate.

There is enough room above the top drive (unless it’s particularly thick) to pass a rubber band around if you wish to apply tension. This shouldn’t be necessary in most cases. Again, the drives are spaced for airflow.

The hard drive mounting is placed as far forward as possible, leaving plenty of room behind to curl the USB cables around, and, where you can attach the USB power distribution hub. Double sided tape works well for this. We made this flexible again, because different brands of external hard drive have the connections in different places on the back. You can place the power hub where it will not interfere with the USB connections. Incoming power from the SMPS can be laid next to the HDD rack. The SMPS itself mounts out on its own to avoid RF switching noise becoming a problem.

Near this is an empty space. This is for people who are using internal drives and need to mount a SATA to USB converter somewhere. Mounting holes are in all sorts of different locations, and some don’t have any mounting holes. Because of all of this, our recommendation is to use the thick, very sticky, outdoor double sided tape available at hardware stores.

The SMPS unit also has a challenge - it mounts with 2 gauge screws, which are somewhat difficult to get besides a few specialist (read ‘bulk’) suppliers. In order to mount it, we needed to design a clamp system where 4 gauge screws could be used instead. It mounts in a small recess on a raised platform, with screw holes outside this profile.

The Raspberry Pi itself has 3mm mounting holes, and standoffs have been added to the case at the rear corner to enable direct mounting. The Pi PCB mounts close to the rear wall of the case, which has openings to access the HDMI, composite video, and USB Micro-B ports.

The Ethernet connection faces the wrong way to be accessible through the back panel, and as such, a cut-out has been provided at the opposite side of the rear panel. This 2mm-deep recess leaves 1mm of material that will need to be cut with a sharp knife and filed clean if you do need the RJ45 connection. This arrangement ensures the cable has plenty of space to make its 90° bend. Although we intend the device to use Wifi, and the reality is that wifi speeds exceed the available internet performance (actual, rather than specified) in many parts of the country, there are still going to be situations where the ethernet connection is used. You will need to plug in the cable before you attach the lid of the case.

Since the case was now going to be a reasonable size in order to factor in these options and provide flexibility, we decided to make a feature of it and make it look like a DVD player, something some of us have already forgotten even existed. We have a faux drawer moulded into the front, along with a row of four buttons that mount through matching holes. Above these is a hole for a real button, used for power control.

COOLING FANS

Fan cooling is technically optional, but with the possibility of two hard drives and the ability to overclock the Pi, we felt designing them in was essential. Because we already have an incoming 12V supply, this opened up the options. It also raises the possibility of using commercially available computer fan speed controllers if you want to reduce noise. We used thin 40mm fans, and designed a drop-in housing for them. The airflow passes across the width of the case, avoiding the worst of the heat that often occurs at the back of entertainment equipment cabinets.

This is also why we spaced the hard drive mounting options - air can flow under and over the drives from the side. Note that one fan blows in, and one out. We didn’t add a grille to the fans as a finger guard, as we anticipate the unit being on some sort of shelf with only the front readily accessible. The lack of grille will allow maximum airflow, but if you are concerned, the plastic is soft enough to have holes drilled to screw in one of the metal wire fan guards available from the major electronics retailers.

FINISHING THE CASE

While we have used quite a lot of 3D printing in DIYODE projects, we’ve never really done any further finishing. While we primed and painted the legs for the supersized LED, this time we’re going a bit further. We’re going to reduce the appearance of the layers of filament, to make the finish closer to the sheet metal of a DVD player. This will need to occur before any assembly.

Start by sanding any rough spots or protrusions. Sharp corners are a problem for many 3D printers, and the ends of our case walls had excessive rounding where the 0.4mm nozzle had tried to make an exact 90° turn on a 3mm thick wall. These need to be sanded down, and wet-and-dry sandpaper is the choice.

Before you start, drill any screw holes that have not printed properly. The lid has 3.5mm holes to clear the 4G screws, while all screw holes in the base are 2mm ID for the same screws to self-tap into. Also carefully drill any support structure left from the button holes in the front of the case if you need to. If these are not round enough, the buttons will not fit.

For those unfamiliar with the sanding process, it is essential to use a sanding block with some elasticity to even out the pressure of your hands and avoid uneven rubbing. Fingers alone aren’t good enough. Most sandling blocks are made from cork. They’re available from hardware stores. We started with 300-grit sandpaper for the really bad parts of the print, then quickly graduated to 600-grit. Grit numbers in abrasive products are the number of abrasive particles per inch. With the majority of shaping and forming done, finish off with 1200-grit paper. Also rub any as-yet unsanded surfaces with this, to help adhesion in the next stage.

To smooth out the surfaces, we used an automotive spray putty. This product is reasonably self-levelling, even on vertical surfaces, and adheres well to plastics. It does this with some pretty harsh chemicals, however, so apply it in a well-ventilated area, and use appropriate personal protective equipment (PPE). Nitrile gloves are best, and you’ll need a face mask. The cheap paper ones will not do the job - the toxic solvents go straight through. Use one of the thick, multi-layer paper ones with a carbon/charcoal layer in them, a valve on the front, and a rating for agrichemicals and paints. Safety glasses are also advisable, as splash-back would be very unpleasant. You will likely need several coats, so follow the manufacturer’s instructions for drying and recoat times.

After the putty has been applied, sand the surfaces again with 1200-grit sandpaper. If there are thick raised spots in the putty, work on it with 600-grit. You may need to add another coat, but sand first to level as much as possible. Once all coats are done, thoroughly clean the surface, and coat with plastic primer. We chose Dupli-Color products again, as we were very impressed with them during the Supersized LED project. Having said that, any automotive plastic primer should work, but make sure it is a plastic primer. If it just says ‘primer’, it’s probably for metal.

With the primer dry, it’s time to apply the colour of choice. We’re using a silver colour, in line with many 90s DVD players, but you can use any colour you choose. Again, automotive paints work best. We used Dupli-Color Nickel, from the Supersized LED. With the finish dry, there is one last detail. The drawer impression on the front face may be less pronounced now. You can highlight it with a technique model builders will know well: A wash was made with thinned acrylic hobby paint. Often black paint is used, and thinned around 1:10 with water. The mix should definitely be transparent.

Using a fine brush, apply this as neatly as you can to the groove representing the drawer. Immediately afterwards, run a dampened cotton tip over the surface to remove any excess and spill. You should now have a very thin black paint applied only in the grove, which makes it look deeper than it is and returns the sense of detail. In the hobby world, this would be sealed with a clear topcoat, but as no further handling will occur, and we aren’t otherwise using a topcoat, we’ll leave this step.

The Power Distributor Build:

Assemble the USB power distributor first. Cut the USB cables in half, and cut the USB A side to the appropriate length to reach the mounting location. Follow the schematic and Fritzing to connect the D- (white), D+ (green), and GND (black) cables to the board. A couple of holes further along the same row, add the same connections from the Micro-B cable, but remember to add the +5V (red) wire this time.

Repeat this for the other USB cable at the end of the SAME row. This creates common power and ground rails. The problem of the USB connections being in parallel is solved by spot drilling to cut the two tracks between the two separate cables, as shown here.

Now, you can add the connections to the Raspberry Pi. We soldered speaker wire from the power rail, and ran it to reach the Pi. We made a double connection for each pole, using PCB pin sockets, and added heatshrink. Finally, we added wires for the power from the SMPS.

Parts Required:JaycarAltronicsCore Electronics
1 x Raspberry Pi 3B+XC9001Z6302CCE05436
2 x 40 mm Case Fans (10mm thick)XC5054F0010-
1 x 5V 5A Switchmode Power Supply Board--POLOLU-2851
2m x Red Medium Duty Hook-up WireWH3040W2260-
2m x Black Medium Duty Hook-up WireWH3041W2261-
4 x PCB Pin Sockets*HP1260-POLOLU-1930#
1 x Strip board (4 rows x 8 holes min.)HP9540H0714-
2 x USB-A plug to USB-Micro B Plug CablesWC7757P1895A-
1 x Pushbutton SwitchSP0793S0937-
1 x 2.1mm DC Panel Mount SocketPS0522P0622ADA610
12 x 4Gx6mm Screws*HP0550(H1139 9mm)-
1 x 12V 2.5A PlugpackMP3490M8937CCE04425
3D Printer Filament of Choice---
Hard Drive of choice - see text---
Aerosol Automotive Putty---
Aerosol Automotive Paint, colur of choice---

Parts Required:

* Quantity required, may only be sold in packs.

# These are not PCB pin sockets. They are lighter with less contact, and they need to be checked for a good connection when installed.

MEDIA PLAYER ASSEMBLY

Now that you have prepared and painted all the parts of the case, it is time to assemble your media centre. Most of the details have been discussed and photographed, so only a basic assembly procedure will follow.

Start by installing the power socket and switch in the rear and front of the case, respectively. Solder power wires to the input connections on the SMPS board, then anchor it in place. Lay the wires from the USB power distributor, and cut to length. Remove the SMPS again and solder the USB distributor wires to the relevant places on the SMPS board. Solder the other ends of the input wires to the switch, along with the wires for the fans, and SATA to USB converter if you’re using one (if you are, the USB power distributor is likely redundant). Solder wires from the power socket to the other side of the switch.

Now you can install the appropriate hard drive frame for your chosen drive type. The external drive plate mounts before the shelves go on, which need to be placed over the drives first. Both options screw down with 4G x 6mm screws. The same screws are used to mount the USB power distributor to its location, and the Raspberry Pi to its home. Also use 4G x 6mm screws to mount the SMPS connector, although you may need washers. Use nylon ones if you do.

With the hardware installed, tidy the wiring, drop the fans into their brackets (making sure they are blowing axially in the same direction), and insert the USB cables. The last item of physical assembly is to glue in the buttons for the front of the case. That done, press the power switch and check that everything works before easing on the lid and securing it with 4G x 6mm screws. We also added four small self-adhesive rubber feet. You should now have a working Raspberry Pi Media Centre in a versatile case that looks like a piece of ‘90s home theatre equipment.

Note: Last month, we discussed control options for using the media centre. While Kodi supports an app to control it, the keyboard and mouse option will suit some users. Because of the mounting of the USB ports on the Pi inside the case, there is no easy way to install a keyboard.

You could use the cut-out meant for ethernet connections. However, we recommend a wireless option. The USB dongle for this can be installed prior to case closure, and wireless keyboards exist with trackballs or track pads built in. Some are even designed for media centre and smart TV use, with ergonomics on the underside to sit across the legs easily.

TESTING & TROUBLESHOOTING

Once assembly is complete and everything is plugged in, you can test your media centre. With such a simple build on the hardware front, most issues are likely going to be software based. If the Pi itself is not powering up, check power connections from the input socket, all the way through the switch and SMPS board, then on to the USB distributor. Finally, make sure the sockets on the Pi power lead we made up are on the right pins.

If you cannot access files through Kodi, check your hard drive by listening or feeling for the slight vibrations as it spins up. Of course, if you’re using a solid state drive, you won’t hear anything. External drives also usually have a power light.

If you suspect the drive is not functioning, take it out and plug it into a computer to make sure it can be read and that the drive itself is not faulty. Check power to the drive as well, from where the USB cord attaches to the power distributor we made earlier. If the drive is powering up and can be read on a computer, check its formatting aligns with what the Pi and Kodi need.

WHERE TO FROM HERE?

While we haven’t got anything further in mind for this build, that doesn’t mean you can’t. You may have only installed one hard drive, in which case you could install the second for maximum capacity.

You can explore with the app or try a wireless keyboard/mouse arrangement. You could get really brave and see if you can replace the front panel faux buttons with real ones, and program those functions into the Pi. You could also introduce reactive fan speed control, using one of the stand-alone modules meant for PC cases.

Finally, if heat is an issue, you can add one of the dedicated Raspberry Pi self-adhesive heatsinks on the market.

Part 1