<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://bitzero.tech/feed.xml" rel="self" type="application/atom+xml" /><link href="https://bitzero.tech/" rel="alternate" type="text/html" /><updated>2026-10-07T21:30:07+00:00</updated><id>https://bitzero.tech/feed.xml</id><title type="html">Bitzero Blog</title><subtitle>I&apos;m Jacob. I&apos;m a software developer and cybersecurity student.
</subtitle><author><name>Jacob Schooley</name></author><entry><title type="html">Adding wired audio to a Tesla with TeslAux</title><link href="https://bitzero.tech/posts/2026/10/07/teslaux" rel="alternate" type="text/html" title="Adding wired audio to a Tesla with TeslAux" /><published>2026-10-07T00:00:00+00:00</published><updated>2026-10-07T00:00:00+00:00</updated><id>https://bitzero.tech/posts/2026/10/07/teslaux</id><content type="html" xml:base="https://bitzero.tech/posts/2026/10/07/teslaux"><![CDATA[<p>Why don’t newer cars come with an aux port? I wish I knew the answer. It seems like it would be so cheap for every car to have one. Sure, just about everyone has a phone with Bluetooth, but there are some situations where you don’t want to use Bluetooth. For example, streaming hi-def audio through Plexamp, or especially relevant to Teslas, watching a movie at a supercharger on an iPad (or <a href="https://screenmate.co/">screenmate</a>) because you can’t run a VPN on the Tesla’s infotainment and don’t want to open your Plex server to the world.</p>

<p>I was looking for a way to get wired audio into a Model Y and noticed Tesla sells a mic called the Caraoke Mic. This is a gimmicky little thing allowing passengers to sing karaoke. I got a cheap clone mic and it’s actually pretty fun. The mic comes with a receiver that connects to the glovebox USB port, and I started thinking, would the car accept USB audio from another source?</p>

<p><img src="/assets/images/2026-10-07-teslaux/caraoke-mics.png" alt="caraoke-mics.png" /></p>

<h3 id="ai-can-just-do-stuff">AI can just… <em>do stuff</em></h3>

<p>A few years ago I built a LIN Bus interceptor for my Rav4. The software for that took months worth of 1 AM coding sessions sitting in my car to build. Now, AI and vibecoding have made this process much faster. I do sometimes miss typing code myself and building every component by hand. But you just can’t beat the efficiency gains from AI.</p>

<p>For this project, for example, I would have had to learn and understand a whole bunch of intricate details surrounding the USB connection process to reverse engineer it. While that sounds like a fun project, I simply don’t have the time for that between my job, playing in my band, sleeping enough to stay alive, and attempting to have some sort of a social life. AI being able to just do things like that makes it so I can come up with something I want to build, work out the high level details, and hand over all the slow menial stuff to an agent while I work on other projects or my actual job.</p>

<h3 id="what-is-teslaux">What is TeslAux?</h3>

<p>So TeslAux came from this idea that surely, if a Tesla will accept wired audio in from a mic, it will accept audio from anything else that pretends to be a mic. This turned out to be true. All it required was reverse engineering the USB descriptors of the mic that were whitelisted by the car and programming another USB device to look like that mic. This used to be easier said than done, but this time all that was required was a Heltec T114 board I had sitting around from another project, an ST-Link connected to the T114, and the mic plugged into my laptop. I told Claude to make it work and before long I had a sine wave playing through the car’s speakers.</p>

<p>What the mic looks like:</p>
<ul>
  <li>VID 0x1235, PID 0x0002, and the manufacturer, product and serial strings. The serial is 40 bytes, which makes the string descriptor 162 bytes — a 128-byte control buffer silently breaks enumeration.</li>
  <li>Four interfaces: AudioControl, AudioStreaming, and two HID interfaces.</li>
  <li>IF2 is a HID keyboard with the standard 65-byte boot-keyboard report descriptor. Not telemetry, as was assumed for months — the mic’s button sends keystrokes.</li>
  <li>IF3 is an endpoint-less vendor HID, usage page 0xFF00, usage 0x55AA, with an exact 36-byte report descriptor and an 8-byte Feature report reading 00 01 00 03 03 00 08 00. The car writes A5 5A-framed configuration to it and validates what comes back. Cloning it byte for byte defeats the “invalid mic” popup.</li>
</ul>

<p>I guess it wasn’t just as simple as telling Claude to make it work and coming back to it working perfectly after the first prompt. Audio sounded really garbled at first and I had to steer it to fix timing issues. Without that IF3 interface, it works for about a minute before an “invalid mic” popup is thrown and the car disconnects from the device.</p>

<p>After that, I had to find a way to get actual audio into the system. The T114 can’t handle processing audio input, so I went with RP2040-Zero boards. <a href="https://www.amazon.com/10Piece-Microcontroller-Development-Dual-core-Processor/dp/B0C5Q2V49P">These things are so cheap.</a> It turns out there isn’t a single cheap, tiny board out there that has 2 USB ports that can both operate as audio devices. The closest to that are dual-USB RP2350 boards, but the second USB port is PIO and nobody’s written a driver to use that as an audio device (I did try and haven’t been able to get it working yet). So the best solution is 2 RP2040-Zero boards placed back to back with their edge pads soldered together.</p>

<p><img src="/assets/images/2026-10-07-teslaux/board.jpg" alt="board.jpg" /></p>

<p>One board connects to an audio source and identifies as a USB audio sink. Pretty much any modern tech will see it and output audio to it. It converts this audio stream into I²S and sends it over those edge pads. The other board identifies as a Caraoke Mic, then listens for that I²S stream and sends it as mic audio. The Caraoke Mic’s effects are processed on the mic receiver, which works great for us because it means the car plays exactly what is pumped in through that input. Latency is about 8 ms through both boards, due to USB frame quantisation and enough buffer to cover one packet at each hop.</p>

<h3 id="some-issues-i-unfortunately-cant-fix">Some issues I unfortunately can’t fix</h3>

<p>While this setup does work, it did uncover some issues that are on Tesla’s end to fix. It would be nice if they got around to just accepting USB audio natively at some point, but I have no idea how to get ahold of someone at Tesla who would have enough influence to do anything about it.</p>

<p>First off, Tesla’s audio processing chain adds around 130ms of latency. This applies to any source, including audio in the browser and FM radio. While this is much better than Bluetooth’s delay, it still isn’t low enough for playing instruments in the car, which I was really hoping to do. In fact, if you watch a Caraoke Mic demo video, you’ll notice the delay there too. I’m surprised they just decided not to reduce that delay considering they sell a product that would really benefit from it.</p>

<p>Tesla also added “anti-howling technology” to the mic, and that appears to manifest as limiting system volume to 60% while the mic is connected, which makes sense for avoiding feedback with a mic but just gets in the way here. It’s glitchy though. If a mic is connected while volume is over 60%, volume doesn’t limit until the driver tries to change it. I added a feature in the car board firmware where if the boot button is held, it disconnects the mic from the car, then reconnects when let go, and this works for turning the volume up, but means you can’t change volume and keep it high without holding the button again, and you can’t hide the device behind the dash. This is frustrating when watching movies with quiet dialog, and since it affects system volume, the device must be disconnected to turn it up just for music.</p>

<p>And one last major issue, when the mic is connected (either Caraoke Mic or TeslAux) there’s noticeable popping sounds in the audio chain, and these popping sounds affect all system audio including built in streaming and even system sounds like shifter and object detection noises.</p>

<p>Overall, it was pretty cool building what I believe to be the first working aux in system for Teslas. I would love to get ahold of Tesla engineering and have them fix these issues and officially support USB audio in without having to fake the official mic, but I don’t even know where to start with that.</p>

<p><img src="/assets/images/2026-10-07-teslaux/teslaux.jpg" alt="teslaux.jpg" /></p>

<h2 id="another-potential-way-to-get-audio-in">Another potential way to get audio in</h2>

