close-circle
Close
0%
0%

Volkswagen CAN BUS Gaming

Controlling a VW CAN BUS dashboard of a Polo 6R with an Arduino and a CAN BUS shield using the Telemetry API of Euro Truck Simulator 2

Similar projects worth following
close
Ever wanted to play a car/truck simulator with a real dashboard on your PC? Me too! I'm trying to control a VW Polo 6R dashboard via CAN Bus with an Arduino Uno and a Seeed CAN Bus Shield. Inspired by Silas Parker.

[!!!] PLEASE NOTE [!!!]
This project only works with an instrument cluster of a Volkswagen Polo 6R.
I can't give you any help when you try out this project with other instruments from different manufacturers, as every company has their own CAN BUS protocol.

I use this dashboard in combination with a Logitech G27 wheel and coded a program for it. Just come round to my other Hackaday Project: https://hackaday.io/project/7059-logitech-g27-compatibility-tool

Click on one of the following Links to navigate through the project page:

All Project LogsAll CAN Codes
Project Page @ Seeed Studios
Silas Parker's Blog
YouTube ChannelYouTube Playlist
Download CenterSources
Supporters and Sponsors

See the project in action:

German demonstration: http://youtu.be/BZKrnzsYgRA

VWCode3.0_static.ino

Newest version of test sketch. For Arduino with Seeed CAN BUS Shield and installed libraries.

ino - 12.51 kB - 12/30/2016 at 15:31

download-circle
Download

VWRadio_Setup.exe

