It was time to upgrade the old radio and CD player in our Tacoma. Rather than buy an expensive off-the-shelf unit, I decided to make one myself, using a Raspberry Pi, a touchscreen, and a few accessories.
Parts list:
-Raspberry Pi 4, 4GB
-Sunfounder 10.1 Touchscreen
-USB External Sound Card
-External Microphone
-12V Multifunction Programmable Timer Relay
-12V 4 Channel Isolation Relay
-Ultrawide RPi Camera
-RPi Camera HDMI Adapter
-Scosche Toyota Stereo Wiring Harness Adapter
-TP Link USB Bluetooth Dongle
-Assorted wire, shrink tube, standoffs, mounting hardware solder, etc...
Software:
-OpenAuto Pro, Headunit Interface/Carplay/AA Auto Support
-Custom Python scripts, services running on RPi
Overview:
I designed the headunit to be a full replacement for the stock stereo/radio/CD player. I primarily wanted Carplay and Android Auto Support, plus a large screen for viewing maps. Aftermarket solutions are available, but they are expensive, and most adhere to the "double-DIN" size, with a max size of 4x7". I wanted more screen real-estate, and I enjoy the DIY process!
Wiring:
I used an aftermarket harness that plugs directly into the OEM stereo connector to capture all of the necessary connections to the new unit. This makes it "plug-and-play", which makes it really easy to revert back to the stock system if needed!
Power is captured from a constant fused 12V feed in the OEM connector. I wanted to make sure that the system functioned like a stock car stereo - i.e. when the car is on or in accessory mode, the stereo should be on, when the ignition is turned off the system should shut down.
This is where I ran into the first problem: if I used the direct accessory/ignition power feed, the system would abruptly cut power when removing the key. I wanted to avoid repetitive hard shutdowns on the Raspberry Pi to minimize data corruption or other issues. Additionally, I did not want the Pi to shutdown immediately after the ignition turned off. For instance, if I needed to run some errands, I wanted the system to be on in a "hibernate" mode, so it didn't need to do a full boot upon returning to the car. To facilitate this I used a system of relays and a custom Python script/monitoring service.
The control system is pretty basic, but it was fun to design! Essentially, I use a python script as a service to monitor a GPIO pin that is connected to the 4 channel relay. The relay grounds the GPIO pin when it sees the 12V ignition/accessory feed. When the ignition is turned off, the script sends the Pi into a "hibernate" mode (blanks the screen), and starts a shutdown timer. I currently have the timer set to 30 minutes. After 30 minutes is up, the Pi gracefully shuts down.
I could have left the system alone at this point, but I remembered that the RPi loves to continue to draw power, even when "shutdown". Typical parasitic current draw in a car is anywhere between 40-100mA. My RPi system draws around 50-100mA in the powered off state. Seeing as we love to adventure off-grid in out truck, I didn't want to be stranded with a dead battery! To remedy this, I used an additional relay. This relay was a programmable timer relay that allowed me to cut all power to the system after the graceful shutdown. With this system in place, the Pi gracefully shuts down after 30 minutes with no signal from the ignition/accessory feed, then, a few minutes later, the timer relay cuts all power to the Pi. The relay itself only draws 2mA at idle, so this was a big win!
The rest of the wiring is pretty simple! I use 2 of the other relay channels to trigger GPIO inputs for the reverse camera, and headlights. When shifting into reverse, the system will automatically pull up the reverse cam. When turning on the headlights, the screen will dim for night-time driving.
Audio System:
The audio system is fairly simple as well. I am using a MiniDSP to split the audio output from the USB soundcard to my ADS 6 Channel Amp.