<p>One other route I might explore in the future is the FM tuner. It’s a box mounted in the back somewhere that sends its audio to the MCU via automotive Ethernet. There is a <a href="https://teslamotorsclub.com/tmc/threads/factory-oem-siriusxm-nearly-working-in-tesla-2022-model-3.271704/page-44">TMC forum thread</a> where people have swapped their radio tuners for boxes with SiriusXM built in, and from what I can tell, it simply works when you swap in the box. This suggests that encryption over that Ethernet line is probably nonexistent, that it’s likely possible to replace the tuner or intercept the line to inject audio, and that it might even be possible to add another arbitrary “Aux” source (if the SiriusXM source and listings are set by the tuner instead of the MCU). This, however, would be much more challenging than the mic emulator. Automotive Ethernet transcievers are pricey and I’d have to make a wiring harness to plug one into the MCU without losing connection to other controllers. And injecting audio this way would fix the popping and volume issues but not the latency.</p>]]></content><author><name>Jacob Schooley</name></author><category term="car hacking" /><category term="reverse engineering" /><category term="hardware" /><summary type="html"><![CDATA[A dirt cheap device to give Teslas the low-latency aux input they should've come with]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitzero.tech/assets/images/2026-10-07-teslaux/teslaux.jpg" /><media:content medium="image" url="https://bitzero.tech/assets/images/2026-10-07-teslaux/teslaux.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Rooting an old MiFi hotspot</title><link href="https://bitzero.tech/posts/2026/08/09/hotspot-5510-root" rel="alternate" type="text/html" title="Rooting an old MiFi hotspot" /><published>2026-08-09T00:00:00+00:00</published><updated>2026-08-09T00:00:00+00:00</updated><id>https://bitzero.tech/posts/2026/08/09/hotspot-5510-root</id><content type="html" xml:base="https://bitzero.tech/posts/2026/08/09/hotspot-5510-root"><![CDATA[<p>Back in high school I got ahold of a Verizon MiFi 5510L mobile hotspot. It came in handy for my hour-long bus ride home from school. One day I ran the updater package to update the firmware and discovered it opened a serial port on the device, which exposed a user-level shell. Poked around and it turns out there was a world-writable script executed by root on reboot, so an edit to that file to change the root password opened the door.</p>

<p>I had a few people ask me about it on reddit back then and this is what I would DM them:</p>

<hr />

<p>To get root on the Mifi, download <a href="https://web.archive.org/web/20211027085614/http://production.5510.verizon.mifiupdates.com/Windows/MiFi5510LWin_updt.zip">this DUU</a>. Plug it in on charge mode, run the DUU and have it verify the device. The mifi will reboot into debug mode. Now unplug the mifi, force quit the DUU, plug it back in and check device manager for the COM port.</p>

<p>Open PuTTY and connect to that com port, login with guest (does not have a password by default but you might want to set one), and run these commands: (change TestPassword to whatever you want)</p>

<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cat</span> /opt/nvtl/bin/nvtl_radvd.sh <span class="o">&gt;</span> /tmp/nvtl_radvd.sh
<span class="nb">sed</span> <span class="nt">-i</span> <span class="s1">'85 a echo -e "TestPassword\\nTestPassword" | passwd root'</span> /tmp/nvtl_radvd.sh
<span class="nb">cat</span> /tmp/nvtl_radvd.sh <span class="o">&gt;</span> /opt/nvtl/bin/nvtl_radvd.sh
</code></pre></div></div>

<p>Now turn it off and back on, it should stay in debug mode, connect to it in PuTTY and login with root and the new password. Keep that line in /opt/nvtl/bin/nvtl_radvd.sh because sometimes it will reset the password and you want it to change to yours every time it gets rebooted.</p>

<hr />

<p>That hotspot is long gone, but it kickstarted my interest in exploiting and repurposing embedded devices. Feel free to try this if you happen to have a 5510L sitting in a drawer somewhere. I doubt it’ll be patched at this point considering the latest firmware was released in 2014.</p>]]></content><author><name>Jacob Schooley</name></author><category term="embedded devices" /><category term="hardware" /><category term="exploit" /><summary type="html"><![CDATA[10 years ago I found an exploit on a Novatel/Verizon MiFi 5510L hotspot]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitzero.tech/assets/images/2026-08-09-hotspot-5510-root/mifi.jpg" /><media:content medium="image" url="https://bitzero.tech/assets/images/2026-08-09-hotspot-5510-root/mifi.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Hacking My Car’s Climate Controls, Part 3: PCB Design</title><link href="https://bitzero.tech/posts/2026/06/03/hacking-my-cars-climate-controls-part-3" rel="alternate" type="text/html" title="Hacking My Car’s Climate Controls, Part 3: PCB Design" /><published>2026-06-03T00:00:00+00:00</published><updated>2026-06-03T00:00:00+00:00</updated><id>https://bitzero.tech/posts/2026/06/03/hacking-my-cars-climate-controls-part-3</id><content type="html" xml:base="https://bitzero.tech/posts/2026/06/03/hacking-my-cars-climate-controls-part-3"><![CDATA[<p>I’ll admit, I do not enjoy writing as much as I enjoy building things. Over the last 3 years since my last post on this project, I’ve started working full time, graduated from BYU with a degree in Cybersecurity, moved across town, <a href="https://www.instagram.com/tstreet.band">started a band</a>, and built a ton of software and hardware to make my life easier.</p>

<p>But I did say I was going to design a custom board for this project, and I presented it at the BYU Cybersecurity Conference in February 2024. It is still in my car and continues to work great. I didn’t use it much this last winter, given the extreme lack of snow, but now it’s crazy hot outside and I often leave it in L2 mode which sets the AC to max when the car’s started.</p>

<p>The board is a much more compact version of the prototype I built in Part 2. It is designed as a backplane that attaches to an Arduino Mega 2560 Pro Mini, the smallest Arduino I could find at the time that had 2 hardware UARTs. It has a power module, 2 LIN transcievers, and a Molex connector that attaches to a custom wiring harness that plugs into both the car’s and panel’s connectors. (Please leave a comment if you know of a good source for custom built wiring harness as this harness was a nightmare to build by hand.)</p>

<p>I designed the board using EasyEDA and used JLCPCB to manufacture it. As someone who had never manufactured a PCB before this, it turned out to be easier than I thought to turn a schematic into a PCB into a physical, functional product.</p>

<p><img src="/assets/images/2026-06-03-hacking-my-cars-climate-controls-part-3/board.jpg" alt="Board" /></p>

<p><img src="/assets/images/2026-06-03-hacking-my-cars-climate-controls-part-3/arduino.jpg" alt="Arduino" /></p>

<p>And a size comparison of the board to the prototype. The prototype worked but required removing a few panels to get it installed. The new board is small enough to fit through the little hole behind the climate control panel without having to unscrew other stuff.</p>

<p><img src="/assets/images/2026-06-03-hacking-my-cars-climate-controls-part-3/case.jpg" alt="Case" /></p>

<p><a href="https://github.com/jbschooley/ToyotaLinInterceptor/tree/main/Board">Board</a> and <a href="https://github.com/jbschooley/ToyotaLinInterceptor/tree/main/Case">case</a> files can be found on this project’s GitHub repo. I can’t guarantee all the parts I used are still available, but you are welcome to import the design files into your PCB design software of choice and modify as needed.</p>

<p>I discovered during this process that I am not a fan of hardware design and will probably stick to software development as a career. When developing software, I can compile and run my current code in seconds to see if it works. With hardware, I have to spend money ($50 for this project per iteration, and this was before tariffs), then wait 3 weeks for the board to be built and shipped, then test it, and if it doesn’t work, I have to throw it out, spend more money, and wait another 3 weeks. Instant gratification really is my weakness. But I am glad I went through this process and figured it out. Since then, I have built more hardware for other projects, because sometimes it’s the only way to get the functionality you need.</p>]]></content><author><name>Jacob Schooley</name></author><category term="car hacking" /><category term="hardware" /><category term="personal projects" /><summary type="html"><![CDATA[Designing a custom PCB to make my LIN interceptor more compact and easier to install.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitzero.tech/assets/images/2026-06-03-hacking-my-cars-climate-controls-part-3/board.jpg" /><media:content medium="image" url="https://bitzero.tech/assets/images/2026-06-03-hacking-my-cars-climate-controls-part-3/board.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Hacking My Car’s Climate Controls, Part 2: Building the Interceptor</title><link href="https://bitzero.tech/posts/2023/04/06/hacking-my-cars-climate-controls-part-2" rel="alternate" type="text/html" title="Hacking My Car’s Climate Controls, Part 2: Building the Interceptor" /><published>2023-04-06T00:00:00+00:00</published><updated>2023-04-06T00:00:00+00:00</updated><id>https://bitzero.tech/posts/2023/04/06/hacking-my-cars-climate-controls-part-2</id><content type="html" xml:base="https://bitzero.tech/posts/2023/04/06/hacking-my-cars-climate-controls-part-2"><![CDATA[<p>We’ve had an incredible winter and Utah this year. Storm after storm have been blessing us with an unforgettable season of back to back powder days, making all that money I spent on my ski pass totally worth it.</p>

<p>As much as I would like to have my favorite resort to myself, that isn’t realistic. Everyone in the general Salt Lake area has to compete for their share of untouched pow. And for me, being over an hour away without traffic, that means I have to wake up way too early to even have a chance at a parking spot. If my car is covered in snow, the 10 minutes I’d have to wait for the defroster to kick in and melt it off the windshield can be the difference between parking right next to the lift or parking on the side of the road a mile away. Anyone who has hiked in ski boots before knows that is definitely not an ideal way to start the day.</p>

<p>This has made it imperative that I find time between classes and my job to finish this project. It’s really nice walking out to my car and only having to brush off the already melted snow before I can pick up the boys and head to the mountains. And once summer rolls around, I won’t burn to death getting into my car if I’d forgotten to turn the AC on before I left.</p>

<p>I’m on a college student budget (and already spent all my money on ski gear), and part of the reason I’m posting this is to show that DIY hardware doesn’t have to be expensive, and that, even on a very limited budget, you can make some really cool stuff. Feel free to replace parts with better more expensive ones, or even design a custom PCB if you have the knowledge for that (and please let me know if you do as I would love to use it)!</p>

<h3 id="materials">Materials</h3>

<h4 id="parts">Parts</h4>
<ul>
  <li>Arduino Mega <a href="https://www.amazon.com/ARDUINO-MEGA-2560-REV3-A000067/dp/B0046AMGW0/">amazon</a> <a href="https://www.aliexpress.us/item/2251832678521697.html">aliexpress</a> <a href="https://www.aliexpress.com/w/wholesale-arduino-mega.html?SearchText=arduino+mega">search</a></li>
  <li>Mikroe LIN Shield for Arduino Mega <a href="https://www.mikroe.com/arduino-mega-click-shield">mikroe</a> <a href="https://www.mouser.com/ProductDetail/932-MIKROE-1900">mouser</a></li>
  <li>2x Mikroe LIN Click <a href="https://www.mikroe.com/lin-click">mikroe</a> <a href="https://www.mouser.com/ProductDetail/Mikroe/MIKROE-3816?qs=Cb2nCFKsA8qi3nKltYdgQw%3D%3D">mouser</a>
    <ul>
      <li>Alternatively, you can use the ATA663254 click as it includes a 5V regulator. 2 of these in parallel should be able to power the Arduino, eliminating the need for the car charger. <a href="https://www.mikroe.com/ata663254-click">mikroe</a> <a href="https://www.mouser.com/ProductDetail/Mikroe/MIKROE-2872?qs=f9yNj16SXrJrtHOXHs2kUA%3D%3D">mouser</a></li>
    </ul>
  </li>
  <li>Toyota connectors 90980-12369 and 90980-12370 (get 2 of each because thye’re easy to break) <a href="https://www.aliexpress.us/item/3256803593976654.html">aliexpress</a></li>
  <li>Protoboard (insert size)</li>
  <li>Dollar store USB car charger</li>
  <li>18-20 gauge wire</li>
  <li>Gorilla mounting tape (or 3M VHB tape) <a href="https://www.amazon.com/Gorilla-Heavy-Double-Sided-Mounting/dp/B082TQ3KB5/">amazon</a></li>
</ul>

<h4 id="tools">Tools</h4>
<ul>
  <li>Soldering kit. Get a good one with a temperature dial; if you try to use a cheap soldering iron from Walmart, you’ll end up very frustrated very quickly. These are expensive so you may want to borrow one. <a href="https://www.amazon.com/Weller-Digital-Soldering-Station-WE1010NA/dp/B077JDGY1J/">amazon</a></li>
  <li>Extraction tool for removing wires from connectors (I used a breadboard pin, but they break easily so I wouldn’t recommend it)</li>
  <li>Trim removal tool <a href="https://www.amazon.com/XBRN-Removal-Window-Fastener-Remover/dp/B07R44VJHN">amazon</a></li>
  <li>Digital multimeter <a href="https://www.amazon.com/Crenova-Auto-Ranging-Multimeter-Measuring-Backlight/dp/B00KXX2OYY/">amazon</a></li>
</ul>

<h3 id="building-the-interceptor">Building the Interceptor</h3>

<h4 id="step-1-assemble-the-mikroe-lin-shield">Step 1: Assemble the Mikroe LIN Shield</h4>

<p>The LIN shield comes with header pins that are not attached, so you will need to solder the ones that you’ll be using. You do not need to solder all of them. Solder pins for:</p>

<ul>
  <li>ground</li>
  <li>5V</li>
  <li>serial RX and TX</li>
  <li>the enable pins for both LIN clicks</li>
</ul>

<p>If you aren’t a soldering expert, you may want to use your multimeter to check continuity between the pins and the click headers.</p>

<p><img src="/assets/images/2023-04-06-hacking-my-cars-climate-controls-part-2/arduino-with-click-shield.jpg" alt="Arduino with click shield" /></p>

<h4 id="step-2-solder-jumpers-on-the-lin-clicks">Step 2: Solder jumpers on the LIN clicks</h4>

<p>The basic LIN click has a jumper for selecting Responder or Commander mode. It comes with the Responder position selected. On one of your clicks, you will need to solder the jumper to the Commander position. This click will be the one that will be sending the messages to the car. The other click will be the Responder click, and will be receiving the messages from the car. You can also remove the 3.3V jumper and solder it to the 5V position, but this is not necessary as the Arduino will output 3.3V for the clicks to use.</p>

<p>If you get the ATA663254, you will need to solder the 5V jumper on both clicks and the L-PULL jumper on the click that will be used as the Commander.</p>

<p><em>Note: While the official terms for LIN device roles have been changed to Commander and Responder, most documentation, including the documentation for these LIN clicks, still uses the terms Master and Slave.</em></p>

<h4 id="step-3-take-apart-your-dollar-store-car-charger">Step 3: Take apart your dollar store car charger</h4>

<p>If using the ATA663254, you can skip this step. Otherwise, you will need to take apart your car charger and solder wires for 12 V, 5V, and ground to it.</p>

<h4 id="step-4-prepare-the-toyota-connectors-and-wires">Step 4: Prepare the Toyota connectors and wires</h4>

<p>Remove wires from your Toyota connectors. You’ll need an extraction tool or a perfectly sized pin to get them out, and these connectors are very finicky and easy to break. I would suggest buying a second set of connectors because they’re cheap.</p>

<p>You will only need 10 wires total. Label 2 wires each as:</p>

<ul>
  <li>12V</li>
  <li>Ground</li>
  <li>LIN</li>
  <li>Illumination+</li>
  <li>Illumination-</li>
</ul>

<p>Don’t insert them back into the connectors yet. It’s easier to solder them first.</p>

<h4 id="step-5-solder-everything-together-on-the-proto-board">Step 5: Solder everything together on the proto board</h4>

<p>The best way I found to set up the proto board is by soldering pins to it so that it takes up the 3rd click slot on the shield. This way, you can keep everything attached to the Arduino rather than having to find another place to mount the proto board.</p>

<p>Some connections can be made without the board, but having a central connection area simplifies things a bit.</p>

<p>You want to connect the following:</p>

<ul>
  <li>All grounds, including the Arduino ground, both LIN grounds, the car charger ground, and ground from both connectors</li>
  <li>All 12V, including the Arduino 12V, both LIN 12V, the car charger 12V, and 12V from both connectors</li>
  <li>The car charger 5V to a 5V pin on the Arduino</li>
</ul>

<p>The rest of the connections can be made directly, but connecting them through the proto board allows for cleaner wiring:</p>

<ul>
  <li>Illumination+ and Illumination- from both connectors (these are direct and do not pass through the Arduino)</li>
  <li>LIN from the car connector to the Responder LIN click</li>
  <li>LIN from the panel connector to the Commander LIN click</li>
</ul>

<div class="image-row">
  <img src="/assets/images/2023-04-06-hacking-my-cars-climate-controls-part-2/assembled-1.jpg" alt="assembled view 1" />
  <img src="/assets/images/2023-04-06-hacking-my-cars-climate-controls-part-2/assembled-2.jpg" alt="assembled view 2" />
</div>

<p>Then all you have to do to build it is plug the clicks and proto board into the click shield and insert the appropriate wires into the screw terminals on the LIN clicks.</p>

<p><img src="/assets/images/2023-04-06-hacking-my-cars-climate-controls-part-2/device.jpg" alt="Assembled device" /></p>

<h4 id="step-6-test-every-connection-with-your-multimeter">Step 6: Test every connection with your multimeter</h4>

<p>Remember, you’re dealing with your car’s electrical system. Electrical problems in cars, especially newer ones, can be very expensive to fix, so it’s best to be safe. Make sure that you have continuity between all of your connections and that you have no shorts. If you have a short, you will need to find it and fix it before continuing.</p>

<h4 id="step-7-flash-the-arduino">Step 7: Flash the Arduino</h4>

<p>Clone <a href="https://github.com/jbschooley/ToyotaLinInterceptor">jbschooley/ToyotaLinInterceptor</a> and push it to your Arduino. I use CLion with the <a href="https://docs.platformio.org/en/latest/integration/ide/clion.html#installation">PlatformIO</a> plugin. You may be able to use another IDE, but I haven’t tried it.</p>

<h4 id="step-8-plug-it-in-and-test-it">Step 8: Plug it in and test it!</h4>

<p><a href="https://www.youtube.com/watch?v=eL141juGyrM">Remove the climate control panel</a>. Unplug it from the car and attach the interceptor between the panel and the car. Plug it back in and turn the car on. If everything is working, you should see the panel light up and the climate control buttons should work. By default, there won’t be a preset configured, so hold down the S-Mode button for a second, then turn the driver’s temperature knob to the right to set a preset.</p>

<p>If everything works, install it behind the dash. You may want to <a href="https://github.com/jbschooley/ToyotaLinInterceptor/tree/main/Case">3D print a case</a> so it doesn’t touch anything it’s not supposed to and short itself out. This case <em>barely</em> fits behind the dash, and it was a pain to get it in, but it does fit.</p>

<div class="image-row">
  <img src="/assets/images/2023-04-06-hacking-my-cars-climate-controls-part-2/inside-case.jpg" alt="Inside 3D printed case" />
  <img src="/assets/images/2023-04-06-hacking-my-cars-climate-controls-part-2/installed.jpg" alt="Installed behind dash" />
</div>

<h3 id="software">Software</h3>

<p>The software is written in C++ and uses the <a href="https://www.arduino.cc/">Arduino framework</a>. I’ve tried to keep things as simple as possible and keep things modular so that it’s easy to add new features. You’ll notice that all code is kept in .h files. No, this isn’t best practice, but it made development a bit easier and the difference in compile time by keeping implementation code in .cpp files was negligible.</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">Button.h</code> - handles state for a button on the climate control panel and triggers actions on press, hold, and release
    <ul>
      <li><code class="language-plaintext highlighter-rouge">Menu.h</code> - holding the S-Mode button will replace the driver’s temperature display with a preset menu. Turning the driver’s temperature knob will cycle between presets, and the preset will be saved when the button is released. Presets are displayed as L1, L2, etc. on the display. (Why L#? Because I had to pick from the text the panel was configured to display, and I figured those were the least likely to be seen during normal operation. I think the car can display up to L32.) If new presets are added, increment the <code class="language-plaintext highlighter-rouge">numPresets</code> constant.</li>
      <li><code class="language-plaintext highlighter-rouge">Toggle.h</code> - holding the Eco button will toggle the preset on and off. The display will toggle between the preset number and <code class="language-plaintext highlighter-rouge">OFF</code> when the button is held.</li>
      <li><code class="language-plaintext highlighter-rouge">OffButton.h</code> - turns off the rear defroster when the Off button is pressed.</li>
    </ul>
  </li>
  <li><code class="language-plaintext highlighter-rouge">LINController.h</code> - handles low-level sending and receiving messages on the LIN bus</li>
  <li><code class="language-plaintext highlighter-rouge">Handler.h</code> - handles state for reading and writing messages on the LIN bus and ensures received messages are validated before being processed.
    <ul>
      <li><code class="language-plaintext highlighter-rouge">CarHandler.h</code> - handles reading, forwarding, and responding to messages from the car</li>
      <li><code class="language-plaintext highlighter-rouge">PanelHandler.h</code> - handles sending data and requests and responding to messages from the panel</li>
    </ul>
  </li>
  <li><code class="language-plaintext highlighter-rouge">DataStore.h</code> - stores data received from the car and the panel and handles reading and writing to EEPROM</li>
  <li><code class="language-plaintext highlighter-rouge">Modifier.h</code> - used to modify intercepted data before it’s forwarded. This includes modifying temperature, fan speed, and buttons pressed.</li>
  <li><code class="language-plaintext highlighter-rouge">Preset.h</code> - defines how a preset is applied
    <ul>
      <li><code class="language-plaintext highlighter-rouge">PresetMaxDefrost.h</code> - turns on front and rear defrosters, sets fan speed to high, sets temperature to max, and turns off eco mode and S-Mode</li>
    </ul>
  </li>
  <li><code class="language-plaintext highlighter-rouge">PresetController.h</code> - handles applying the correct presets. This is where you can add new presets.</li>
  <li><code class="language-plaintext highlighter-rouge">Timer.h</code> - a debug timer that can be used to measure how long it takes to process a message. It’s not used in the final code, but it’s useful for debugging.</li>
  <li><code class="language-plaintext highlighter-rouge">Logger.h</code> - a debug logger that can be used to log messages to the USB serial port. Loggers are disabled unless necessary for debugging because log output is incredibly slow and causes the Arduino to miss messages on the LIN bus.</li>
</ul>

<p>I’ve tried my best to keep things organized, but my code is definitely not perfect. I’m open to suggestions and pull requests.</p>

<p>More detailed documentation can be found in the <a href="https://github.com/jbschooley/ToyotaLinInterceptor">source code</a>.</p>

<h3 id="possible-improvements">Possible Improvements</h3>

<p>This project is far from perfect, and there are some things I would like to improve in the future.</p>

<p>I would like to be able to have the preset always activated if I use the remote starter to start the car. It’s easy to forget to turn it on before parking for the night and then it doesn’t work in the morning. I probed every wire in the remote starter connector and couldn’t find anything that would indicate whether the car was started with the remote starter or not, but there’s got to be a way to do it.</p>

<p>One possibility is that messages are sent over the CAN bus when the remote starter is used. Reading these messages would require a CAN transceiver, and there currently isn’t space on the click shield unless I want to reposition the proto board and rewire everything. I would also have to tap into CAN wires somewhere, which means I’d have to buy more connectors. I’m not sure if it’s worth it.</p>

<p>I could also wire up the other output from my car’s tracking device to the Arduino and have it watch for a pulse on that. For that to work, though, I’d have to remember to trigger it every time I use the remote starter. It wouldn’t be able to be triggered by the output to the remote starter itself because the Arduino wouldn’t yet have power. I could maybe integrate a separate low-power controller that only watches for the remote starter output and triggers the Arduino once it’s powered on.</p>

<p>I would also like to build a custom board rather than using the click shields. As it is, the wiring is a bit messy and the whole thing barely fits behind the dash. I could use this <a href="https://www.amazon.com/SongHe-ATMEGA2560-16AU-Pinheaders-Compatible-Mega2560/dp/B07TGF9VMQ">unofficial Arduino Mega 2560 Pro</a> and design a custom PCB around it to handle the wiring and power. I’ve never designed a PCB before, though, and I’m not sure I want to spend hundreds of dollars ordering prototypes that I’ll definitely get wrong the first few times.</p>

<h3 id="a-little-discussion-about-security">A Little Discussion About Security</h3>

<p>I’m a cybersecurity student, so I’m always thinking about security.</p>

<p>It’s taken for granted these days that most of our day-to-day activity on the Internet is done securely. Most modern websites are configured with HTTPS, which uses the TLS protocol to encrypt our data as it is transmitted between the client and the server, ensuring that nobody can see what’s being sent. The server sends a certificate to the client to prove that it is who it says it is, and the client verifies the certificate (and shows a big scary warning if it doesn’t check out). You then use a username and password (and hopefully two-factor authentication) to prove that you are who you say you are. This way, when you’re buying something on Amazon, nobody can see what you’re buying, you know you’re giving your credit card information to Amazon, and Amazon knows that you’re the one giving them your credit card information.</p>

<p>Embedded networks are a different story. They use different protocols, some of which have defined standards for encryption and authentication, but many of which do not. Networks with very limited bandwidth are designed to use the bandwidth they have as efficiently as possible, and encryption and authentication are often not a priority, so data is left to be transmitted in the clear. This is the case with the LIN bus. There is no encryption or authentication, so anyone with access to the bus can see and modify the data being transmitted. There is a checksum to ensure integrity, but the checksum can be generated by anyone with access to the data. Because of this, once I have access to the LIN bus, I can do whatever I want with it.</p>

<p>Why would Toyota leave it open like this? The answer is <em>risk</em>. Risk, according to <a href="https://csrc.nist.gov/glossary/term/risk">NIST</a>, is “the extent to which an entity is threatened by a potential circumstance or event;” in other words, the likelihood that something bad will happen and how bad it will be if it does. For Internet traffic involving personal data, like the Amazon example mentioned above, the risk is very high. Without encryption and authentication, a malicious actor could watch you make a purchase and then steal your credit card data, or pretend to be Amazon and steal your username and password. They would then have easy access to your money, and they’d know where your stuff is being shipped so they could rob you once it’s delivered. The risk is high enough that it’s worth the cost of implementing encryption and authentication.</p>

<p>But for the climate control panel, the risk is low. The data being transmitted is not sensitive, and the worst that could happen is that a bad actor could blast cold air in your face in the middle of winter or disable your climate control system (although they could do that by just unplugging the panel). Maybe if they had something out for you in particular they could short circuit the connection and break your climate system. Doing any of these, however, would require physical access to the car. It’s already secured with a key, and if they’re able to bypass the car’s physical security measures get into the car there’s so many other things they could do to ruin your day. The cost of implementing additional encryption and authentication on the LIN bus is high, so it’s not worth it. (From Toyota’s perspective, though, this project is a risk they may not have considered–it uses this lack of security to give my car a feature that is usually reserved for more expensive trim levels.)</p>

<p>This extends to most of the embedded networks in the vehicle. There are a few, however, where the risk would be considerable enough that it would be worth the cost of implementing security measures. For example, the bus that connects to the lock switch and the door lock actuators, or the bus that connects ECUs to each other. If a bad actor could get access to this bus, they could lock you out of your car or unlock it and steal your stuff, <a href="https://kentindell.github.io/2023/04/03/can-injection/">or steal the whole car</a>.</p>

<p>Another important one is the CAN bus that connects to the lane keep assist and radar cruise system. I use a <a href="https://comma.ai/">Comma.ai</a> device, which intercepts this bus to massively improve upon my car’s built-in lane keep assist and radar cruise control to the point where I can drive hands-free on the highway. As someone who gets worn out by long road trips, being able to use these commands is awesome, but it’s a huge security risk. If a bad actor could get access to this bus, they could spoof the radar and lane keep assist systems to unexpectedly slam on the gas or brakes or steer the car off the road. Imagine a hitman who installs a little box with a CAN interceptor and a cellular radio under the lane keep camera cover. They could then take out their target by remotely taking over their car and driving it off a cliff. You might not be interesting enough to have a hit put out on you, but if you’re a celebrity or a politician, this is a real risk.</p>

<p>Toyota clearly does not like this because in new model years they’ve started locking this down with a protocol called <a href="file:///C:/Users/Jacob/Downloads/17-1_p44_autosar-secoc-for-canfd_tobias-islinger_denso-automotive_d.pdf">Autosar SecOC</a>. While this does not encrypt messages, it authenticates messages with a checksum that is generated using a key that is unique to each car. This prevents malicious actors from taking control of a car while it’s driving, which is a very good thing. However, it has been a <a href="https://github.com/commaai/openpilot/discussions/19932">major thorn in Openpilot’s side</a> as it isn’t able to control new model year cars, and talented developers have been working to crack it for the last 2 years and have not yet succeeded. Toyota also makes more money this way because they’re able to convince people to buy a more expensive trim with <a href="https://www.toyota.com/mirai/2023/teammate/">their Teammate system</a> instead of using a Comma device. They know Comma exists and secured the bus because leaving it open was a risk to both driver safety and their bottom line.</p>

<p>Personally, I would like to see this cracked, but in a way that only the car’s owner can sign the checksum so that malicious actors can’t take control of a car while it’s driving. For example, if the owner could get access to the key as it’s being distributed through the CAN network, they could use it to sign the checksum. This would allow them to use Openpilot, but it would prevent malicious actors from taking control of the car while it’s driving. If a vehicle manufacturer wanted to support 3rd party solutions, they could provide a way for the owner to be given the key if they sign a release of liability over the driver assistance systems, similar to unlocking the bootloader on a phone.</p>

<p>Some other car manufacturers secure those messages as well, including all Teslas and (I think) some GM vehicles. I’m not sure how they implement it. Most other manufacturers, however, do not. If a car is on <a href="https://github.com/commaai/openpilot/blob/master/docs/CARS.md">this list</a> it’s a reasonable assumption that authentication is not implemented on the CAN bus.</p>

<h3 id="conclusion">Conclusion</h3>

<p>I had a lot of fun working on this project. I probably would have spent less time if I just manned up and went outside early to start the car or scrape ice, but it was a great learning experience, and I learned a lot about embedded systems and the LIN bus. I’m always happy to answer questions, so feel free to ask in the comments.</p>

<video style="width: 100%" controls="" src="/assets/images/2023-04-06-hacking-my-cars-climate-controls-part-2/defrost.mp4"></video>]]></content><author><name>Jacob Schooley</name></author><category term="car hacking" /><category term="hardware" /><category term="personal projects" /><summary type="html"><![CDATA[A walkthrough of the hardware I built to intercept and modify the LIN bus messages sent by my car's climate control system, and a discourse about vehicle network security.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitzero.tech/assets/images/2023-04-06-hacking-my-cars-climate-controls-part-2/device-wide.jpg" /><media:content medium="image" url="https://bitzero.tech/assets/images/2023-04-06-hacking-my-cars-climate-controls-part-2/device-wide.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Hacking My Car’s Climate Controls: LIN Reverse Engineering</title><link href="https://bitzero.tech/posts/2022/11/30/hacking-my-cars-climate-controls-lin-reverse-engineering" rel="alternate" type="text/html" title="Hacking My Car’s Climate Controls: LIN Reverse Engineering" /><published>2022-11-30T00:00:00+00:00</published><updated>2022-11-30T00:00:00+00:00</updated><id>https://bitzero.tech/posts/2022/11/30/hacking-my-cars-climate-controls-lin-reverse-engineering</id><content type="html" xml:base="https://bitzero.tech/posts/2022/11/30/hacking-my-cars-climate-controls-lin-reverse-engineering"><![CDATA[<p>It’s not a great feeling to walk out to your car in the morning and find that your windshield is completely covered in ice. Scraping it off is a pain, and it’s even worse when you’re in a hurry.</p>

<p>I used to drive a 20-year-old Honda Accord. It had a barebones climate control system, with buttons to choose where the air would blow, and dials to choose the temperature and fan speed. It was simple, but it worked. If I set the mode to defrost and then turned off the car, the defroster would still be on when I started the car again.</p>

<p>Not so in newer cars. My current car, a 5th generation Toyota RAV4, won’t keep the front or rear defrosters on after restarting the car. I installed a remote start system, but without being able to keep the defroster on, it’s not very useful. I could just as easily start the car myself and then turn on the defroster, but that would require me to go outside earlier than I want to.</p>

<p>I’ve been told this is a safety feature (and common on many newer cars, not just my Toyota). However, according to <a href="https://support.toyota.com/s/article/Can-I-control-the-AC-10212?language=en_US">Toyota’s website</a>, when you remote start the car, “if the outside temperature is less than 41°F, the front and rear defrosters will turn on.” Ah, so you <em>can</em> remotely defrost the windshield—if you bought a trim level that comes with Toyota’s remote start subscription service. I didn’t. (I did want the larger display though, so <a href="https://www.rav4world.com/threads/cheap-audio-plus-8-display-upgrade-with-corolla-radio.322164/#post-2962820">I bought and installed one from a junkyard Corolla</a>.)</p>

<p>So I’ve been thinking about how I could hack my car’s climate control system to keep the defroster on after restarting the car.</p>

<h3 id="the-can-bus">The CAN Bus</h3>

<p>With almost everything in modern cars being computer-controlled, CAN is the most common way to communicate between different systems. The CAN bus is a serial bus that uses a twisted pair of wires to carry data. It’s a multi-master bus, meaning that multiple devices can be connected to the bus and transmit data at the same time. Each device has a unique ID, and the bus uses arbitration to determine which device gets to transmit data at any given time.</p>

<p>CAN hacking is not new. There are many tools and a plethora of documentation and tutorials available for sniffing, intercepting, and modifying CAN traffic. <a href="https://comma.ai/">Comma.ai</a>, which I use every day, uses a CAN interceptor to modify communications between the car’s lane keeping camera and the car’s computer to send commands to drive the car semi-autonomously.</p>

<p>I figured that if CAN messages could <em>drive the car</em>, then they could probably control the climate control system, too. I started by connecting my computer to the <a href="https://comma.ai/shop/panda">panda</a> that I’d installed already for openpilot and opening <a href="https://cabana.comma.ai/">cabana</a> to view the raw CAN traffic. Unfortunately, nothing changed when I messed with the climate control buttons. Cars have multiple CAN buses, so I tried sniffing other buses, including the one connected to the remote starter and the one on the back of the radio. Still nothing.</p>

<p>Simply put, CAN is not used for controlling the climate system in my car. And if there’s no CAN traffic, there’s nothing to sniff. I needed to find another way to control the climate system.</p>

<p>(Actually, there might be a way to control it through CAN. Newer Highlanders and Venzas with the 12-inch screen can control the climate system through the touchscreen, and some RAV4 Prime and Prius Prime models can control it through the app. If you have one of those, you’re welcome to try sniffing the CAN traffic and see if you can figure out how to control the climate system. I’d love to hear about it.)</p>

<h3 id="the-lin-bus">The LIN Bus</h3>

<p>I started looking for other ways to control the climate system. Studying the wiring diagrams for my car, I found that the control panel on the dash is connected to the climate control unit through a LIN bus. (I also found that there was a CAN line connected to the control unit directly to a CAN gateway, but I’d have to rip apart most of my car’s dash to get to it.)</p>

<p>LIN is a serial bus that uses a single wire to carry data. It is different from CAN in that it is a single-master bus, meaning that only one device can transmit data at a time. The master node sends data to up to 16 slave nodes, and the slave devices can respond to requests sent by the master. <a href="https://www.csselectronics.com/pages/lin-bus-protocol-intro-basics">More information about LIN can be found here</a>.</p>

<div class="image-row">
  <img src="/assets/images/2022-11-30-hacking-my-cars-climate-controls-lin-reverse-engineering/connector_car_pinout.jpg" alt="car connector" />
  <img src="/assets/images/2022-11-30-hacking-my-cars-climate-controls-lin-reverse-engineering/connector_panel_pinout.jpg" alt="panel connector" />
</div>

<table>
  <thead>
    <tr>
      <th>Circle color</th>
      <th>Wire color</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Green</td>
      <td>Green</td>
      <td>LIN</td>
    </tr>
    <tr>
      <td>Yellow</td>
      <td>White/Black</td>
      <td>12V</td>
    </tr>
    <tr>
      <td>White</td>
      <td>White</td>
      <td>Ground</td>
    </tr>
    <tr>
      <td>Blue</td>
      <td>Blue</td>
      <td>Illumination</td>
    </tr>
  </tbody>
</table>

<p>Because LIN is much newer than CAN, well-documented hardware is scarce and open-source utilities for sniffing and intercepting traffic are practically nonexistent. I decided to start by reverse engineering the LIN data transmitted between the control panel and the climate control unit. This was a lot easier than I expected. A <a href="https://www.amazon.com/dp/B0895WQ5VM">LIN bus transciever with a TJA1020 chip</a> converts LIN data to TTL serial data, which can be read by a <a href="https://www.amazon.com/dp/B00LODGRV8">USB-to-UART adapter</a>. I ordered one and connected it to my computer, with the LIN terminal connected to the bus alongside both the car and the panel. (It’s a mess, but a functional mess.)</p>

<p><img src="/assets/images/2022-11-30-hacking-my-cars-climate-controls-lin-reverse-engineering/lin_connected_to_computer.jpg" alt="LIN bus connected to computer" /></p>

<p>Opening a serial connection using PuTTY gave me this:
<img src="/assets/images/2022-11-30-hacking-my-cars-climate-controls-lin-reverse-engineering/putty_serial_output.png" alt="putty serial output" /></p>

<p>Looks ugly, but there’s a pattern. A hex editor was a bit more useful. This sequence of bytes was repeated over and over:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>55 B1 00 40 00 00 38 38 00 00 9D 00 55 32 00 00 00 00 38 38 00 00 5D 00 55 39 40 00 00 00 10 90 00 00 E5 00 55 BA 00 00 00 00 00 00 00 00 45 00 55 F5 00 00 00 00 38 00 00 00 D1 00 55 76 00 55 78 90 00 00 00 00 00 00 00 F6 00
</code></pre></div></div>

<p>A LIN frame begins with a sync byte, followed by a 6-bit ID, a 2-bit parity bit, 8 data bytes, and a 1-byte checksum. The transceiver returns <code class="language-plaintext highlighter-rouge">0x55</code> to represent the sync byte and <code class="language-plaintext highlighter-rouge">0x00</code> at the end of the frame. Separating the frames gives us this:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>55 B1 00 40 00 00 38 38 00 00 9D 00
55 32 00 00 00 00 38 38 00 00 5D 00
55 39 40 00 00 00 10 90 00 00 E5 00
55 BA 00 00 00 00 00 00 00 00 45 00
55 F5 00 00 00 00 38 00 00 00 D1 00
55 76 00
55 78 90 00 00 00 00 00 00 00 F6 00
</code></pre></div></div>

<p>Disconnecting the control panel from the bus changed the output:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>55 B1 00 40 00 00 38 38 00 00 9D 00
55 32 00 00 00 00 38 38 00 00 5D 00
55 39 00
55 BA 00
55 F5 00 00 00 00 38 00 00 00 D1 00
55 76 00
55 78 00
</code></pre></div></div>

<h3 id="deciphering-the-data">Deciphering the Data</h3>

<p>Immediately we can determine that <code class="language-plaintext highlighter-rouge">0xB1</code>, <code class="language-plaintext highlighter-rouge">0x32</code>, and <code class="language-plaintext highlighter-rouge">0xF5</code> are frames of data sent by the master node (the climate control unit) to the slave node (the control panel). <code class="language-plaintext highlighter-rouge">0x39</code>, <code class="language-plaintext highlighter-rouge">0xBA</code>, and <code class="language-plaintext highlighter-rouge">0x78</code> are requests, which are responded to by the control panel. I have no clue what <code class="language-plaintext highlighter-rouge">0x76</code> is. To figure out which frames do what, I simply pressed buttons and observed the changes in the data.</p>

<h4 id="status-messages">Status Messages</h4>

<p>Frames with the ID <code class="language-plaintext highlighter-rouge">0xB1</code> contain the current status of the climate system.</p>

<table>
  <thead>
    <tr>
      <th>Function</th>
      <th>Status</th>
      <th>Data (8 bytes + checksum)</th>
      <th>Bits (excluding checksum)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td rowspan="8">fan/power</td>
      <td>off</td>
      <td><code>80 0<strong>0</strong> 13 00 2c 2c 00 81 <em>e0</em></code></td>
      <td rowspan="8"><code>&gt;&gt; 48 &amp; 7</code></td>
    </tr>
    <tr>
      <td>1</td>
      <td><code>80 0<strong>1</strong> 13 00 2c 2c 00 81 <em>df</em></code></td>
    </tr>
    <tr>
      <td>2</td>
      <td><code>80 0<strong>2</strong> 13 00 2c 2c 00 81 <em>de</em></code></td>
    </tr>
    <tr>
      <td>3</td>
      <td><code>80 0<strong>3</strong> 13 00 2c 2c 00 81 <em>dd</em></code></td>
    </tr>
    <tr>
      <td>4</td>
      <td><code>80 0<strong>4</strong> 13 00 2c 2c 00 81 <em>dc</em></code></td>
    </tr>
    <tr>
      <td>5</td>
      <td><code>80 0<strong>5</strong> 13 00 2c 2c 00 81 <em>db</em></code></td>
    </tr>
    <tr>
      <td>6</td>
      <td><code>80 0<strong>6</strong> 13 00 2c 2c 00 81 <em>da</em></code></td>
    </tr>
    <tr>
      <td>7</td>
      <td><code>80 0<strong>7</strong> 13 00 2c 2c 00 81 <em>d9</em></code></td>
    </tr>
    <tr>
      <td rowspan="4">temperature</td>
      <td>Low (<code>0x00</code>)</td>
      <td><code>80 01 13 00 <strong>00 00</strong> 00 81 <em>38</em></code></td>
      <td rowspan="4"><code>&gt;&gt; 24 &amp; FF</code> (driver)<br /><code>&gt;&gt; 16 &amp; FF</code> (passenger)</td>
    </tr>
    <tr>
      <td>60 - 64 °F (<code>0x66</code> - <code>0x6a</code>)</td>
      <td><code>80 01 13 00 <strong>68 68</strong> 00 81 <em>67</em></code></td>
    </tr>
    <tr>
      <td>65 - 85 °F (<code>0x22</code> - <code>0x36</code>)</td>
      <td><code>80 01 13 00 <strong>29 34</strong> 00 81 <em>da</em></code></td>
    </tr>
    <tr>
      <td>High (<code>0x37</code>)</td>
      <td><code>80 01 13 00 <strong>37 37</strong> 00 81 <em>c9</em></code></td>
    </tr>
    <tr>
      <td rowspan="2">auto</td>
      <td>off</td>
      <td><code>80 <strong>0</strong>3 13 00 2c 2c 00 81 <em>dd</em></code></td>
      <td rowspan="2"><code>&gt;&gt; 53 &amp; 1</code></td>
    </tr>
    <tr>
      <td>on</td>
      <td><code>80 <strong>2</strong>3 13 00 2c 2c 00 81 <em>bd</em></code></td>
    </tr>
    <tr>
      <td rowspan="5">mode</td>
      <td>face</td>
      <td><code>80 02 1<strong>1</strong> 00 2c 2c 00 81 <em>e0</em></code></td>
      <td rowspan="5"><code>&gt;&gt; 40 &amp; F</code></td>
    </tr>
    <tr>
      <td>face/feet</td>
      <td><code>80 02 1<strong>2</strong> 00 2c 2c 00 81 <em>df</em></code></td>
    </tr>
    <tr>
      <td>feet</td>
      <td><code>80 02 1<strong>3</strong> 00 2c 2c 00 81 <em>de</em></code></td>
    </tr>
    <tr>
      <td>feet/defrost</td>
      <td><code>80 02 1<strong>4</strong> 00 2c 2c 00 81 <em>dd</em></code></td>
    </tr>
    <tr>
      <td>defrost</td>
      <td><code>80 02 1<strong>9</strong> 00 2c 2c 00 81 <em>d8</em></code></td>
    </tr>
    <tr>
      <td rowspan="2">rear defrost</td>
      <td>off</td>
      <td><code>80 03 13 <strong>0</strong>0 2c 2c 00 81 <em>dd</em></code></td>
      <td rowspan="2"><code>&gt;&gt; 38 &amp; 1</code></td>
    </tr>
    <tr>
      <td>on</td>
      <td><code>80 03 13 <strong>4</strong>0 2c 2c 00 81 <em>9d</em></code></td>
    </tr>
    <tr>
      <td rowspan="2">eco</td>
      <td>off</td>
      <td><code>8<strong>0</strong> 03 13 00 2c 2c 00 81 <em>dd</em></code></td>
      <td rowspan="2"><code>&gt;&gt; 59 &amp; 1</code></td>
    </tr>
    <tr>
      <td>on</td>
      <td><code>8<strong>8</strong> 03 13 00 2c 2c 00 81 <em>d5</em></code></td>
    </tr>
    <tr>
      <td rowspan="2">recycle</td>
      <td>off</td>
      <td><code>80 02 <strong>1</strong>2 00 2c 2c 00 81 <em>df</em></code></td>
      <td rowspan="2"><code>&gt;&gt; 45 &amp; 1</code></td>
    </tr>
    <tr>
      <td>on</td>
      <td><code>80 02 <strong>2</strong>2 00 2c 2c 00 81 <em>cf</em></code></td>
    </tr>
    <tr>
      <td rowspan="2">s-mode</td>
      <td>off</td>
      <td><code><strong>0</strong>0 02 12 00 2c 2c 00 81 <em>60</em></code></td>
      <td rowspan="2"><code>&gt;&gt; 63 &amp; F</code></td>
    </tr>
    <tr>
      <td>on</td>
      <td><code><strong>8</strong>0 02 12 00 2c 2c 00 81 <em>df</em></code></td>
    </tr>
    <tr>
      <td rowspan="2">sync</td>
      <td>off</td>
      <td><code>00 02 12 <strong>0</strong>0 2c 2c 00 81 <em>60</em></code></td>
      <td rowspan="2"><code>&gt;&gt; 37 &amp; 1</code></td>
    </tr>
    <tr>
      <td>on</td>
      <td><code>00 02 12 <strong>2</strong>0 2c 2c 00 81 <em>40</em></code></td>
    </tr>
    <tr>
      <td rowspan="2">a/c</td>
      <td>off</td>
      <td><code>00 02 12 00 2c 2c 00 8<strong>0</strong> <em>61</em></code></td>
      <td rowspan="2"><code>&amp; 1</code></td>
    </tr>
    <tr>
      <td>on&gt;</td>
      <td><code>00 02 12 00 2c 2c 00 8<strong>1</strong> <em>60</em></code></td>
    </tr>
    <tr>
      <td rowspan="2">illumination</td>
      <td>off</td>
      <td><code>00 06 14 00 35 36 00 <strong>8</strong>1 <em>47</em></code></td>
      <td rowspan="2"><code>&gt;&gt; 6 &amp; 1</code></td>
    </tr>
    <tr>
      <td>on</td>
      <td><code>00 06 14 00 35 36 00 <strong>c</strong>1 <em>07</em></code></td>
    </tr>
  </tbody>
</table>

<h4 id="button-presses">Button Presses</h4>

<p>Pressing buttons on the control panel to change the temperature, fan speed, or blower mode causes a change in the response to <code class="language-plaintext highlighter-rouge">0x39</code>. Its data with nothing pressed is
<code class="language-plaintext highlighter-rouge">40 00 00 00 10 90 00 00 e5</code>. When a button is pressed, a bit or bits in the response change for a minimum of one frame before returning to the response. If the button is held down, the response continues to reflect the pressed button until it is released.</p>

<p>For the most part, multiple buttons can be pressed simultaneously. There are two exceptions.</p>

<ol>
  <li>If the fan up/down buttons are pressed simultaneously, the panel will send the response for the fan up button and the fan speed will increase.</li>
  <li>Temperature up/down can be triggered multiple times per command. For example, if I quickly spin the driver temperature knob clockwise, the panel will respond to the next <code class="language-plaintext highlighter-rouge">0x39</code> request with <code>40 00 00 00 <strong>12</strong> 90 00 00</code> or <code>40 00 00 00 <strong>13</strong> 90 00 00</code>. The temperature will increase by 2 or 3 degrees, respectively.</li>
</ol>

<table>
  <thead>
    <tr>
      <th>Button</th>
      <th>Data (8 bytes + checksum)</th>
      <th>Operation</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>none</td>
      <td><code>40 00 00 00 10 90 00 00 <em>e5</em></code></td>
      <td> </td>
    </tr>
    <tr>
      <td>off</td>
      <td><code>4<strong>2</strong> 00 00 00 10 90 00 00 <em>e3</em></code></td>
      <td><code>&#124; 0<strong>2</strong> 00 00 00 00 00 00 00</code></td>
    </tr>
    <tr>
      <td>auto</td>
      <td><code>4<strong>8</strong> 00 00 00 10 90 00 00 <em>dd</em></code></td>
      <td><code>&#124; 0<strong>8</strong> 00 00 00 00 00 00 00</code></td>
    </tr>
    <tr>
      <td>driver temp down</td>
      <td><code>40 00 00 00 <strong>0f</strong> 90 00 00 <em>e6</em></code></td>
      <td><code>- 00 00 00 00 0<strong>1</strong> 00 00 00</code></td>
    </tr>
    <tr>
      <td>driver temp up</td>
      <td><code>40 00 00 00 <strong>11</strong> 90 00 00 <em>e4</em></code></td>
      <td><code>+ 00 00 00 00 0<strong>1</strong> 00 00 00</code></td>
    </tr>
    <tr>
      <td>passenger temp down</td>
      <td><code>40 00 00 00 10 <strong>8f</strong> 00 00 <em>e6</em></code></td>
      <td><code>- 00 00 00 00 00 0<strong>1</strong> 00 00</code></td>
    </tr>
    <tr>
      <td>passenger temp up</td>
      <td><code>40 00 00 00 10 <strong>91</strong> 00 00 <em>e6</em></code></td>
      <td><code>+ 00 00 00 00 00 0<strong>1</strong> 00 00</code></td>
    </tr>
    <tr>
      <td>sync</td>
      <td><code>40 00 00 <strong>2</strong>0 10 90 00 00 <em>c5</em></code></td>
      <td><code>&#124; 00 00 00 <strong>2</strong>0 00 00 00 00</code></td>
    </tr>
    <tr>
      <td>a/c</td>
      <td><code>40 <strong>8</strong>0 00 00 10 90 00 00 <em>65</em></code></td>
      <td><code>&#124; <strong>8</strong>0 00 00 00 00 00 00 00</code></td>
    </tr>
    <tr>
      <td>front defrost</td>
      <td><code>40 00 00 <strong>8</strong>0 10 90 00 00 <em>65</em></code></td>
      <td><code>&#124; 00 00 00 <strong>8</strong>0 00 00 00 00</code></td>
    </tr>
    <tr>
      <td>rear defrost</td>
      <td><code>40 00 00 <strong>4</strong>0 10 90 00 00 <em>a5</em></code></td>
      <td><code>&#124; 00 00 00 <strong>4</strong>0 00 00 00 00</code></td>
    </tr>
    <tr>
      <td>eco</td>
      <td><code>40 <strong>4</strong>0 00 00 10 90 00 00 <em>a5</em></code></td>
      <td><code>&#124; 00 <strong>4</strong>0 00 00 00 00 00 00</code></td>
    </tr>
    <tr>
      <td>fan down</td>
      <td><code>40 <strong>3d</strong> 00 00 10 90 00 00 <em>a8</em></code></td>
      <td><code>&#124; 00 <strong>3d</strong> 00 00 00 00 00 00</code></td>
    </tr>
    <tr>
      <td>fan up</td>
      <td><code>40 <strong>3c</strong> 00 00 10 90 00 00 <em>a9</em></code></td>
      <td><code>&#124; 00 <strong>3c</strong> 00 00 00 00 00 00</code></td>
    </tr>
    <tr>
      <td>mode</td>
      <td><code>40 00 <strong>1c</strong> 00 10 90 00 00 <em>c9</em></code></td>
      <td><code>&#124; 00 00 <strong>1c</strong> 00 00 00 00 00</code></td>
    </tr>
    <tr>
      <td>recycle air</td>
      <td><code>40 00 00 00 10 90 <strong>c</strong>0 00 <em>25</em></code></td>
      <td><code>&#124; 00 00 00 00 00 00 <strong>c</strong>0 00</code></td>
    </tr>
    <tr>
      <td>s-mode</td>
      <td><code>40 00 <strong>8</strong>0 00 10 90 00 00 <em>65</em></code></td>
      <td><code>&#124; 00 00 <strong>8</strong>0 00 00 00 00 00</code></td>
    </tr>
  </tbody>
</table>

<h4 id="everything-else">Everything Else</h4>

<p>During my testing, <code class="language-plaintext highlighter-rouge">0x32</code>, <code class="language-plaintext highlighter-rouge">0xBA</code>, <code class="language-plaintext highlighter-rouge">0xF5</code>, and <code class="language-plaintext highlighter-rouge">0x78</code> messages never changed, so I’m not sure what they do. My car doesn’t have the winter package, which includes the heated seats, heated steering wheel, and wiper defroster. Those messages may be related to those features and would be used on cars with those options.</p>

<p><code class="language-plaintext highlighter-rouge">0x76</code> is still a mystery, as it is continually requested by the master node and never receives a response. Remember how I mentioned some cars, like the newest generation Venza and Highlander with the 12 inch display, can control the climate system from the touchscreen? They might use CAN, or they might be connected to the climate LIN bus and respond to <code class="language-plaintext highlighter-rouge">0x76</code> requests. I tried responding to <code class="language-plaintext highlighter-rouge">0x76</code> requests with the same data as <code class="language-plaintext highlighter-rouge">0x39</code> and nothing happened. I also tried sending messages with 1 bit changed at a time (<code class="language-plaintext highlighter-rouge">0x0000000000000001</code>, <code class="language-plaintext highlighter-rouge">0x0000000000000002</code>, <code class="language-plaintext highlighter-rouge">0x0000000000000004</code> etc.) and observed no changes.</p>

<h3 id="sending-lin-data">Sending LIN Data</h3>

<p>Because the TJA1020 transceiver operates as a slave node, it can respond to requests sent by the master. Responses, as with data sent by the master, must end with a <a href="https://onlinedocs.microchip.com/pr/GUID-FA73463A-EB90-493D-A558-196E2EA36553-en-US-1/index.html?GUID-E40384CE-AADE-42A4-B529-F5522A91CAF8">checksum byte</a>. A Python script can be used to listen for requests and transmit responses.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">serial</span>

<span class="n">ser</span> <span class="o">=</span> <span class="n">serial</span><span class="p">.</span><span class="n">Serial</span><span class="p">(</span>
  <span class="n">port</span><span class="o">=</span><span class="s">'COM9'</span><span class="p">,</span> <span class="c1"># the serial port of the UART to USB adapter
</span>  <span class="n">baudrate</span><span class="o">=</span><span class="mi">19200</span><span class="p">,</span>
  <span class="n">parity</span><span class="o">=</span><span class="n">serial</span><span class="p">.</span><span class="n">PARITY_NONE</span><span class="p">,</span>
  <span class="n">stopbits</span><span class="o">=</span><span class="n">serial</span><span class="p">.</span><span class="n">STOPBITS_ONE</span><span class="p">,</span>
  <span class="n">bytesize</span><span class="o">=</span><span class="n">serial</span><span class="p">.</span><span class="n">EIGHTBITS</span><span class="p">,</span>
  <span class="n">timeout</span><span class="o">=</span><span class="bp">None</span>
<span class="p">)</span>

<span class="k">def</span> <span class="nf">calculate_checksum</span><span class="p">(</span><span class="n">frame_id</span><span class="p">,</span> <span class="n">bytes_data</span><span class="p">):</span>
  <span class="n">checksum</span> <span class="o">=</span> <span class="n">frame_id</span>
  <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">bytes_data</span><span class="p">:</span>
    <span class="n">checksum</span> <span class="o">+=</span> <span class="n">b</span>
    <span class="k">if</span> <span class="n">checksum</span> <span class="o">&gt;</span> <span class="mi">255</span><span class="p">:</span>
      <span class="n">checksum</span> <span class="o">-=</span> <span class="mi">255</span>
  <span class="n">checksum</span> <span class="o">=</span> <span class="o">~</span><span class="n">checksum</span> <span class="o">&amp;</span> <span class="mh">0xFF</span>  <span class="c1"># invert; &amp; 0xFF is unnecessary in C when using uint8_t
</span>  <span class="k">return</span> <span class="n">checksum</span><span class="p">.</span><span class="n">to_bytes</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s">'big'</span><span class="p">,</span> <span class="n">signed</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">respond</span><span class="p">():</span>
  <span class="n">increase_fan_speed</span> <span class="o">=</span> <span class="sa">b</span><span class="s">'</span><span class="se">\x40\x3c\x00\x00\x10\x90\x00\x00</span><span class="s">'</span>
  <span class="k">while</span> <span class="mi">1</span><span class="p">:</span>
    <span class="n">b</span> <span class="o">=</span> <span class="n">ser</span><span class="p">.</span><span class="n">read</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">b</span><span class="p">.</span><span class="nb">hex</span><span class="p">()</span> <span class="o">==</span> <span class="s">'55'</span><span class="p">:</span>
      <span class="n">b</span> <span class="o">=</span> <span class="n">ser</span><span class="p">.</span><span class="n">read</span><span class="p">()</span>
      <span class="k">if</span> <span class="n">b</span><span class="p">.</span><span class="nb">hex</span><span class="p">()</span> <span class="o">==</span> <span class="s">'39'</span><span class="p">:</span>
        <span class="n">ser</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="n">increase_fan_speed</span> <span class="o">+</span> <span class="n">calculate_checksum</span><span class="p">(</span><span class="mh">0x39</span><span class="p">,</span> <span class="n">increase_fan_speed</span><span class="p">))</span>

<span class="n">respond</span><span class="p">()</span>
</code></pre></div></div>

<p>Running this script will tell the car that the fan up button is being held down, causing the fan speed to increase. However, the control panel must be unplugged from the car for this to work. If the control panel is plugged in, both nodes will be transmitting responses at the same time, resulting in a collision. The car sees this as invalid data and ignores it.</p>

<p>Operating as a master node is a bit more complex. To start, most LIN chips require another resistor placed between two pins or something of the sort to enable them to transmit in master mode. When I tried sending messages to the panel as a master, nothing happened. I think Python with the USB-UART adapter might just be too slow to send messages fast enough to be recognized by the transceiver as a single message. SoftwareSerial on an Arduino also did not send messages quickly enough. I was finally able to get it to work with an Arduino Mega, which has 3 hardware serial interfaces in addition to its USB serial interface. More detail on this will have to wait for another post.</p>

<h3 id="next-steps">Next Steps</h3>

<p>My goal is to send messages to turn on the defrosters if they were on before shutting off the car. This is going to require building an interceptor with 2 LIN transceivers, one to act as a slave on the car’s network and another to act as a master for the panel. I bought some parts to build a prototype, but turning this into something that reliably works in my car is going to take a while.</p>

<p><img src="/assets/images/2022-11-30-hacking-my-cars-climate-controls-lin-reverse-engineering/prototype_interceptor.jpg" alt="prototype LIN interceptor" /></p>]]></content><author><name>Jacob Schooley</name></author><category term="car hacking" /><category term="hardware" /><category term="personal projects" /><summary type="html"><![CDATA[I've been working on reverse engineering the LIN bus in my car's climate control system. This post is a summary of what I've learned so far.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitzero.tech/assets/images/2022-11-30-hacking-my-cars-climate-controls-lin-reverse-engineering/panel.jpg" /><media:content medium="image" url="https://bitzero.tech/assets/images/2022-11-30-hacking-my-cars-climate-controls-lin-reverse-engineering/panel.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">I Built a Monitor Just For Spotify</title><link href="https://bitzero.tech/posts/2022/11/17/i-built-a-monitor-just-for-spotify" rel="alternate" type="text/html" title="I Built a Monitor Just For Spotify" /><published>2022-11-17T00:00:00+00:00</published><updated>2022-11-17T00:00:00+00:00</updated><id>https://bitzero.tech/posts/2022/11/17/i-built-a-monitor-just-for-spotify</id><content type="html" xml:base="https://bitzero.tech/posts/2022/11/17/i-built-a-monitor-just-for-spotify"><![CDATA[<p>I love music. I listen to music constantly, whether I’m working or doing homework or goofing off. I also really like knowing what I’m listening to at all times, as I spend much of my time listening to other people’s playlists and Spotify radio/auto-generated playlists. Bonus points if it’s easy to skip through a bunch of songs quickly for those times when I’m feeling a specific type of song but not quite sure exactly which one.</p>

<p>I was particularly intrigued by Spotify’s <a href="https://carthing.spotify.com/">Car Thing</a>. I didn’t need one for my car because I use CarPlay and its dashboard works great. For my office, though, it looked like it could be useful. I have 2 monitors and use all the screen space I have available for work. MusicBee and the Pandora app I used years ago allow me to minimize the player into a tiny window that just shows the album art and track name with player controls, but Spotify does not. A big ol’ window to show what I’m listening to on Spotify takes up too much screen real estate.</p>

<p><img src="/assets/images/2022-11-17-i-built-a-monitor-just-for-spotify/carthing.jpg" alt="spotify car thing" /></p>

<p>So I bought one. Unfortunately, it turns out, the firmware it ships with will not allow it to connect to a PC. It was designed to connect only to the Spotify app on a phone. I didn’t like that because it would either drain my phone’s battery or would require me to set up a spare phone just for interfacing with that screen. I gave up and sold it.</p>

<h3 id="building-something-that-does-what-i-want">Building Something That Does What I Want</h3>

<p>There’s plenty of space under my main monitor, so I settled on putting a little 7” monitor under it. That would leave my options open in case I wanted to eventually display more than just Spotify. An Amazon search revealed that every mini monitor that came with a case had the HDMI and USB ports sticking out the side. Yuck.</p>

<p><img src="/assets/images/2022-11-17-i-built-a-monitor-just-for-spotify/amazon-prebuilt-monitor.png" alt="monitor with ports on the side" /></p>

<p>I actually bought one, thinking it couldn’t be that bad. I was wrong. The cables sticking out the side bothered me a bit too much. If I wanted something that looked nice, I was going to have to go with a caseless one and build a case for it. <a href="https://a.co/d/4XXSw9p">This is the one I went with.</a> Waveshare makes decent displays, and this one is pretty cheap, even though shipping took 3 weeks. It also comes with a separate HDMI board, so I could put the ports wherever I want.</p>

<p>I then designed and 3D-printed a chassis for this monitor. I’m not an artist and there’s a reason I’m studying cybersecurity rather than mechanical engineering. Prior to this, I had never successfully designed anything physical, much less actually made it real, so trying to design something functional was a whole new learning experience and took a lot longer than I was expecting.</p>

<p>This is what I came up with:</p>

<p><img src="/assets/images/2022-11-17-i-built-a-monitor-just-for-spotify/case-fusion-360.png" alt="case in fusion 360" /></p>

<p>Definitely not your typical monitor chassis. But it didn’t take too long and wasn’t too difficult to design, it attaches to a spare monitor arm I had, the ports point out the back, there’s a spot for a brightness knob, and for the most part it looks like it belongs on my desk. I may redesign it in the future because the chin is more noticeable than I thought it would be, but this is good enough for now.</p>

<p><img src="/assets/images/2022-11-17-i-built-a-monitor-just-for-spotify/behind-monitor.jpg" alt="behind monitor" /></p>

<p>It took 4 prints and revisions to come up with a case that would fit the screen and not fall apart while being printed. Every time I paid for a print, waited 12+ hours, and then realized it wouldn’t fit right, I was reminded why I chose a career in software.</p>

<p>If you want to print one yourself (or redesign it), you can download the files <a href="https://github.com/jbschooley/SpotifyMonitor/tree/main/Case">here</a>. Good luck!</p>

<h3 id="the-insides">The Insides</h3>

<p>The HDMI board has a pin for controlling brightness. Brightness is high at 3.3 V and low when grounded. The waveshare wiki instructions say brightness can be controlled via PWM, but I found that a potentiometer works just fine (and DC brightness control is better on the eyes).</p>

<p>Most monitors automatically turn off when they detect that no video is coming through. This one, as I found out after building it, does not. My PC will cut power to the USB ports when it’s shutdown, but I usually put it to sleep when I’m not using it, and USB devices are powered during sleep. This posed a problem, as I would wake up at 2 am and see a glowing black square on the other side of my room.</p>

<p>One possible solution to this would be to detect a difference in voltage on one of the HDMI pins between on and sleep. One of the pins did show a noticeable difference when probed with a multimeter, and I would be able to detect that with an Arduino and use that to control power. That may be an option in the future, but it would require SMD tools and I’m not quite comfortable with those yet.</p>

<p>I found an interesting workaround though. I had an old USB audio interface lying around, and found that when the PC was awake, the mic connector had a positive voltage but was grounded during sleep. Connecting that to the EN (enable) pin on the HDMI port resulted in the monitor turning off during sleep.</p>

<p><img src="/assets/images/2022-11-17-i-built-a-monitor-just-for-spotify/insides.jpg" alt="insides" /></p>

<h3 id="software">Software</h3>

<p>For the Spotify interface, I simply modified the Spotify web player. They already did all the complicated stuff, and some simple-ish changes make it look pretty good on its own screen.</p>

<p><a href="https://www.slimjet.com/">Slimjet</a> is a minimal Chromium fork that’s distributed in a portable version. Any Chromium fork works, as long as you aren’t using it for anything else.</p>

<p><a href="https://chrome.google.com/webstore/detail/mini-player-for-spotify/mjjeebakniihklfggnacbigighgildlo?hl=en">Mini Player for Spotify</a> is a Chrome extension that adds some CSS to the Spotify player to get rid of the unnecessary stuff.</p>

<p><a href="https://github.com/jbschooley/SpotifyMonitor/blob/main/SpotifyCSS.js">This tampermonkey script</a> further adjusts the CSS (and some JS to fix low resolution album art) to make it look even better.</p>

<p>A desktop shortcut with this target to open it in full screen:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>slimjet.exe -kiosk https://open.spotify.com
</code></pre></div></div>

<p>And this is what it looks like:</p>

<p><img src="/assets/images/2022-11-17-i-built-a-monitor-just-for-spotify/monitor.jpg" alt="interface" /></p>

<p>Honestly, I think it looks pretty good.</p>

<h3 id="my-projects-never-end">My Projects Never End</h3>

<p>I feel like I can’t ever truly “finish” a project. I’m always thinking of ways I could make it better. For example:</p>

<p>I could replace Slimjet with <a href="https://thorium.rocks/">Thorium</a> because it’s open source.</p>

<p>I at least want to get rid of the Chrome extension and move all that CSS to the tampermonkey script.</p>

<p>Tapping the buttons works fine, but dragging the timebar doesn’t. I haven’t been able to find a reliable way to fix that, but it works fine on the mobile interface. The mobile interface is more difficult and time consuming to modify so that it looks nice on this screen, but I’m considering it if not being able to drag the timebar bothers me enough.</p>

<p>Or, I could show my Home Assistant dashboard instead. That would let me easily control the lights in my room too. However, the Spotify HA plugin currently makes for a poor user experience. The official player uses a websocket for instant updates whenever another device changes the track or playback status, but the HA plugin just polls the API every few seconds, which means if I pause the music or change the song from the desktop app, it will take a few seconds to update on the screen. I’m not sure if this is fixable because Spotify doesn’t provide a websocket API to developers.</p>

<p>We’ll see if I ever get around to doing any of that.</p>]]></content><author><name>Jacob Schooley</name></author><category term="hardware" /><category term="music" /><category term="personal projects" /><summary type="html"><![CDATA[Because one that worked the way I wanted didn't exist, I designed, 3D printed, and built a monitor to show what I'm listening to.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bitzero.tech/assets/images/2022-11-17-i-built-a-monitor-just-for-spotify/monitor.jpg" /><media:content medium="image" url="https://bitzero.tech/assets/images/2022-11-17-i-built-a-monitor-just-for-spotify/monitor.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>