The software used in my latest videos. It simulates an RNS310 from VW and plays online radio stations over the Internet (m3u-Streams and RTMP://) and also plays Windows Media Playlists (WPL file format). You can also visit some webpages (like maps for games) with it. Have fun. This file is a WinRAR-self-extracting archive. Just double-click it and install it. For support, or feedback please PM me.

x-msdownload - 16.04 MB - 04/06/2016 at 21:50

download-circle
Download

3D-Print Radio-Case.stl

3D-Print Radio-Case (STL 3d-printable Sketch)

- 30.43 MB - 12/24/2015 at 14:30

download-circle
Download

3D-Print Radio-Case.123dx

3D-Print Radio-Case (Autodesk 123D Design Project File)

- 4.68 MB - 12/24/2015 at 14:30

download-circle
Download

frontpanel.stl

3D-Print Radio Front Panel (STL 3d-printable Sketch)

- 47.70 MB - 12/24/2015 at 14:25

download-circle
Download

View all 7 files

View all 7 components

  • New Version of VWRadio available (v1.2.1)

    Leon Bataille06/12/2017 at 14:55 0 comments

    I've just released a newer version for the VWRadio software.

    I fixed several small bugs. Especially the loop after the first launch without a prior configuration file has been fixed.

    There's now the option to enable a graphic visualization for music playback in the lower left corner.

    You can now also shut down your computer within the program. Therefore you have to go to the settings menu and click on exit. There you're can choose either to exit the program or to completely shut down your PC. I'll show you this feature in a future video. But at the moment it's a surprise for what I implemented it in the software.

  • Building a dashboard desk

    Leon Bataille06/09/2017 at 17:12 1 comment

    Hi there.

    It's been a long time since the last update.
    I'm back with some great news and some exciting plans.

    At the moment I'm building a new desk out of an Polo 6R dashboard. All buttons of the dashboard shall be used as controller in ETS2 and other simulation games.

    Even the Navigation System will display the map of the game (at least that's my goal).

    So here're some pictures of my new sub-project:

  • Creating an automatic Install and Setup Tool

    Leon Bataille05/08/2017 at 11:39 0 comments

    I'm in the process of building an Installation and Setup Tool for those of you, who wanted a detailed instruction on how to set everything up. This software does the job for you!

    I hope to complete this Setup Tool as fast as I can.

    Here's already a screenshot (You can manually choose the packages which you want to install)

  • New Demo-Sketch for Dashboard

    Leon Bataille12/30/2016 at 15:32 3 comments

    Hi!

    Just as promised a few days ago: Here's the new version of the test sketch.

    It contains more CAN BUS functions (such as much more LEDs to switch on or off) and is completely rewritten for a better structure and easier usage.

    These are the LEDs you can manually turn on or off in the sketch

    There's also a new section where you can setup a userdefined setup for testing your dashboard's functions!

    You find the new sketch in the download section of this project,

    or directly here.

    Best regards, and a happy new year!

  • More dashboard functions found

    Leon Bataille12/27/2016 at 21:20 2 comments

    Happy Holidays to all of you!

    The last few days I worked pretty hard on finding new functions of some CAN Commands for the dashboard!

    New functions I found:

    • Battery low warning
    • Fog Light
    • High Beam
    • ABS signal
    • Seat Belt warning
    • Hand brake
    • Low tire pressure warning
    • Offroad mode
    • Diesel particle filter
    • Diesel preheater
    • Water temperature alarm

    I also rewrote the hole demo script with more explanations and comments. The speed needle should also be more accurate (but sadly still not perfect yet)

    I will release the new demo source code in the next few days, so stay tuned.

    And I wish all of you a happy new year!

  • It's been a while

    Leon Bataille07/27/2016 at 11:36 5 comments

    After moving to antother city and my exams there's now time again for hackin'!

    So expect frequent updates from now on.

    I've bought a real dashboard from a VW Polo 6R and I want to build something like a desk out of it. So you can play great racing games and work on it.

    I'm really excited about the next months and hope to get everything working :D

  • Dashboard Photoshoot

    Leon Bataille04/18/2016 at 11:45 0 comments

    Hello Tech-Enthusiasts!

    I just updated the thumbnails for this project. Therefore I got help in a photo studio to take some better profile pics. I hope you enjoy them!

  • 100 Followers!

    Leon Bataille04/11/2016 at 18:07 0 comments

    Thank you for your awesome support!

    We've reached the big mark of one hundred followers!

    This is just awesome! Thank you.

  • RNS310 Simulator software available for Download

    Leon Bataille04/06/2016 at 21:59 0 comments

    Hi!

    I used the last time to build a Windows software which simulates an VW Radio (RNS 310).
    You can find it in the download section of this project page. Or here

    I coded it from scratch and I even drew every single image by myself. So please don't hesitate to PM me for bug reports :D

    For support or feedback please also write me an PM.

    Thanks!

  • VW RNS Simulator running on Android

    Leon Bataille02/25/2016 at 11:19 0 comments

    Finally I ported my VW RNS Simulator software on to Android Platform.

View all 47 project logs

  • 1
    Step 1

    Known CAN Codes so far:

    For CAN Codes please visit the Sources-Page.

  • 2
    Step 2

    Instruction Video:

  • 3
    Step 3

    Arduino Source Code:

    //##############################################################################################################  
    
    //Volkswagen CAN BUS Gaming
    //Test Sketch v3.0
    //(C) by Leon Bataille 2015-2016
    //Hackaday Project Page: https://hackaday.io/project/6288-volkswagen-can-bus-gaming
    
    //Sketch information #DO NOT REMOVE!
    String game = "VW Static v3.0";
    String vendor = "Leon Bataille";
    //END Sketch information
    
    //For individual setup scroll down to the section MAIN CONFIGURATION
    
    //##############################################################################################################  
    
    //Libraries
    #include <mcp_can.h>            //CAN Bus Shield Compatibility Library
    #include <SPI.h>                //CAN Bus Shield SPI Pin Library
    #include <Servo.h>              //Library for Controlling Servos
    #include <Wire.h>               //Extension Library for measuring current
    #include <LiquidCrystal_I2C.h>  //Libraries for controlling LC Displays
    #include <LCD.h>                
    #include <LiquidCrystal.h>
    
    //Definition
    #define lo8(x) ((int)(x)&0xff)
    #define hi8(x) ((int)(x)>>8)
    
    //Variables (Dashboard LEDs)
    int high_beam = 13;
    int fog_beam = 12;
    int park_brake = 11;
    
    //Variables (VW Dashboard Adapter)
    int LEFT_INDICATOR  = A0;
    int RIGHT_INDICATOR = A1;
    int PARKING_BREAK   = A2;
    int FUEL_WARNING    = A3;
    
    //Variables (Dashboard Functions)
    int turning_lights = 3;
    boolean turning_lights_blinking = true;
    int turning_lights_counter = 0;
    int temp_turning_lights = 0;
    boolean backlight = false;
    int oilpswitch = 8;
    int pack_counter = 0;
    boolean add_distance = false;
    int drive_mode = 0;
    int distance_multiplier = 2;
    boolean oil_pressure_simulation = true;
    boolean door_open = false;
    boolean clutch_control = false;
    int temp_clutch_control = 0;
    boolean check_lamp = false;
    int temp_check_lamp = 0;
    boolean trunklid_open = false;
    int temp_trunklid_open = 0;
    boolean battery_warning = false;
    int temp_battery_warning = 0;
    boolean keybattery_warning = false;
    int temp_keybattery_warning = 0;
    int lightmode = 0;
    boolean seat_belt = false;
    int temp_seat_belt = 0;
    int engine_control = 0;
    int temp_dpf_warning = 0;
    boolean dpf_warning = false;
    boolean light_fog = false;
    int temp_light_fog = 0;
    boolean light_highbeam = false;
    int temp_light_highbeam = 0;
    boolean signal_abs = false;
    boolean signal_offroad = false;
    boolean signal_handbrake = false;
    boolean signal_lowtirepressure = false;
    boolean signal_dieselpreheat = false;
    boolean signal_watertemp = false;
    int temp_signal_abs = 0;
    int temp_signal_offroad = 0;
    int temp_signal_handbrake = 0;
    int temp_signal_lowtirepressure = 0;
    int temp_signal_dieselpreheat = 0;
    int temp_signal_watertemp = 0;
    
    //Variables (Speed and RPM)
    int speed = 0;
    byte speedL = 0;
    byte speedH = 0;
    
    int rpm = 0;
    short tempRPM = 0;
    byte rpmL = 0;
    byte rpmH = 0;
    
    int distance_adder = 0;
    int distance_counter = 0;
    
    //Variables LCD
    LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlightpin, polarity
    
    //Variables CAN BUS
    /* the cs pin of the version after v1.1 is default to D9
    v0.9b and v1.0 is default D10 */
    const int SPI_CS_PIN = 9;
    MCP_CAN CAN(SPI_CS_PIN);  // Set CS pin
    
    //Setup Configuration
    void setup()
    {
      //Initialize LCD
      lcd.begin(16,2);
      lcd.backlight();
      showLCD("VW Dashboard","by Leon Bataille");
      delay(2000);
      
      showLCD("VW Dashboard","booting...");
      
      //Define Dashboard LEDs as Outputs
      pinMode(high_beam, OUTPUT);
      pinMode(fog_beam, OUTPUT); 
      pinMode(park_brake, OUTPUT);
      pinMode(oilpswitch, OUTPUT);
      
      //Visual Start Sequence on Dashboard
      digitalWrite(high_beam, HIGH);
      digitalWrite(fog_beam, HIGH);
      digitalWrite(park_brake, LOW);
      digitalWrite(PARKING_BREAK, HIGH);
      delay(500);               // wait for a second
      digitalWrite(high_beam, LOW);
      digitalWrite(FUEL_WARNING, HIGH);
      digitalWrite(PARKING_BREAK, LOW);
      delay(500);
      digitalWrite(FUEL_WARNING, LOW);
      digitalWrite(LEFT_INDICATOR, HIGH);
      digitalWrite(RIGHT_INDICATOR, HIGH);
      digitalWrite(fog_beam, LOW);
      delay(500);
      digitalWrite(LEFT_INDICATOR, LOW);
      digitalWrite(RIGHT_INDICATOR, LOW);
      
      //Begin with Serial Connection
      Serial.begin(115200);
      
      //Show Sketch information on LCD
      showLCD(game,"by "+vendor);
      
      //Begin with CAN Bus Initialization
    START_INIT:
    
        if(CAN_OK == CAN.begin(CAN_500KBPS))                   // init can bus : baudrate = 500k
        {
            Serial.println("CAN BUS Shield init ok!");
        }
        else
        {
            Serial.println("CAN BUS Shield init fail");
            Serial.println("Init CAN BUS Shield again");
            delay(100);
            goto START_INIT;
        }
    }
    
    
    //Reload LC Display
    void showLCD(String line1,String line2)
    {  
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print(line1);
      lcd.setCursor(0, 1);
      lcd.print(line2);
    }
    
    
    //Send CAN Command (short version)
    void CanSend(short address, byte a, byte b, byte c, byte d, byte e, byte f, byte g, byte h)
    {
      unsigned char DataToSend[8] = {a,b,c,d,e,f,g,h};
      CAN.sendMsgBuf(address, 0, 8, DataToSend);
    }
    
    //fuel gauge (0-100%)
    void Fuel(int amount)
    {
      pinMode(2, INPUT);
      pinMode(3, INPUT);
      pinMode(4, INPUT);
      pinMode(5, INPUT);
      pinMode(6, INPUT);
      pinMode(7, INPUT);
     
      if (amount >= 90)
      {
        pinMode(2, OUTPUT);
        digitalWrite(2, LOW);
        return;
      }
      if (amount >= 75)
      {
        pinMode(3, OUTPUT);
        digitalWrite(3, LOW);
        return;
      }
      if (amount >= 50)
      {
        pinMode(4, OUTPUT);
        digitalWrite(4, LOW);
        return;
      }
      if (amount >= 25)
      {
        pinMode(5, OUTPUT);
        digitalWrite(5, LOW);
        return;
      }
      if (amount >= 10)
      {
        pinMode(6, OUTPUT);
        digitalWrite(6, LOW);
        return;
      }
      if (amount >= 0)
      {
        pinMode(7, OUTPUT);
        digitalWrite(7, LOW);
        return;
      }
    }
    
    //Loop
    void loop()
    {
    //##############################################################################################################  
      
      //MAIN SETUP FOR OPERATION
    
      //Set constant speed and RPM to show on Dashboard
      speed = 0;                        //Set the speed in km/h
      rpm = 800;                        //Set the rev counter
      Fuel(30);                          //Set the fuel gauge in percent
      
      //Set Dashboard Functions
      backlight = true;                  //Turn the automatic dashboard backlight on or off
      turning_lights = 0;                //Turning Lights: 0 = none, 1 = left, 2 = right, 3 = both
      turning_lights_blinking = false;   //Choose the mode of the turning lights (blinking or just shining)
      add_distance = false;              //Dashboard counts the kilometers (can't be undone)
      distance_multiplier = 2;           //Sets the refresh rate of the odometer (Standard 2)
      signal_abs = false;                //Shows ABS Signal on dashboard
      signal_offroad = false;            //Simulates Offroad drive mode
      signal_handbrake = false;          //Enables handbrake
      signal_lowtirepressure = false;    //Simulates low tire pressure
      oil_pressure_simulation = true;    //Set this to true if dashboard starts to beep
      door_open = false;                 //Simulate open doors
      clutch_control = false;            //Displays the Message "Kupplung" (German for Clutch) on the dashboard's LCD
      check_lamp = false;                //Show 'Check Lamp' Signal on dashboard. B00010000 = on, B00000 = off
      trunklid_open = false;             //Simulate open trunk lid (Kofferraumklappe). B00100000 = open, B00000 = closed
      battery_warning = false;           //Show Battery Warning.
      keybattery_warning = false;        //Show message 'Key Battery Low' on Display. But just after first start of dashboard.
      light_fog = false;                 //Enable Fog Light
      light_highbeam = false;            //Enable High Beam Light
      seat_belt = false;                 //Switch Seat Betl warning light.
      signal_dieselpreheat = false;      //Simualtes Diesel Preheating
      signal_watertemp = false;          //Simualtes high water temperature
      dpf_warning = false;               //Shows the Diesel particle filter warning signal.
      
      
    //##############################################################################################################  
      
      //Conversion Speed
      speed = speed / 0.0075; //KMH=1.12 MPH=0.62
      
      //Conversion Low and High Bytes
      speedL = lo8(speed);
      speedH = hi8(speed);
      
      tempRPM = rpm*4;
      rpmL = lo8(tempRPM);
      rpmH = hi8(tempRPM);
      
      if (add_distance == true)
      { 
        distance_adder = speed * distance_multiplier;
        distance_counter += distance_adder;
        if (distance_counter > distance_adder) { distance_counter = 0; }
      }
      
      if ( oil_pressure_simulation == true)
      {
      //Set Oil Pressure Switch
        if (rpm > 1500) {
          digitalWrite(oilpswitch, LOW);
          }
        else {
          digitalWrite(oilpswitch, HIGH);
          }
      }
     
      /*Send CAN BUS Data*/
      
      //Immobilizer
      CanSend(0x3D0, 0, 0x80, 0, 0, 0, 0, 0, 0);
      
      //Engine on and ESP enabled
      CanSend(0xDA0, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
      
      //Enable Cruise Control
      //CanSend(0x289, 0x00, B00000001, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
      
      //Dashboard Functions
      
      //Turning Light blinking
      if (turning_lights_blinking == true)
      {
        if (turning_lights_counter == 15)
        {
          temp_turning_lights = turning_lights;
          turning_lights_counter = turning_lights_counter + 1;
        }
        if (turning_lights_counter == 30)
        {
          temp_turning_lights = 0;
          turning_lights_counter = 0;
        }
        else
        {
          turning_lights_counter = turning_lights_counter + 1;
        }
      }
      else
      {
        temp_turning_lights = turning_lights;
      }
      
      //Check main settings
      
      //DPF
      if (dpf_warning == true) temp_dpf_warning = B00000010;
      else temp_dpf_warning = B00000000;
      
      //Seat Belt
      if (seat_belt == true) temp_seat_belt = B00000100;
      else temp_seat_belt = B00000000;
      
      //Battery Warning
      if (battery_warning == true) temp_battery_warning = B10000000;
      else temp_battery_warning = B00000000;
      
      //Trunk Lid (Kofferraumklappe)
      if (trunklid_open == true) temp_trunklid_open = B00100000;
      else temp_trunklid_open = B00000000;
      
      //Check Lamp Signal
      if (check_lamp == true) temp_check_lamp = B00010000;
      else temp_check_lamp = B00000000;
      
      //Clutch Text on LCD
      if (clutch_control == true) temp_clutch_control = B00000001;
      else temp_clutch_control = B00000000;
      
      //Warning for low key battery
      if (keybattery_warning == true) temp_keybattery_warning = B10000000;
      else temp_keybattery_warning = B00000000;
      
      //Lightmode Selection (Fog Light and/or High Beam)
      if (light_highbeam == true) temp_light_highbeam = B01000000;
      else temp_light_highbeam = B00000000;
      if (light_fog == true) temp_light_fog = B00100000;
      else temp_light_fog = B00000000;
      lightmode = temp_light_highbeam + temp_light_fog;
      
      //Engine Options (Water Temperature, Diesel Preheater)
      if (signal_dieselpreheat == true) temp_signal_dieselpreheat = B00000010;
      else temp_signal_dieselpreheat = B00000000;
      if (signal_watertemp == true) temp_signal_watertemp = B00010000;
      else temp_signal_watertemp = B00000000;
      engine_control = temp_signal_dieselpreheat + temp_signal_watertemp;
      
      //Drivemode Selection (ABS, Offroad, Low Tire Pressure, handbrake)
      if (signal_abs == true) temp_signal_abs = B0001;
      else temp_signal_abs = B0000;
      if (signal_offroad == true) temp_signal_offroad = B0010;
      else temp_signal_offroad = B0000;
      if (signal_handbrake == true) temp_signal_handbrake = B0100;
      else temp_signal_handbrake = B0000;
      if (signal_lowtirepressure == true) temp_signal_lowtirepressure = B1000;
      else temp_signal_lowtirepressure = B0000;
      
      drive_mode = temp_signal_abs + temp_signal_offroad + temp_signal_handbrake + temp_signal_lowtirepressure;
      
      
      //Send CAN data every 200ms
      pack_counter++;
      if (pack_counter == 20)
      {
        //Turning Lights 2
        CanSend(0x470, temp_battery_warning + temp_turning_lights, temp_trunklid_open + door_open, backlight, 0x00, temp_check_lamp + temp_clutch_control, temp_keybattery_warning, 0x00, lightmode);
        
        //Diesel engine
        CanSend(0x480, 0x00, engine_control, 0x00, 0x00, 0x00, temp_dpf_warning, 0x00, 0x00);
        
        ///Engine
        //CanSend(0x388, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
        
        
        //Cruise Control
        //CanSend(0x289, 0x00, B00000101, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
        
        pack_counter = 0;
      }
      
      //Motorspeed
      CanSend(0x320, 0x00, (speedL * 100), (speedH * 100), 0x00, 0x00, 0x00, 0x00, 0x00);
      
      //RPM
      CanSend(0x280, 0x49, 0x0E, rpmL, rpmH, 0x0E, 0x00, 0x1B, 0x0E);
        
      //Speed
      CanSend(0x5A0, 0xFF, speedL, speedH, drive_mode, 0x00, lo8(distance_counter), hi8(distance_counter), 0xad);
        
      //ABS
      CanSend(0x1A0, 0x18, speedL, speedH, 0x00, 0xfe, 0xfe, 0x00, 0xff);
      
      //Airbag
      CanSend(0x050, 0x00, 0x80, temp_seat_belt, 0x00, 0x00, 0x00, 0x00, 0x00);
        
      //Wait a time
      delay(20);
    }
    

View all 3 instructions

Enjoy this project?

Share

Discussions

Udo Schneider wrote 08/30/2017 at 18:17 point

What's the newest (best?) source for wiring? On first glance the fritzing diagram is not identical to Is0-Mick's diagram ... and both do contain things which didn't work on the dashboard I'm using. Maybe (the source for) the PCB might be a good reference - but where to get that? 

  Are you sure? yes | no

Anthony Whittle wrote 07/27/2017 at 13:15 point

Hello again,

When will the installation setup tool be available?

Thanks

  Are you sure? yes | no

Anthony Whittle wrote 07/07/2017 at 17:46 point

Hi,

Does it work with the petrol version dash?

Thanks

  Are you sure? yes | no

Leon Bataille wrote 07/11/2017 at 18:58 point

Should also work with the petrol version, yes.

  Are you sure? yes | no

Steph Geiselh. wrote 04/28/2017 at 10:00 point

Hey Leon,

I have seen a wiring diagram for the engine temperature and the fuel gauge on a photo.

Can we see this circuit diagram in more details?? Thanks :)

  Are you sure? yes | no

Leon Bataille wrote 07/11/2017 at 18:59 point

Yes of course :) Did you mean the outside temperature insted of the engine temp.?

  Are you sure? yes | no

Tom wrote 04/17/2017 at 09:14 point

Hello,

I'm trying to bring this project to life on my own, however - it seems like the cluster isn't communicating with Arduino.

Have you removed a 62k resistor from can bus shield?

Regs,

Tom

  Are you sure? yes | no

Leon Bataille wrote 07/11/2017 at 19:01 point

no, i didn't remove any parts from the can bus shield. however it could be that newer versions of the can bus shield are little bit different. especially the CS pin could have changed. I think mine has D9 as CS pin and newer have D10. but I'm not sure at the moment.

  Are you sure? yes | no

Tom wrote 07/12/2017 at 06:46 point

Hi Leon!

Thank you for the reply. Indeed - mine shield has CS pin on D10, but that wasn't the case. It turned out that on my shield CAN high an low pins are swapped (pins itself are fine, but the pins' description on the shield are contrariwise), so I've got it working :)

