Raspberry Pi Carcp

 In-car PCs with multimedia and navigationcapabilities are so cool, but you know how it is, they are oftenfound in luxury, high-end vehicles only. But if you know what you are doing,nothing stops you from making your very own car PC, even if your car does notsupport this type of fancy accessories out of the box. In this episode I willshow you how I turned a Raspberry Pi and a bunch of other components into acustom PC for my car. My name is Kradion and this is Maker's Report. 

Let's face it,there is nothing more annoying than a long road trip without any music. You see,I love my car, but that piece of junk has very poor multimedia capabilities. I canbasically listen to people talk on the FM radio, and load one audio CD. Just one!So, that's not very much. This means no mp3, no auxiliary inputs,no data CDs, no USB, no nothing. None of that. So that's why I decided totake up the challenge and design my own car PC based on a Raspberry Pi. So, firstquestion is: what should this car PC do? And I have identified a few featuresthat I really want to implement in this project. First and foremost, I want thiscar PC to be able to play music and video. Second, I want the car PC toprovide GPS navigation with voice directions. Now, I know, I know, 

I can slapa standalone GPS unit on my windshield, but where's the fun in that? So, we aregoing to do that as well. Third, I want the car PC to be able to poweritself on and off automatically when the engine starts and stops. Next, I wouldlike to implement automatic screen brightness control. I basically would likethat automatically, when I'm driving in full sunlight, the screen gets brighter,so I can read it, and if I enter a tunnel, orit's night, I want the screen to get dimmer and dimmer so it doesn't burn myretinas. I like my retinas. Next, I want the car PCto be able to receive audio via Bluetooth.Basically, I want to turn my entire car into a huge Bluetooth speaker. Last butnot least, very important, I would like to implement some sort of steering wheelcontrols.

 You see, I like safety and I would like to be able to control the carPC without breaking eye contact with the road. Okay, so, now that you know what wewant, let's have a look at the system we're going to build. Let me start by sayingthat this project is quite complex, and I will be leaving out a lot of detail forthe sake of runtime of this video. I will publish a little more on my blog(link in the description) so, if you want to have a chat, or a discussion, or know alittle bit more, see you there, or in the comment section, if you feel soinclined. So, surprise surprise, everything starts with a Raspberry Pi. For thisproject I decided to use a Raspberry Pi 2 model B. Why not the 3? Well, none ofthe functions that I'm going to build actually requires the extra power of theRaspberry Pi 3, so I decided to give the old guy a chance. The Raspberry Pi isconnected to the official seven inch touchscreen display. This device is a biton the expensive side, but totally worth it. 

It is recognized automatically under Raspbian, and both the screen and thetouchscreen are of very very high quality, so, totally recommended,especially for bigger or more complex projects like this one. So, let's have alook at the audio system. As I was mentioning, we need to find a way tobridge the gap between the Raspberry Pi, generating the music, and my car radio,which only accepts FM signal. I have found a very nice component, an FMtransmitter on Adafruit, that can help me bridge this gap. I can basicallyconnect the audio jack of the Raspberry Pi to the input audio jack of the FMtransmitter, and have my music broadcast inside my car onthe FM channel of my choice, but that would be a mistake. Why? Because theRaspberry Pi generates its music using Pulse Width Modulation, or PWM for short.PWM is a very cheap way to generate audio, but it suffers from artefacts, anda humming noise that cannot be removed. I really didn't want to have theseproblems, so I decided to use digital audio. The Raspberry Pi is capable ofgenerating digital audio using what is called I2S, which is a digitalaudio port available on the GPIOs. I bought an I2S DAC, which isbasically a Raspberry Pi sound card, we can say, that takes the digital signaland turns it into a high quality analog representation, and that is what isconnected to the FM transmitter. The GPS subsystem is quite straightforward. Ijust bought a GPS receiver from Adafruit and an active antenna. 

