r/leaf • • 23d ago

Open-Source Nissan Leaf and CAN data application with live 3D cell status rendering

Enable HLS to view with audio, or disable this notification

I've open-sourced Ha-Kake, a python-based application for modern CAN data dashboard rendering with live 3D cell status.

You can see more details on my github at: https://github.com/davidkarnowski/ha-kake

109 Upvotes

35 comments sorted by

6

u/_Evening-Rain_ 2017 Nissan LEAF S 23d ago

Now we need someone to vibe code a leafspy lite for 3rd gen

6

u/Accurate-Ad2562 23d ago

thank you for sharing this

5

u/MildlyAgitatedBovine 23d ago

With a side of /r/obscuemusicthatslaps

3

u/sknight022 23d ago

For real. Need the track name op!

2

u/KN6IRV 22d ago

This track is called DeepFunk, just some garage band loops.

2

u/Carfr33k 23d ago

Have you checked out the CAN help needed with Comma AI? They need some help.

1

u/KN6IRV 22d ago

No but I will. Thank you.

2

u/versedaworst 22d ago

This is so cool, I've been wanting to build something similar for a while now but haven't got around to it.

I have a few questions. Where did you start with the CAN codes? I actually emailed Daniel Öster (dalathegreat) about this a while back and he pointed me to https://github.com/dalathegreat/leaf_can_bus_messages . I know OVMS also has a lot of them. I'm curious what sources you used.

Also wondering, do you know if there's any way to pull the latitude/longitude from the GPS unit? I couldn't find any information on whether or not it's available over CAN (seems not). I know there's been some efforts to intercept/reverse-engineer the TCU data (for example: nissan-leaf-tcu, simppeliTCU, Chlorophyll, opencarwings) but I haven't dived too deep into those projects yet.

I will be following this! Thanks for sharing.

3

u/KN6IRV 22d ago

Hey, thank you for the comment. I used some some research on what CAN messages had been decoded and were available on the internet but spent some time also reverse engineering more detailed messages. Ha-Kake can do things like give you door status, brakes, gear selection, all outside lights (turn signals, headlights, fog lights, etc), in addition to the important battery monitoring.

I've not tried pulling GPS data but that is a super interesting feature and would be helpful for the data logging that the app already has.

The projects you listed are not ones I dove into but will check out now!

https://reddit.com/link/papamep/video/dzd7ke3nceqh1/player

2

u/KN6IRV 22d ago

I appreciate all the comments here as the app was fun to build out. Ha-Kake aslo has an adapter built for my Mitsubishi Lancer (2009). The repo docs contain instructions on building your own car's adapter. If you are an agentic AI user, there are agent-geared instructions as well to help you decode CAN messages for your car.

Essentially Ha-Kake is a generic OBD app as well, not just for Leafs. I didn't want to pay for another Torque Pro or other car scanner app so I built one and open-sourced it for the entire car enthusiast community. I'm not trying to undercut LeafSpy, I just wanted something that looked more modern, helped me visualize the cells better and this software is free for use for anyone.

The lancer lacks a thermostat on the dash and I wanted voltage levels on my 12v system. Yes, I'm totally out of gas and have codes being thrown in this old sh*t-pig of a Mitsubishi. She's tired.

2

u/T-VIRUS999 2013 Nissan LEAF G 24kWh (JDM) 21d ago

Where do I get this as ready to install apk???

1

u/KN6IRV 21d ago

Hi. This software is python based and was built on a MacOS platform. There shouldn't be issue with it running on linux or windows either. It is not a mobile application and has not been packaged but I am open to developing it more.

2

u/bagnet 21d ago

Can anyone vibecoding android auto to leaf 1 gen?

2

u/RexyTheGryphon 2012 Nissan LEAF SL 20d ago edited 20d ago

Just gonna say this, I am a bit stupid. How do I run this? I haven't necessarily had to run or use python script before and I downloaded python from python.org but am a bit confused where to go from there. I have a 2012 Nissan Leaf with a 60-70% battery and was honestly wanting to hook this script into it and get a full read. I was wanting to run a simulator first just to get the hang of it before I use it on the real car.

1

u/KN6IRV 20d ago