Unfortunately - I couldn't get the Passat's B6 Instrument to work (speed gauge was jumping for few seconds and after that - it's been turning off), so I've took a instrument cluster out from... Fiat Panda and it's working perfect ;)

Thank you very much for this project :)

Best regs
Tom


  Are you sure? yes | no

lego wrote 04/16/2017 at 12:51 point

i've got the tacho, the arduino and the canbus shield, got the code on the arduino but when i go into ets 2 nothing happens. the rpm needle stays at 800 rpm and that's it. 

could it be from the plugin? maybe they changed something in the telemetry. 

Silas's plugin is 3 years old...

  Are you sure? yes | no

Leon Bataille wrote 07/11/2017 at 19:02 point

Oh this would be not godd (*panic). I will double check this and reply when I know more about it. Thanks for the info.

  Are you sure? yes | no

Felix wrote 03/15/2017 at 09:10 point

I've purchased the exact same tacho from a 6R with the same pinout and all. But when I connect it it says no key and beeps then no function with any of the can bus calls. Do you have any suggestions to bypass this or what might be the issue? How do you connect the immobiliser pins or is it not necessary to touch?

  Are you sure? yes | no

Leon Bataille wrote 07/11/2017 at 19:04 point

The tacho should work even when it says "no key". Mine tells me the same. Did you upload my newer script or did you try to send one single command?

  Are you sure? yes | no

