Monday, February 20, 2017

 I show how to collect detailed CAN bus data from a Tesla Model S, and display it in the car's own web browser!

Complete Raspberry Pi with CAN bus shield and 12V buck converter:

Tesla diagnostic connector:

RPi CAN bus tutorial:

Get node.js installed on the RPi:

I used, which is a module that installs into node.js:

Diagnostic connector pinout (scroll through the images):

Tesla CAN bus reverse engineering:

Basic sequence to setup the server on the Pi:
sudo ip link set can0 type can bitrate 500000 listen-only on
sudo ip link set can0 up

candump -cae can0,0:0,#FFFFFFFF

candump -cae can0,0:0,#FFFFFFFF | grep 106 | awk -Winteractive '{ print $10}' | node app.js

I will post the node.js code on my blog:

Support Applied Science on Patreon:


var readline = require('readline');
var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
pipedata = '';
rl.on('line', function(line){
pipedata = line;

var http = require('http'),
    fs = require('fs'),
    // NEVER use a Sync function except at start-up!
    index = fs.readFileSync(__dirname + '/index.html');

// Send index.html to all requests
var app = http.createServer(function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/html'});

// server listens to our app
var io = require('').listen(app);

// Send current time to all connected clients
function sendTime() {
//    io.emit('time', { time: new Date().toJSON() });
    io.emit('time', pipedata);

// Send current time every 10 secs
setInterval(sendTime, 100);

// Emit welcome message on connection
io.on('connection', function(socket) {
    // Use socket to communicate with this particular client only, sending it it's own id
    socket.emit('welcome', { message: 'Welcome!', id: });

    socket.on('i am client', console.log);



<!doctype html>



        <script src='/'></script>


            var socket = io();

            socket.on('welcome', function(data) {


                // Respond with a message including this clients' id sent from the server

                socket.emit('i am client', {data: 'foo!', id:});


            socket.on('time', function(data) {



            socket.on('error', console.error.bind(console));

            socket.on('message', console.log.bind(console));

            function addMessage(message) {

              //  var text = document.createTextNode(message);

                  document.getElementById('messages').textContent = message;

        //     el = document.createElement('li'),

               //     messages = document.getElementById('messages');

              //  el.appendChild(text);

              //  messages.appendChild(el);




p.sansserif { font-family: Arial, Helvtica, sans-serif; font-size:300%;}




        <p class = "sansserif" id='messages'>Hello</p>