The powersubsystem is a little bit more convoluted. I have found an intelligentswitch on Mausberry Circuits. This switch connects to the 12 Volt power ofthe battery and to the ignition line of the engine. When I switch on the engine,the ignition line goes active and the power switch activates the power to theRaspberry Pi, so the system goes online. That's nice.Then, when I'm done with my driving, the ignition lines disappears and the switchcommunicates this event to the Raspberry Pi using one of the GPIOs.In the Pi, there is a script that monitors this GPIO, and responds by issuing aclean shutdown, so this should give me the functionality I need.Next up, a few extras for convenience. First of all, I want to implement twolight sensors very close to the screen. I basically want to implement a feedbackloop in software where I measure the light intensity hitting the screen andregulate the brightness of the screen accordingly. Next component is aReal-Time Clock, or RTC for short. Next, I have a small USB flash memory where Iwill install program data, such as the maps for the GPS software. Then, I willcertainly need a Bluetooth dongle, if I want to turn my car into a Bluetoothspeaker, and last but not least, I marked here a keyboard, because

 I want to beable to control the car PC with a small keyboard installed as close as possibleto my steering wheel. And last but not least, I've decided to install two panelmounted Ethernet and USB ports. Because why not. Okay, so, the initial problem wasto put music in my car, and this is what I came up with. This is what happens whenI'm left unsupervised for a while. So, now it's the time to put some hardwaretogether. And putting the computer together is probably the funniest part ofthis project. To start we need to hook the Raspberry Pi to the seven inchtouchscreen display. Conveniently enough, this display comeswith an adequate ribbon cable for data and with metal standoffs that arealigned to the mounting holes on the Pi. This will make for a very sturdy boardsandwich. Next up, the audio DAC board goes on topof the Pi, firmly hooked to the GPIO header. For this build,I had already soldered the Real-Time Clock board to the appropriate pins andhooked the wires that will be connected to all other peripherals. And here's thebasic stack in all of its beauty. 

Then, I want to show you this little prototypeboard I made, where I soldered the FM transmitter and the GPS module. I routedthe power supplies and the I2C lines to the top and bottom bus ofthe prototype board, and soldered a few screw terminals for jumper wires. Thisallows me to centralize the distribution of supply voltages and control signalsto all the satellite peripherals. From here on, it's a matter of connecting allother components: the two light sensors, the internal USB stick, the Bluetoothdongle, the GPS antenna, you get the point. I also designed a custom USB keyboard tocontrol the media centre. It's a simple design based on a Adafruit Trinket. theTrinket is an Arduino compatible development board that can be programmedto emulate a USB keyboard, and send valid key codes to the Pi in response tobutton presses. My personal touch was the inclusion of a PSP thumb joystick forcursor navigation. So, time to perform a smoke test... and it seems to work. So, myGPS navigator of choice was Navit. Its user interface is indeed a bit clunky,but I didn't really have much choice under Linux. Navit uses maps I'vedownloaded from OpenStreetMap. Very detailed, highly recommended. My personaltouch was the customizatincel Doneon of the user interface to suit my liking.The choice for the media software fell very naturally on Kodi,former XBMC. My only task there was the customization of the user interface tosuit it to the colour scheme of my car, and to add all the functions that Ineeded, such as launching the GPS navigation, and hopping to a different FMchannel. Okay, time to test the system. I apologize for the reflections on thescreen, but I haven't peeled the plastic off the screen yet, to keep it pristineuntil the final installation. The first functionality I want to explore is thevideo and music playback. I will navigate through the menus using the externalkeyboard to test the steering wheel controls as well. I have loaded a songand a video on the external USB key, and now we'll be playing them. 

The FMtransmitter tuned itself to 89.8 FM. Here, I have tuned theradio receiver of my smart phone to the same frequency, and connected it to thespeakerphone in order to be able to hear the signal. So, without any further ado,let's make some noise. I should be able to freely navigate up and down thehierarchy. Fantastic. So, it seems to work. I can pause themusic, resume it, and stop it altogether. Okay, very good. I was not expecting asuccess, hehe. Let's see if we can do the same with the videos. I can stillnavigate up and down, select the source, and if you are a real fan you shouldknow this one. In the same way, I can pause the video, resumeit, and stop it. Okay, fantastic. So, the point here is that thevideo, music, and steering wheel control seems to work as intended, so we can tickthem off the list. The second function to test is GPS navigation with voicedirections. Now, I'm not going anywhere, but I can launch Navit and set adestination, to see if the navigation started correctly. So, let's push the button. Very good. Now I can set a recentdestination, calculate the route... Fantastic. Okay, so, the user interfacethat I've customized gives me additional information, such as the next turn, thedistance to my destination, the estimated time of arrival, and some other GPS statsfor the geeks. I think we can tick the GPS off the list. In order to test theautomatic power on and off of the carpc, 

I need to install this smartswitch in my car. There is no easy way to emulate this function here in my studio,so, this test will have to wait. Moving on to the automatic brightness control. Thisis a very important feature of my carpc. I don't want to be continuouslyannoyed by a screen that is always too bright to be comfortable, or too dark tobe readable. These two light sensors and a small feedback loop in softwareshould do the trick. To test this function, I have my sun emulator, and I'm about toshine the living hell out of these sensors. This should cause the screen toslowly go brighter and brighter. I don't know if this is visible in the video, but it is definitely getting brighter. Good.So, now I remove the sun and I cover the sensors. The carpc should now think it'snight, or I'm in a tunnel, and should lower the brightness to very low levels. Again, I don't know how visible it is, butthere we go, it's done. Excellent. Another feature has been proven. Last not least: Bluetooth audio. You knowthe drill. The perfect album for the trip is there in your phone, and there is noeasy way to move it to a USB key. This is where Bluetooth comes to the rescue. 