animireddysaip wrote 01/26/2017 at 11:33 point

Hie i am a student trying to build a two way communication (using can bus protocol) between two arduino's which have some sensors and actuators on them, 

can you please help me with the code required for sending and receiving the sensor values on CAN BUS protocol. (atleast where to refer)

  Are you sure? yes | no

Leon Bataille wrote 07/11/2017 at 19:06 point

Hi, sorry for my late replay. But I hope it's not too late ;-). There are very useful examples for the CAN BUS protocol in the Arduino library of the Seeedstudio CAN BUS Shield. Just open Arduino IDE, import the library and click on File>Examples>CAN.

There should be everything you need.

  Are you sure? yes | no

vitecd wrote 01/24/2017 at 09:18 point

wiring diagram has some missing components

  Are you sure? yes | no

Leon Bataille wrote 01/24/2017 at 10:45 point

thanks for the info. yes the diagram is out of date.

I'll make a new one as soon as i can.

  Are you sure? yes | no

bigvicproton wrote 01/08/2017 at 03:35 point

Perhaps I am missing something, but I have the Silas Parker plugin installed and telemetry is working.  Compiled on the Arduino and running RMP goes to 800, so I know the CanBus Shield is talking to the cluster.  Yet when playing ETS2 it is not talking to the cluster.  What am I doing wrong?

  Are you sure? yes | no