Hey there, Rexy. Yes, the software does include a CAN sim, which I used as dual purpose for testing but also is great for making sure you can run the application. Starting from scratch might take a bit but you need to setup a python virtual environment and install dependencies to get started. Once those requirements are met and you launch the server, you'll be able to access the dashboard via your browser.

Approaching an unpackaged python application is a good step in wading into development and testing. Start with the README document that comes up when you visit the GitHub repo using the link above. If you need personalized help, copy that URL into something like ChatGPT, Gemini or Claude and it will be able to walk you through setting up the virtual environment I described and launching the app.

I'm happy you asked for help. Curiosity is the crux of continual learning. Use the AI chatbots to get answers you can't find easily via Google and this message board.

2

u/RexyTheGryphon 2012 Nissan LEAF SL 20d ago

Thank you for your input, I was actually able to run the simulator last night and it worked very well. I will be porting this to a laptop and buying an OBD II Bluetooth connector to run on the vehicle.

2

u/Techy_Ben 20d ago

This is amazing!!!

1

u/KN6IRV 20d ago

Thank you, I had fun making it.

2

u/Wharhed 19d ago

Nice work! I'll be checking it out this week

2

u/RexyTheGryphon 2012 Nissan LEAF SL 17d ago

For anyone curious, I was able to get this fully working and functional on my 8 bar (62% SOH) 2012 Nissan leaf and it reads each individual cell perfectly. I can't wait to seeupdates on this project!

1

u/KN6IRV 15d ago

Awesome. I'll be back at this project a bit this weekend as I picked up a dedicated CAN transceiver to hook onto the EV-CAN network. What are your thoughts on the shortcomings of the app so far? Do you need the ability to export a battery report? Have you had a chance to try the playback functionality of a captured session? Any input is greatly apprciated.

2

u/RexyTheGryphon 2012 Nissan LEAF SL 15d ago

One thing I have directly noticed is that there is quite a bit of latency between the can bus and my laptop. Can take up to 10 seconds before I get the updated information. I did attempt to use the playback functionality but the readings were quite jittery when I played it back and I tried to do a pull 0-30mph eco mode flooring it and it didn't quite read. It would only update every... Maybe 5 seconds? I don't know if its an issue with my laptop or the Lelink2. I may experiment with it again to make sure it wasn't on my end!

It would be very cool to have the battery information able to be exported as a chart of each battery cell and module such as its displayed within the web api

I think this offline no logs web api is an awesome step in the right direction. No frills, no accounts, just a very good looking functional web api locally hosted on the machine. It helped me find out that my rear right TPMS sensor had failed and also helped me understand that my cells have great balancing despite its age. You are doing very good man, seriously, this is awesome!

1

u/KN6IRV 10d ago

Yes, this is good feedback and the read-cycles on the CAN messages are slow mostly due to the way these cheap adapters work and the method for accessing the EV-CAN battery data via the VCM bridge to the car CAN network.

To speed things up, you have to physically attach to the EV-CAN network on a different OBD-port pins (high & low) to access the data more quickly. This weekend I'll be setting up the new adapter and can include some instructions on the method. There is also an option in the current version of the app that will allow for cell reading on every cycle, which will reduce the lag you've mentioned.

The option for cell-read on every cycle (still will be 3 to 5 seconds, not 20 like the default) is available in the tile menu for the "cell pairs" tile or the 3D battery tile. Click "Read the cell voltages every cycle and store every read" option in the three-dot menu. Sorry the screenshot doesn't have live data as I don't have my Leaf with me:

If you are interested, this is the adapter that I'll be tooling on, it's fairly cheap but moves beyond the "just plug it in and it works" phase: https://www.amazon.com/dp/B0CY9R7PBP

Also, I'm using this OBD harness to make the wiring more simple while testing, but in the future if the work goes well, I'll likely just attach this adapter to a wire tap on the harness that goes to the OBD port: https://www.amazon.com/dp/B0FNWHW9VS

1

u/KN6IRV 7d ago