Also, establishing a Bluetooth link between my smartphone and my carpcallows me to use my car as a speakerphone during phone calls, or Skype,or Whatsapp, or whatever cool kids use these days. I have paired my smartphone to my carpc,and I'm about to play some more Pacman's Revenge so, here we go! Fantastic. It seems that all featuresare go. It's time to take a look at my car, and decide where to install thislittle marvel. Okay welcome to my car. So, the question is: where to install my carpc? As you can see my car is a pretty standard car, so there is no place thatis really suitable for this type of installation. In the end I knew I had toinvent something. So, the first idea I got was to reuse the cup holder. I do notneed a cup holder so maybe I could reuse the cavity, install the electronics hereon the bottom, and a screen right sitting on top. This would be very convenient,because very often my arm is resting right here, so it would be convenient fortyping. Problem is, in order to use the device, I would have to look down, whichis dangerous. I don't want to do that. The second idea I got was to install thedevice right there, in front of the clock. I could reuse this cavity for theelectronics, and install an even bigger screen right in front. This wouldbe safe, because while driving the device would be sitting right in front of me.Problem is that it would be quite far to reach. What I decided to do is to reusethe ashtray cavity. 

I am not a smoker, so I do not need the ashtray. So I decided todesign a plastic holder that would sit firmly on the bottom of the ashtray,where I could install all the electronics. I will also have a screenholder that would come at an angle from the bottom of the radio all the way down.In the end I will also have a left plastic wall, and the rightplastic wall, to close this entire area that would be really dedicated to theelectronics of my carpc. But the most important feature of of this arrangementis this cavity that I have here on the back, because in here I can route a powerwire directly from the battery compartment to the car PC, so, the entireinstallation would be pretty invisible. Last thing, 

I would like to have somecontrols of the car PC close to my steering wheel. In the end, I do not wantto look at the PC every time I want to change something, so I was thinking ofinstalling a few buttons, maybe here on the on back of the steering wheel, tocontrol the basic functions of the carpc, and I could route the control wiresfor this keyboard all the way down, reusing the same cavity as the power, sothe entire installation I think would be pretty invisible. So, we have a plan: let's dothis. So, time to have a look at the case. I designed the whole thing in Sketchupunder windows, starting from a single rectangle and extruding all the volumesone by one. In order to get the measurements right, I decided to build a few paper models of each part, and refine them until they fitted my carperfectly, and if I learned something here, is that paper craft is not my art, by along shot. Anyway, I exported the final design tothe Collada format, and sent it to Shapeways for printing. In the end, I wasquite pleased with the result, and I had just a few details to fix here and therewith a Dremel tool, because, believe me not, it does not matter how accurate your papermodel is.

 It isn't. All parts are held together by screws.However, given that I do not really trust the ability of a cheapM2.5 screw to carve a decent thread in nylon, I decided to slot some brassnuts on the interior side of every screw hole. I used epoxy glue, some patience,and I would say a lot of regret every time the glue ended up flooding thethreads, and it happens. The side panels are quite boring, sporting severaluninspired slots for ventilation, and holes for the panel mounted USB andEthernet ports. The front panel was by far the most satisfactory part of thisdesign, with its angles and curves. I really loved it. I'm not a productdesigner, but I am unreasonably proud of this piece of plastic. I also built twolittle glass windows with a plastic bezel to expose the light sensors to,well, light. The funniest part of it, was the face of the DIY store technician when I askedhim to cut me two pieces of glass exactly one square centimetre each. Theguy thought I was making fun of him. As a final step, I can finally install the carpc in my car, starting from the base plate in the ashtray compartment and thescaffolding structure on top. I will attach all other parts to these two, so,they better be solid! Next I need to prepare the panel mountedports and install the GPS and FM transmitter board on the bottom of thehole. Now, I am ready to slot the Raspberry Pi and the screen into place,and this is almost an emotional moment. 

Once done, I can fix the side panels inplace, choose a destination for the GPS antenna, and check if the custom keyboardfits its slot, and spoiler alert: it does. And I'm finally ready to run thislittle thing. So, the computer starts automatically as expected, and thesoftware is fired up as planned. Good! I kind of like the aesthetics ofthe final result. You can see it's a DIY work from a kilometre, but it's stillacceptable to look at. My favourite part are the little windows for the lightsensors. They're kind of cute. So, will it play music on my radio? Good, it works! And the audio quality isbetter than expected. And what about video playback? Excellent. And now, it's time to end this video. Ihad a lot of fun with this project, and I learned a bunch of new things about cars,electronics, design, an even paper craft, which is more than I initially planned.Now, if you'll excuse me, I'll go play with my new carpc based on Raspberry Pi.My name is Kradion and this was Maker's Report.