Leon Bataille wrote 01/24/2017 at 09:44 point

Hi, did you check the config file inside the plugin folder of ETS2? (i.e. C:\Program Files\Euro Truck Simualtor 2\bin\win_x86\plugins\dash_plugin.txt)

You have to configure the COM Port of your Arduino inside this file.

Best regards,

Leon

  Are you sure? yes | no

Jeroen van der Velden wrote 01/05/2017 at 14:18 point

Hi Leon, I lost my board schematic you send me along with your Board. Could you please send me a copy? Best Regards, Jeroen

  Are you sure? yes | no

bigvicproton wrote 12/21/2016 at 14:23 point

Hi Leon,  Could you show us the code you used to get the gas gauge working? 

  Are you sure? yes | no

trandi wrote 10/25/2016 at 22:24 point

Hi Leon, I'm trying to replicate your work but using a Skoda Octavia 2002 instrument cluster and a LM3S8962 dev board from Texas Instruments (which has a CAN peripheral included).

I could immediately turn on / off a few lights and the RPM indicator (https://goo.gl/photos/JdxRyuY42Auv7dXZ9 ) but now I'm completely stuck with the Speed indicator and/or the other 2 smaller ones (oil temperature and petrol tank).

I've obviously tried you codes for the speed but they don't seem to work... any other idea ?

Dan

  Are you sure? yes | no

jsfrederick2011 wrote 06/07/2016 at 11:25 point

hey leon is there a way to PM you?

  Are you sure? yes | no

Leon Bataille wrote 06/07/2016 at 14:26 point

yes of course, just click on my name and write me an PM :)

  Are you sure? yes | no

