Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register
  • The final cut of the 8th episode of the Tesla Motors Club Podcast, featuring Balazs Biro, of the prominent Hungarian EV channel Villanyautósok, is now available. You can watch it now on YouTube or listen to it on all major podcast networks.

Using a Raspberry Pi 3 to interface with powertrain bus CAN3

apacheguy

S Sig #255
Oct 21, 2012
5,119
1,308
So Cal
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
 

FlasherZ

Sig Model S + Sig Model X + Model 3 Resv
Jun 21, 2012
7,028
1,025
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

Products we're discussing on TMC...

About Us

Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.

Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


SUPPORT TMC
Top