Introduction: Repurpose Optical Drive With RPi
This project came about after my beloved laptop's optical drive started to misbehave. The CD tray would repeatedly pop out whenever I gave my laptop a push or moved it about in any way. My diagnosis of the problem was that there must have been some loose connection which was tripping the eject switch whenever it was moved about. This became more and more irritating and finally, I decided to do something about it. I had only once used the optical drive in the 2 years of having my laptop so I thought I could probably do without it altogether.
Removing the tray meant I had a large hole in the side of my computer so I needed to fill it with something. I had seen that you could buy bays that you can slot a second hard drive into for your laptop. I didn't really have the need for that so instead, I went about designing and 3D printing a replacement blank part with the same dimensions as the original dive, with a space that I could fit passport sized notebook that I kept all my project ideas in. This was a fun little project and conversation starter and worked perfectly. It got me thinking though, that you could probably fit other things into this new found real estate inside my laptop. I thought about what I could put in there instead and realised I could embed a Raspberry Pi inside my computer that I could use for projects on the go and more programmable IO for my computer. As this idea evolved I came up with the idea of powering the Pi form the power provided by the laptop to run the optical drive and connecting to the Pi from my laptop using VNC. This meant that I could access my Raspberry Pi's desktop anywhere without needing all the peripherals that go with it. This Is a bit like the pi-top however, here I am still able to use my laptop as it was originally intended except for the lack of cd drive.
In this Instructable I'll go through how I went about building this project and the problems I encountered and overcame. It won't really be a traditional instructable where I go through every step that should be followed religiously because I think that it is quite niche, as very few people nowadays have removable optical drive bays in their laptop. Instead in this Instructable, I hope to show how I overcame different design problems so that no-one else has to when working on similar projects.
I will provide links to parts and all the 3D files I used, so if anyone does have the exact same laptop (Lenovo ThinkPad T420) or compatible that they can build the project too. If at any specifics are unclear please feel free to comment, and I will happily help out.
Step 1: Parts Used
For this project, only 3 main parts were really needed:
A raspberry pi with a fresh install of NOOBS with right angle pins soldered on. I went with the Pi Zero W for the small form factor and the fact that I wouldn't need any additional networking hardware. As an afterthought, I realised I might have been able to fit a standard sized raspberry pi in there such as the Pi 3 b+ if I desoldered the large connectors like the USB and Ethernet ports.
A 28 x 132 OLED I2C display. This displays the IP of the pi so that you can connect more easily with SSH or VNC. I bought some cheap ones from China because I didn't want to worry about breaking them but you can also get some nicer ones from Adafruit. Luckily the Adafruit library for their product can also be used for the Chinese one.
A male to female slimline SATA cable. This is used to take the power from the laptop. It needs to have all the wires coming from the power section (more on that later).
Step 2: 3D Design
To fit the Raspberry Pi in the slot for the optical drive tray I needed to create something with exactly the same dimensions as the drive. Using a pair of calipers I took down dimensions of the drive and drew a sketch with those dimensions in my CAD software. Here I'm using Onshape, a browser-based tool. It's pretty good and means you don't need to download a load of software on your computer and best of all, it works with Linux. I would, however, recommend Fusion 360 and Instructable's own 3D printing class if you want to get started with this kind of design and your operating system is supported. I extruded the sketch to build up the part to the right dimension and started adding holes to the side where the clips for the drive fit on with screws. Thes clips are super useful because they hold the dive in place but are also removable from the drive so you don't need to redesign them yourself. After having the basic shape I started sketching on the top surface all the holes I wanted to make for the Raspberry Pi, SATA connector, wires, and display. There was still some space left over so I added space to put a breadboard for on the go prototyping. I also made a sketch on the front to extrude, to make space for the display.
I needed to print and adjust my design several times to get it just right and have all the holes in the right places and size. One thing to keep in mind is the tolerance of your printer while designing it so that everything fits perfectly.
I printed mine with about 20% infill and 0.15mm layer height and I have got it just about perfect.
My Onshape files can be viewed here. Or you can just download the STL. This was designed for my Lenovo ThinkPad T420 it probably won't be compatible with most other laptops.
Attachments
Step 3: Powering the Pi
Powering the Pi was probably the trickiest part of the project. The SATA connector on my laptop does not provide the 5V power unless it detects that a device is present. After scouring the web I found the SATA-io revision 2.6 documentation which briefly mentions that for the device to be detected there has to be a 1k resistor between the device present pin and ground. I identified all of the pins with the help of the Wikipedia page and a multimeter. On my cable, it turned out that the two black wires were GND and +5v and the yellow and red were Device Present(DP) and Manufacturing Diagnostic(MD) pins respectively. I cut short the data cable and I didn't need the MD pin so I cut that one as well, and insulated it using heat-shrink tubing. I soldered a 1k resistor between DP and GND, and took the GND side and extended that wire. This left me with just 5v and GND which I soldered directly to the back of the Pi on the two pads behind the power micro USB port.
NOTE:
This is the most dangerous part of the project and I am still amazed that I didn't break my computer doing this. Please make sure that if you are doing anything similar you understand exactly what you are doing otherwise you could easily break stuff.
Step 4: Display
Adding a display to my project was not super necessary, but it does make connecting to the Pi a whole lot easier. I desoldered the pins from the display that came with it and replaced it with some short wires. I then soldered the ends of these wires to the back of the pins on the raspberry pi according to the I2C guide on the adafruit learning system. Soldering the wires to the back was quite tricky as the right angle pins were not easy to get around with a soldering iron. It would have probably been easier to solder the wires to the pins then to solder the pins to the Pi. I compared the length of the wires to the distances in the printed part to make sure the wires were not too long.
Step 5: Putting It All Together and Connecting to the Pi
All there was left to do was set up the Pi. I Plugged it in with all its peripherals (Screen, keyboard and, mouse) and set up VNC according to this tutorial. I then enabled I2C on the raspberry pi with this tutorial. And finally installed all the libraries to run the I2C display from this tutorial. You will notice I am using the example stats.py in my project but I could edit it if I wanted but it's perfect for this application. To get the screen to display stats on startup I added the command to run the stats.py sketch to the bottom of /etc/profile using:
sudo nano /etc/profile
and then added to the bottom:
sudo python /Adafruit_Python_SSD1306/examples/stats.py
save and exit with Ctrl-X, Y, Enter
Now when I restart the pi it displays the stats after a while of booting up. After I had everything working I put it all into the printed part making sure to get the SATA cable the right way around, and slid it into the laptop and it worked.
To connect to the Pi from my laptop with VNC, both computers need to be on the same network. To get the Pi to connect to a network though, I needed to be connected to the pi or using a screen. As I don't want to have to set it up connected with a screen every time I change network I instead have it connected to a hotspot created by my laptop. My laptop is unable to repeat it's internet connection from wifi as it only has one network card. This means what I have to do is set up the laptop's hotspot to connect to the Pi going through VNC, and then get the Pi to connect to some other local network that my laptop can connect to. Once they are both on the same network with internet connection I can reconnect with VNC. And there we have it! I can now work on my Pi connected to the internet from my laptop's interface.
Step 6: Conclusion
This project was a lot of fun to build and I am now happy I have repurposed the wasted space in my laptop for something more useful. I learnt a lot while working on it and I hope it has inspired you to build something similar. If you have any questions, ideas or tips please share them in the comments and I'll make sure to reply.
If you got something useful out of this Instructable would you consider voting for it in the Trash To Treasure contest please :)