Paul wrote 05/18/2016 at 19:49 point

Hello Leon,

just for the understanding:

Can I use your code in combination with Silas Parkers plugin to use it with ETS2?

If yes can I simply add your commands to the plugin from Silas?

With greatest wishes: Paul

  Are you sure? yes | no

Leon Bataille wrote 05/19/2016 at 04:58 point

Hi Paul,

Yes you can use the Plugin of Silas Parker and the commands I used in combination. 

I also have written the script for this purpose but because of licensing problems I can't publish it. (Silas' Arduino script is published under GNU GPL).

But I try to contact him for a long time in the hope that I can publish my script with his permission.

I'll let you know If I know more

  Are you sure? yes | no

Paul wrote 05/19/2016 at 16:40 point

Thanks for the fast response, then I will have to get out my programming skills again and start coding :)

  Are you sure? yes | no

Paul wrote 05/19/2016 at 17:18 point

Finished coding. You may have a look over it, because I am not that into CAN- and Arduino- coding:

/* Copyright by who knows. 
 *  I took several Pieces from Leon Bataille
 *  and Silas Parker.
 */




#include
String game = "Euro Truck Sim 2";
String vendor = "Leon Bataille";




#define PACKET_SYNC 0xFF
#define PACKET_VER  2




#define SERVO_DIR_NORMAL false
#define SERVO_DIR_INVERT false        




int serial_byte;




const int SPI_CS_PIN = 9;
MCP_CAN CAN (SPI_CS_PIN);// Set CS pin




#include
Servo speedo;
Servo rpm;




int fernlicht = 13;
int nebellicht = 12;
int bremse = 11;




int tempo;
int rpm_int;
boolean hgb = false;
int blinker;




void setup()
{
  Serial.begin(115200);
  
  pinMode(fernlicht, OUTPUT);
  pinMode(nebellicht, OUTPUT); 
  pinMode(bremse, OUTPUT);
  
  digitalWrite(fernlicht, HIGH);
    digitalWrite(nebellicht, HIGH);
    digitalWrite(bremse, LOW);// turn the LED on (HIGH is the voltage level)
    delay(1000);               // wait for a second
    digitalWrite(fernlicht, LOW);
    delay(330);
    digitalWrite(nebellicht, LOW);
    delay(100);
    digitalWrite(bremse, HIGH);
    delay(100);
    digitalWrite(bremse, LOW); 
    delay(100);
    digitalWrite(bremse, HIGH); 
    delay(100);
    digitalWrite(bremse, LOW); 
    delay(100);
    digitalWrite(bremse, HIGH); 
    delay(100);
    digitalWrite(bremse, LOW);
    delay(100);
    digitalWrite(bremse, HIGH);
    delay(1000);
    delay(1000);




    START_INIT:




    if(CAN_OK == CAN.begin(CAN_500KBPS))                   // init can bus : baudrate = 500k
    {
        Serial.println("CAN BUS Shield init ok!");
    }
    else
    {
        Serial.println("CAN BUS Shield init fail");
        Serial.println("Init CAN BUS Shield again");
        delay(100);
        goto START_INIT;
    }
}




void skip_serial_byte()
{
  (void)Serial.read();
}




void read_serial_byte_set_servo(bool invert)
{
  
  serial_byte = Serial.read();
  serial_byte = (serial_byte < 0) ? 0 : ((serial_byte > 180) ? 180 : serial_byte);
  //Tempo
    if (invert) {
      tempo = serial_byte * 0.55;//(180 * 0.6 - serial_byte * -0.6)-110;
      }
    else {
      //tempo = (serial_byte * 0.6)-110;
      }
      //servo.write(180 - serial_byte);
    
        
      if (tempo > 1) {
          //KMH aktualisieren
          for(int i=0;i<5;i++){

            unsigned char stmp[] = {1,128,tempo,0,0,0,0,0};
            CAN.sendMsgBuf(0x5A0, 0, 8, stmp);
            delay(10);
            }
            }
            /*
            //Wenn Nadel auf 0 geht, KMH neu schreiben
            FreqCounter::f_comp= 8;             // Kompensation einstellen
            FreqCounter::start(100);           // Zähler starten für 1000ms
            while (FreqCounter::f_ready == 0)   // warten bis der Zähler fertig ist
            freq=FreqCounter::f_freq;           // Ergebnis lesen
            freq=freq*10; 
            
            */           
          else{
            unsigned char stmp[] = {1,0,0,0,0,0,0,0};
            CAN.sendMsgBuf(0x5A0, 0, 8, stmp);
            }
     




     
}




void read_serial_byte_set_servo2(bool invert){
  serial_byte = Serial.read();
  serial_byte = (serial_byte < 0) ? 0 : ((serial_byte > 180) ? 180 : serial_byte);
  
  //RPM
  if (invert){
      //servo.write(180 - serial_byte);
      rpm_int = (180 * 0.5 - serial_byte * -0.5)-90;  
      unsigned char stmp4[] = {1,0,0,rpm_int,0,0,0,0};
      CAN.sendMsgBuf(0x280, 0, 8, stmp4);
      
      }
    else{
      //servo.write(serial_byte);
      rpm_int = (serial_byte * 0.5)-90;  
      unsigned char stmp4[] = {1,0,0,rpm_int,0,0,0,0};
      CAN.sendMsgBuf(0x280, 0, 8, stmp4);
      
      }
      
  }




void digitalWriteFromBit()
{
  //int portnumber = port;




  
  if ((analogRead(2) < 350) && (analogRead(3) < 350)) {
    //kein Blinker
    blinker = 0;
    
    }
  else if ((analogRead(2) > 350) && (analogRead(3) < 350)) {
    //linker Blinker
    blinker = 1;
    
    }
  else if ((analogRead(3) > 350) && (analogRead(2) < 350 )){
    //rechter Blinker
    blinker = 2;
    
    }
  else if ((analogRead(3) > 350) && (analogRead(2) > 350 )){
    //Warnblinker
    blinker = 3;
    }
    
    unsigned char stmp15[] = {blinker,0,hgb,0,0,0,0,0}; //1,0 = links; 2,0 = rechts; 3,0 = Warn
    CAN.sendMsgBuf(0x470, 0, 8, stmp15);
  
   
}




 void loop(){
  //ABS & KMH
    unsigned char stmp1[] = {0,128};
    CAN.sendMsgBuf(0x1A0, 0, 8, stmp1);    
    
    //Lenkradschloss   
    unsigned char stmp6[] = {0,64,0,0,0,0,0,0};
    CAN.sendMsgBuf(0x3D0, 0, 8, stmp6);
  




  
  if (Serial.available() < 16)
    return;
  
  serial_byte = Serial.read();
  if (serial_byte != PACKET_SYNC)
    return;
    
  serial_byte = Serial.read();
  if (serial_byte != PACKET_VER)
  {
   return;
  }
  
     
  
  read_serial_byte_set_servo(SERVO_DIR_INVERT); // Speed  
  read_serial_byte_set_servo2(SERVO_DIR_INVERT); // RPM
  delay(30);
  
  skip_serial_byte(); // Brake air pressure
  skip_serial_byte(); // Brake temperature
  skip_serial_byte(); // Fuel ratio
  skip_serial_byte(); // Oil pressure
  skip_serial_byte(); // Oil temperature
  skip_serial_byte(); // Water temperature
  skip_serial_byte(); // Battery voltage
    
  
  // Truck lights byte
  serial_byte = Serial.read();
  
  digitalWriteFromBit();  
  
  digitalWriteFromBit();
  
  // Warning lights bytes




  serial_byte = Serial.read();  
  digitalWriteFromBit();
  digitalWriteFromBit();  
  
  // Enabled flags
  serial_byte = Serial.read();
  
  // Text length
  int text_len = Serial.read();
  
  
  // Followed by text
 
      serial_byte = Serial.read();




  }

  Are you sure? yes | no

Paul wrote 05/19/2016 at 19:55 point

Jetzt mal auf Deutsch:

Weißt du eine Möglichkeit die Tankanzeige zu steuern?

Ich habe keinen Tacho von einem 6R sondern von einem Golf V, aber ist das so gravierend anders? MfG Paul

  Are you sure? yes | no

Danel K wrote 05/11/2016 at 05:04 point

I rarely get impressed to a point where i truly say WOW out loud (WOL?) but this project, hoooooly... **** = WOW!!!

  Are you sure? yes | no

Leon Bataille wrote 05/11/2016 at 05:14 point

Thanks Danel!

I should remember WOL, sounds great ;

  Are you sure? yes | no

Einārs Deksnis wrote 04/30/2016 at 13:25 point

Hi Leon!
Thanks for sharing Your work! 
This inspired to  use this VW dashboard in one of my projects. 
Also I managed to get working speed gauge, so thought this can be useful for you too.
Basically, when I got trip distance counter kind of working, speed gauge stopped detecting fault and don't drop to zero anymore. 
Here is my code for reference:

void CAN_Speed_Send(uint16_t speed){
    
    uint16_t sp = speed / 0.0075;
    uint16_t distance_adder = speed*2;

    counter += distance_adder;
    if( counter > distance_adder ) { counter = 0; } 

    CAN_TX_DATA_BYTE1(CAN_TX_MAILBOX_SPEED) = 0xFF;
    CAN_TX_DATA_BYTE2(CAN_TX_MAILBOX_SPEED) = LO8(sp);
    CAN_TX_DATA_BYTE3(CAN_TX_MAILBOX_SPEED) = HI8(sp);
    CAN_TX_DATA_BYTE4(CAN_TX_MAILBOX_SPEED) = 0x02 | 0x08;  
    CAN_TX_DATA_BYTE5(CAN_TX_MAILBOX_SPEED) = 0x00;
    CAN_TX_DATA_BYTE6(CAN_TX_MAILBOX_SPEED) = LO8(counter);
    CAN_TX_DATA_BYTE7(CAN_TX_MAILBOX_SPEED) = HI8(counter);
    CAN_TX_DATA_BYTE8(CAN_TX_MAILBOX_SPEED) = 0x00;   
    CAN_SendMsgSPEED();

}

After weird operation of arduino with CAN-BUS Shield, which suddenly stopped sending data on MISO line, I switched to PSoC5LP chip. 

  Are you sure? yes | no

Leon Bataille wrote 04/30/2016 at 14:38 point

Wow! Thank you!

I'll try this as fast as I can! It's great to have such a great community here on hackaday.

You helped me and everyone who wants to rebuilt this project a lot.

I'll keep you updated!

  Are you sure? yes | no

Einārs Deksnis wrote 04/30/2016 at 19:54 point

You are welcome!
Be aware that CAN-BUS message interval shall be constant.
I made 10ms timer to do this.

CY_ISR(Timer10ms){
    pack_counter++;
    if(pack_counter == 20){ //Some messages sending 20x times less
        CAN_IMO_Send();
        CAN_AIRBAG_Send();
        CAN_LIGHT_Send(0, backlight);
        CAN_AIRBAG_Send();
        pack_counter = 0;
    } 
        CAN_ENGINE_Send();
        CAN_RPM_Send(rpm);  
        CAN_Speed_Send(speed);
        CAN_ABS_Send();   
}

There is magic constant which is dependent on message interval.

distance_adder = speed*X;  

I got gauge working when X=2 with 10ms interval, but it can be tuned for other intervals.
Unfortunately trip distance counter on dashboard don't count adequate distance (it is slower than necessary).  In my application it doesn't matter, but probably it would be necessary to read messages on polo CAN-BUS to better figure out relation on these parameters.

  Are you sure? yes | no

Dan wrote 11/05/2016 at 08:29 point

Hi Einars,  

Thank you so much for the above tip on how to make the speedometer work !

I've managed to use the above for a VW Passat B6 dashboard, however it *only* works when the speed is around 100km/h. If I try with 50 or 200km/h, your above formula doesn't work anymore...

Any idea ? Have you managed to find the exact formula between the speed the frequency of the updates and that "X" coefficient ?

Also if I read correctly your code:

counter += distance_adder;    

if( counter > distance_adder ) { counter = 0; }

it means that you're literally sending the distance_adder then "0" every other iteration, as that "if" clause will always be true every 2nd time...

Am I missing something ? Could you please clarify ?

Anyhow, any help / hint would be HUGELY appreciated, as I've spend countless number of hours trying to make this work, and it's becoming really frustrating :)  (I also don't have the actual car so that I can sniff the "real" packages :) )

Dan

  Are you sure? yes | no

Jeroen van der Velden wrote 03/23/2016 at 13:24 point

Hi Leon, my simulator is ready to get connected t this stage. For testing I`m using laptops and PC`s but every time I use a new system I need to find all the right .h files for Arduino.IDE.

So far only my home PC has everything to compile without errors. Would you be able to post a copy of both your IDE Library`s so its less hard for us to get the "Hardware Test" runining on UNO?

  Are you sure? yes | no

Jeroen van der Velden wrote 03/24/2016 at 17:58 point

EDIT:

This should do it!

https://cdn.hackaday.io/files/8448361439232/PC Libraries.rar

This file is for the VW Polo Board and CAN-BUS Shield. Delete all your Arduino
IDE Library’s from your system and copy past these in both library locations.

  Are you sure? yes | no

Leon Bataille wrote 06/26/2015 at 07:36 point

Hi @monnoliv,

Yeah the Conrod is a project about controlling motor and dash controllers, but my project is about controlling a dash for a computer game. It has another purpose.

But thank you for the info!

  Are you sure? yes | no

monnoliv wrote 06/25/2015 at 13:52 point

Hi,

Just for info, there is another project like yours here:

http://blog.atmel.com/2015/06/23/conrod-is-a-dev-board-for-the-automotive-world/

Olivier

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates