Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Using a Raspberry Pi 3 to interface with powertrain bus CAN3

This site may earn commission on affiliate links.
At this point, there are several CAN loggers available (TM-Spy, lolachampcar’s logger, obrien28’s Beaglebone Black, and CANtact to name a few). None of them provided quite what I was looking for so I created my own. I’ll be documenting the project here so others can follow along.

Features:

Powertrain CAN3 interface and logging
Optimized for output through HTTP/CGI

Advantages:

Powered directly by 12 V line on the connector
Wifi capability on the Pi 3 allows me to access over home network, remotely (VPN), or while on the go through an in-car hotspot
Robustness. Eventually I plan to interface the logging with my server DB through a web based API

You will need:

Raspberry Pi 3
PiCAN2 shield with DC DC converter (priced below Evenchick's CANtact)
CAN3 to DB9 connector (FastTech, OVMS cable)

Setup:

Connect everything together and follow the online setup procedure for PiCAN2. Install python can. Install apache2 and configure for CGI. Place python scripts (downloaded from Github) in cgi-bin. Design a simple interface. You can copy mine – easy enough to replicate with screenshots below, otherwise create your own UI.

Misc. notes: Vampire draw is not appreciably altered. Idle power consumption 1-2 watts. My car still sleeps like a beauty for 8-10 hours before waking to recharge the 12 V. This is a normal sleep cycle. Still having issues with the in-car hotspot so I had to make the graph in my driveway. Granny acceleration wasn’t very exciting, but I did it mostly as a test to see if it could keep up with the frame rates. I measured 1700 fps in my single motor and had no issues.

Github (apach3guy)

apach3guy · GitHub

Disclaimer: Note that this project provided me with my first experience coding in Python… and also my first experience interfacing with a Controller Area Network. I am far from fluent in any coding language. So yes, I’m sure there are bugs and issues will crop up (especially with signed integers), but it is tested and working on my setup.

Thanks go to wk057 and obrien28 for providing the bulk of the framework.

chart.png
IMG_0049.PNG
IMG_0050.PNG
 
Still need to figure out what's going on with pack current. Seems to have trouble with data that spills over 1000 A, but no trouble with those just a hair below. I've updated my decode to match wk's and I'll give it another go.
 
Hey apacheguy, while waiting for my PiCAN2 board to arrive I decided to get everything installed and squared up. I found a problem in your latest GIT pull. bms.py line 60 is missing a "0x" in front of "7FFF" which creates a syntax error.

My PiCAN shield should be here tomorrow (the USPS apparently has a rather large definition of "2" when it comes to "2-day priority"). The OVMS cable is on a slow boat from China (literally).
 
Last edited:
CAN spec calls out on the Fasttech cable. Close the solder jumpers SJ1-3 on the right.

Other misc notes:

Cable attaches to CAN output below the 17".
Scripts all generate web output except for logger and logger_spc. Logger is to replicate Bill's logger functionality. Logger_spc is intended to log a supercharging session for 45 min or so.
 
  • Like
Reactions: FlasherZ