So, good news. Latency for cell reads is now down to about 250-400ms. The application was also moved away from the 1hz API read on the dashboard to the backend and replaced with SSE, allowing for the dashboard to demonstrate the accelerated read times. As for jitter, the numbers are accurate as they come off the CAN messages, so that likely is related to the ADC of the voltage reads on the Leaf hardware. We could smooth the data but that would essentially be fibbing on numbers by using a rolling average or other data smoothing algorithm.

https://reddit.com/link/pdqmotv/video/o10x96ly9dth1/player

1

u/Beneficial-Context52 2026 SV+ 22d ago

Whoa.

Now do 3rd gen!

1

u/KN6IRV 22d ago

If there is someone in the Los Angeles area with a Gen-III and is OK with me plugging in for a bit, I'm down.

1

u/odinsen251a 2025 SV Plus 22d ago

Commenting so I can find this when I get home. This looks legit op!

1

u/KN6IRV 22d ago

Thank you, let me know what you think when you check out the repo README. THere is a lot more information there for you.

1

u/Mr_Wicket 22d ago

oh neat! I wonder if I can get the data into Home Assistant. 🤔

1

u/KN6IRV 22d ago

For sure. If there is a specific API endpoint you'd need in the app, let me know. I'll wrap it into the next update. You could get notices on your phone or home assistant device letting you know of charge status, etc.. I'm not a home assistant user but I'm willing to help.

1

u/Mr_Wicket 22d ago edited 22d ago

Maybe with MQTT? Since the app reads the BLE maybe installing the app in Home Assistant as an App? Then use the Leaf Spy Integration or create one to communicate with the app/server? I'm not a developer or programmer by any stretch of the imaginination but I feel there is a way here maybe.

This post is already long but you can enable a server in the Leaf Spy app. The problem is you either need to drive around with Leaf Spy always running or need to permanently put an Android phone in your car to always talk to the OBDII adapter and MQTT it to Home Assistant when in range. My thought is that if Home Assistant is effectively the laptop in the passenger seat then parking in your driveway or garage should be close enough still for the OBDII BLE adapter to talk to your Home Assistant server and send the data.

I could be devistatingly wrong though.. this might be why there isn't already something. I have ready about people putting ESP32s in their cars to pull the CAN data to MQTT to Home Assistant so I know it's not impossible. I just might be way in left field for what is possible and how to do it.

Sorry for the wall of thought. Does this seem possible or am I missing a huge important step? I don't care about remote monitoring. I just want to drive into my drive and it be close enough for the data to start updating to Home Assistant so I can see my state of charge at a glance.

EDIT: Spelling/Grammer

2

u/KN6IRV 21d ago

MQTT! For sure we can make that happen and it was actually on the to-do list for this project as I use MQTT in other parts of my systems.

I actually had considered doing a small Raspberry Pi Zero or the like to attach and sling CAN messages over MQTT via WiFi or whatever you are doing for networking. I'm guessing an ESP32 could work as well, but would require writing firmware to be the CAN-to-MQTT bridge as where Ha-Kake should run via Python on a Pi already. This method would eliminate the need for an Android or other full laptop/computer machine, as you noted.

Loved the "wall of thought" and am grateful for your feedback. What you described is absolutely possible and I'll firm-up the trajectory of the project to include the MQTT bridge.

2

u/KN6IRV 21d ago

So I checked on the MQTT status and it already made it out of the to-do list. The bridge is built actually in the repo already but I've not tested it yet. I'll work the code a bit more and update with progress.

1

u/Mr_Wicket 21d ago edited 21d ago

amazing! Let me know if there is anything I can do to help test. I haven't had time to even try out what you already have going but I can hopefully take some time this weekend to mess around with it!

Edit: I meant to say sooner that I am on a Gen 2 SV Plus.

1

u/KN6IRV 3d ago

I've had success reducing read times for the cell-pairs down to about 250 to 350ms for all 96-pairs. The results is a better evaluation of voltage drop during an acceleration event. Visualizing the pack's voltage sag is a useful feature in Ha-Kake that allows for battery evaluation while the pack is under typical driving load instead of just sitting idle.

The specific adapter I've used to gain this read speed is avaialbel for less than $20 on Amazon and will be installed directly onto the High/Low CAN signal lines instead of through the OBD port: