Comments: CAN-BUS Shield Hookup Guide

Pages

Looking for answers to technical questions?

We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.

  • Member #834256 / about 8 years ago / 3

    How can this be used to send commands to other canbus peripherals?

  • Member #1594229 / about 5 years ago / 2

    hello. I used arduino uno R3 and can bus shield sparkfun. I followed this tutorial but I always saw the massage that " Can't init CAN".

    So, I checked jumper and changed it for DB9 to DB9. And I checked the connection CAN Pin(CAN H = pin7, CAN L = pin2, GND = pin3). However, I cannot initialize CAN.

    What am I suppose to do to initialize CAN??

    by the way,in the https://learn.sparkfun.com/tutorials/can-bus-shield-hookup-guide#example-code ,The instruction did not explain to me who sj4, sj5, sj6 in jumper pin 6c.

    please help me!!

    • santaimpersonator / about 5 years ago / 1

      Hi there, it sounds like you are looking for technical assistance. Please use the link in the banner above, to get started with posting a topic in our forums. Our technical support team will do their best to assist you.

      That being said, I am not sure what "for DB9 to DB9" is supposed to represent. Also, as shown in the picture for the hookup guide, the jumpers circled in the 6c box are SJ6, SJ5, and SJ4 from left to right. However, that shouldn't matter at all as you should be changing all the jumpers to either the ODB-II or CAN configuration.

  • Member #870794 / about 8 years ago / 2

    i have used the can demo/ ecu demo code along with the SparkFun shield and Arduino Uno. i am trying to poll for Engine RPM,Vehicle Speed and Engine Coolant temperature it gives me Value like 0,1 repeatedly. could anyone have a clue what is the source of error ?

  • Member #891237 / about 8 years ago / 2

    Hi all,

    I've successfully hooked up can bus shield with Arduino Mega 2560 with defined SPI pins and hardware connections modifications. But now, i cannot get my gps to work. How can i fix it? Please help me!

    Many thanks.

  • Member #789885 / about 9 years ago / 2

    Hi friends, I'm working on this project but somehow I can not get the data I want.

    // Pins remapped to Arduino Mega 2560

    define P_MOSI B,2 // pin 51

    define P_MISO B,3 // pin 50

    define P_SCK B,1 // pin 52

    define MCP2515_CS B,0 // pin 53

    define MCP2515_INT E,4 // pin 2

    define LED2_HIGH H,5 // pin 8

    define LED2_LOW H,5 // pin 8 this codes do not include in my code so maybe I can not that's way.

    So could you please can you show me a picture of the CANbus connection with arduino Mega with all the codes?

    • Member #1275783 / about 7 years ago / 1

      Hello, I have same issues, did you get the solution? Thankyouu

  • Member #1603049 / about 5 years ago / 1

    It appears the library needs to be overhauled. The product is advertised as 1M bitrate capable (which I need), but the super old library is only defined up to 500K bitrates. I am no genius at this quite yet as I am new to the whole Arduino thing in the first place. Needless to say, it is a little disappointing speed bump for me. I'll have to figure this out later once I get everything else to work, more about this below.

    I can't get the example sketches in the library to compile. I am not sure if it is because of my library or my Redboard Artemis (newer development board, I hope my pin mapping is OK). I am getting a compile error that it can't find "util/delay.h". If someone can point me in the right direction regarding this, it would be much appreciated.

    There's a library for the Seeed CAN shield, but I am unsure if this would work. It does have a library that supports 1M bitrates. I am not so code savvy, so I am unsure if it will work directly with the Sparkfun shield version. I tried digging into the other library to see if maybe I can snip some code out of it and graft it into the Sparkfun library, but the author defined stuff in jibberish making it hard to interpret for a novice. In theory, the Seeed library should work, but I am more than willing to bet the pin mapping is all over the place which is way over my head right now. It seems the easiest thing would be for a more capable person to update the Sparkfun library to support 1M bitrates, and dabbling with other vendor libraries can be avoided all together.

    All I am trying to achieve is to read the streaming CAN data from my race car's Haltech ECU (@1M rates) to pass it on to a separate Artemis board running a 4D Systems dash screen to operate a gauge interface. It seems like it won't be as easy as I thought it would be LOL.

  • Member #1485399 / about 5 years ago / 1

    If the CAN-Bus shield is receiving its power from the OBD2 port via the DB9 connection and I connect the Arduino to my laptop via the USB port, will that result in a power overload and fry the CAN-Bus shield and/or the Arduino?

    • santaimpersonator / about 5 years ago / 1

      Hi there, it sounds like you are looking for technical assistance. Please use the link in the banner above, to get started with posting a topic in our forums. Our technical support team will do their best to assist you.

      That being said, if you take a look at the schematic... there is a fuse on the DB-9 connector and if your overload your board from the 5V side... you have bigger issues with your laptop.

  • Member #1345425 / about 7 years ago / 1

    I have done this project as you stated. I can successfully read the can bus data on serial monitor of arduino. But now when I am trying to extract engine rpm, vehicle speed, fuel level or any other parameter , it is showing nothing on serial monitor except the following lines :

    CAN-Bus Demo CAN init ok Please choose a menu option. 1.Speed 2.RPM 3.Throttle 4.Coolant Temperature 5.O2 Voltage 6.MAF Sensor

    when I enter 1 , serial monitor shows:

    Speed :

    When I enter 2 :

    RPM :

    but no values are is diaplayed ! Can you help me by telling where I am doing wrong : thank you.

  • Member #1275783 / about 7 years ago / 1

    Hello, I'm using sparkfun CAN-BUS shield with Arduino Mega for master and sparkfun CAN-BUS shield with Arduino Uno for Slave. Can I connect and transfer CAN data between that two hardware?Can I see the code or wiring the hardware? Thankyou

  • Member #1166363 / about 7 years ago / 1

    INIT OK BUT NO VALUES

    Hello everyone I got an issue, i am already followed steps of hook up guide I did all connections at pin headers just I didnt sold LCD pins and 4 hole pins (5V hand CanH CanL). I am already use db9 cable but when I am run any demo code example from library that sparkfun released I am just get only INIT OK while db9 cable is not even plugged at vehicle ,without any other clue. If anyone knows please help .

  • Member #879829 / about 8 years ago / 1

    Can this shield be used with K Line on ISO-14230 (KWP2000)? If so, is it pin1 for gnd and pin4 for kline on the DB9 connector? I'm using the Sparkfun RedBoard.

  • Member #856670 / about 8 years ago / 1

    In the code that the page give for the customers show me a lot of problems of syntax, someone can help me?

    • Please email techsupport@ sparkfun dot com for more in depth assistance. You can send them the errors you're getting and they will be able to help you debug your system.

      • Member #870794 / about 8 years ago / 1

        i have used the can demo/ ecu demo code along with the SparkFun shield and Arduino Uno. i am trying to poll for Engine RPM,Vehicle Speed and Engine Coolant temperature it gives me Value like 0,1 repeatedly. could anyone have a clue what is the source of error ?

  • Member #682268 / about 8 years ago / 1

    How do we change the CS pin in the CAN Demo/library?

  • Member #682268 / about 8 years ago * / 1

    EDIT**** I was able to use another library which included the ability to change the CS pin from 9 to 10 as it seems D09 D10 where switched in a newer revision. I am still having issues but I think this is the source of my issues.

    Using the provided libraries and examples in the hookup guide I am having issues with receiving data from any vehicle.

    My serial data is displaying RPM: but no data beside it. I can navigate through the menu in the serial console just fine. When I do let it run for a while it will randomly cycle through -40 deg, 0 km, 0 rpm, and nothing. My board is not the newest version as it has no jumpers. Could this be the issue?

    As of now I have gone through the libraries to check the PIDs against the variable names. My first idea was to replace the buffer var with the actual PID var name. This resulted in a solid 12 for RPM and 5 for O2 sensor.

    Any ideas would be greatly appreciated.

  • Member #834256 / about 8 years ago / 1

    I'm looking to hook up to a car with 100kbs baud rate.

    Any ideas on how I can do that with this shield?

    Many thanks.

  • Member #818200 / about 9 years ago / 1

    Hi, Is it possible to use this shield with arduino leonardo. I am getting error what ever I try. Is it possible to modify the library and make it work ?

    I have to finish this project soon.

    Please help.

    • You would need to both modify the library, as well as run jumper wires from the SPI pins to the ICSP header on the Leonardo. The library pin definitions would need to be updated to reflect the SPI pin ids on the Leonardo, as the SPI pins are not located in the same spot on the Leonardo as they are on the Uno.

  • Member #800002 / about 9 years ago / 1

    Hello,

    I cannot get my µSD-Card to work. I always fail at SD.begin(9) on every example code. I already tried different SD cards with the reccommended and different formatting as well as other pins for the SD initialisation progress.

    As far as I can judge, I don't have any soldering/connection problem. Other things [like the joystick] work fine.

    I am using the CAN shield hooked up on top of the Arduino Due board.

    I appreciate every help!!

    • Hi - you are running into issues with the microSD card (and eventually you will also run into issues with the CAN functionality as well) because the Due only breaks out the SPI pins to the ICSP header. The shield is designed to mate directly with the Uno footprint, where the SPI pins are available on D9-12. You will need to run jumpers from the SPI pins on the shield to the SPI pins on the Due, and verify the clock pin definitions in the library and example sketches.

  • -------------------- Tech Support Tips/Troubleshooting/Common Issues --------------------

    CAN-Bus Shield w/ an Arduino Mega 2560

    Software Defined SPI pins

    Using the example code , you will probably see this output on the Arduino serial monitor

    If you see this output on the Arduino serial monitor when using the CAN-Bus shield on an Arduino Mega 2560 [uploaded with the SparkFun_CAN_Demo.ino - https://github.com/sparkfun/CAN-Bus_Shield/blob/master/Libraries/Arduino/examples/SparkFun_CAN_Demo/SparkFun_CAN_Demo.ino ]:

    CAN-Bus Demo
    Can’t init CAN
    Please choose a menu option.
    1.Speed
    2.RPM
    3.Throttle
    4.Coolant Temperature
    5.O2 Voltage
    6.MAF Sensor
    

    You need to modify the defined SPI pins in the default file located in the "CAN-Bus_Shield" library [ https://github.com/sparkfun/CAN-Bus_Shield/blob/master/Libraries/Arduino/src/defaults.h ] as explained by Memphomaniac the SparkFun forum [ https://forum.sparkfun.com/viewtopic.php?f=14&t=25535&start=30c ]. Just change lines 4-12 from:

    #define P_MOSI  B,3
    #define P_MISO  B,4
    #define P_SCK   B,5
    
    //#define   MCP2515_CS          D,3 // Rev A
    #define MCP2515_CS          B,2 // Rev B
    #define MCP2515_INT         D,2
    #define LED2_HIGH           B,0
    #define LED2_LOW            B,0
    

    to

    // Arduino Uno (Atmega 168/328 pin mapping)
    //#define    P_MOSI            B,3 // pin 11
    //#define    P_MISO            B,4 // pin 12
    //#define    P_SCK             B,5 // pin 13
    //#define    MCP2515_CS        B,2 // pin 10
    //#define    MCP2515_INT       D,2 // pin 2
    //#define    LED2_HIGH         B,0 // pin 8
    //#define    LED2_LOW          B,0 // pin 8
    
    // Pins remapped to Arduino Mega 2560
    #define    P_MOSI              B,2 // pin 51
    #define    P_MISO              B,3 // pin 50
    #define    P_SCK               B,1 // pin 52
    #define    MCP2515_CS          B,0 // pin 53
    #define    MCP2515_INT         E,4 // pin 2
    #define    LED2_HIGH           H,5 // pin 8
    #define    LED2_LOW            H,5 // pin 8
    

    Hardware Connections

    After redefining pins, make sure that you bend the header pins of the shield so that it is not in the Arduino Mega2560’s sockets (pins 10-13). Then, make sure to reroute the pins to the correct SPI pins:

    SPI Pins <=> Arduino Uno  <=> Arduino Mega 2560
    SCK      <=>       13     <=>         52
    MISO     <=>       12     <=>         50
    MOSI     <=>       11     <=>         51
    SS       <=>       10     <=>         53
    

    Try looking at this tutorial [ http://mcukits.com/2009/04/06/arduino-ethernet-shield-mega-hack/ ] as an example. With the correct pins defined and rerouted, I was able to receive this correct output:

    CAN-Bus Demo
    CAN Init ok
    Please choose a menu option.
    1.Speed
    2.RPM
    3.Throttle
    4.Coolant Temperature
    5.O2 Voltage
    6.MAF Sensor
    

    If you are seeing this serial output on the monitor:

    CAN-Bus Demo
    

    it's possible that the software pins are not defined correctly, there is a loose connection, or you are not connecting the wires properly. Make sure the pins are defined properly and check your connections.

    Bit Rate?

    I have not tried changing the bit rate but try looking at this article on step 2 to determine the bit segment => [ http://www.analog.com/en/analog-dialogue/articles/configure-can-bit-timing.html ]. The article seems to indicate that you would need to adjust the crystal oscillator and the Baud Rate Prescaler (BRP) bits.

    Baud Rate?

    If you are trying to add additional baud rates for the CAN BUS, I recommend looking at the library here [ https://github.com/sparkfun/SparkFun_CAN-Bus_Arduino_Library/blob/ffcd67b7f4d5112f747f7c74a8677ef82a4ee202/src/Canbus.h#L10 ] to add additional baud rates. I’m not sure of the exact details of how to do this since I have not tried calculating a value outside of the example code. You would probably need to define your baud rate constant by determining your baud rate prescaler. Try looking at the MCP2515’s datasheet for more information [pg 38 - https://www.sparkfun.com/datasheets/DevTools/Arduino/MCP2515.pdf ]. I did a quick search online and this tutorial might be of some use [ http://www.normalexception.net/index.php/code-development/arduino-mcp2515-library ] .

    Examples

    For more examples, maybe you can look at the MCP_CAN library [ https://github.com/coryjfowler/MCP_CAN_lib ] by coryjfowler . It looks like the Arduino library is compatible with any shield or board that uses a MCP2515 CAN.

    This tutorial on Instructables is useful for reading any device outputting serial data on the CAN bus line => [ http://www.instructables.com/id/CAN-Bus-Sniffing-and-Broadcasting-with-Arduino/?ALLSTEPS] .

    • Member #882315 / about 8 years ago / 1

      Hi bboyho, i followed the exact same steps as you have instructed above. By rerouting the hardware pins and re-coding the defaults.h file. However, after much attempts i am unable to INIT the program. I downloaded the library you provided on your comment. So i believe i am using the same code as you. I am just hoping that there might be some hardware routing i might have missed out. As i use jumper wires, to jump the pin from 50-53 to 10-13 in the order according to the one above. But my board is separated from each other. I am not sure if i am missing out on anything ? I am suspecting that i may have missed out routing some other pins to the spark fun can bus shield as i have only jumped 4 wires from my mega to the spark fun can bus shield... Hope to hear from you soon ..Many thanks =)

      • I'm sorry but we do not actively monitor the comments. I did not see your comment until now. There are quite a lot of pages. It sounds like the shield is not stacked on your Arduino Mega. I would check your connections and solder joints for basic troubleshooting. Keep in mind that there are other pins that need to be connected (i.e. pin 2 for the interrupt, 5V, and GND) if you were just trying to communicate with the MCP2515 IC.

        If you are still having issues with getting the CAN-BUS Shield working on an Arduino Mega, I recommend sending an email => https://www.sparkfun.com/technical_assistance .

  • Member #792720 / about 9 years ago / 1

    Hi all, I've successfully hooked up the CAN-Bus-shield in combination with an Arduino Uno, to one of my cars. However I also want to connect to the Bus of my Saab, which is running on 47,619 kbit/s. Sparkfun's library supports 125/250/500kbps but not Saab's specific frequency. Can anyone tell me how to adjust the CAN-speed of the shield to 47,619kpbs? Thanks in advance!

  • Member #789885 / about 9 years ago / 1

    Hi friends, I'm using arduino mega and arduino canbus shield but I cannot initialize CAN. I wonder if I'm doing wrong canH and canL connection. Can you help me, how do I make this connection.

    • The CAN Bus shield works over SPI, which is in a different location on the Mega than the standard Arduino Uno footprint. You will need to run jumpers from the shield's SPI pins to the Mega's SPI pins, and update the CS pin definition in the code in order to get the shield to work properly. Please see Member #776112's comment below.

  • Member #776112 / about 9 years ago / 1

    hello. I used arduino mega 2560 and can bus shield sparkfun. I followed this tutorial but I always saw the massage that " Can't init CAN".

    So, I checked jumper and changed it for DB9 to DB9. And I checked the connection CAN Pin(CAN H = pin7, CAN L = pin2, GND = pin3). However, I cannot initialize CAN.

    What am I suppose to do to initialize CAN??

    please help me!!

    • You cannot plug the CAN-Bus Shield directly into a Mega2560. The CAN-Bus shield uses SPI for communicating with the Arduino, and on the Mega, these pins are not in the default location. You will need to add jumper wires between your CAN-Bus shield and the SPI pins on the Mega, which you can see a pin out diagram here.

      Also, you will need to double check your jumpers. If you bought our DB9-OBD cable, you will need to configure the jumpers back to the position they were in when your shield arrived.

      • Member #776112 / about 9 years ago / 2

        Thanks!! I solved the Initialization problem.

        I changed connect the pin like this

        Sparkfun D10    ->  Arduino mega2560   53
        
        Sparkfun D11    ->  Arduino mega2560   51
        
        Sparkfun D12    ->  Arduino mega2560   50
        
        Sparkfun D13    ->  Arduino mega2560   52
        

        and I changed the example code, defaults.h like this. In the mega2560 data sheet, port B setting is different.

        #define P_MOSI            B,3   ->  #define P_MOSI            B,2
        
        #define P_MISO            B,4   ->  #define P_MISO             B,3
        
        #define P_SCK            B,5    ->  #define P_SCK             B,1
        
        #define MCP2515_CS   B,2    ->  #define MCP2515_CS    B,0
        

        after this, I succeed to initialize CAN bus.

        But, I have one more question. Is there any code or function that receive or send CAN data?

        If there is code or function, how can I use it?

        • Great to hear you got it working! There is an example function for working with the CAN data in the Arduino library here.

          You will need to load this sketch along with the rest of the library (with the updated SPI pin mapping) to your Mega in order to run it.

  • Member #730512 / about 9 years ago / 1

    Hello, I am trying to have the CAN-Bus Shield work with an MTK-based Arduino board (the LinkIt ONE). What changes would I need to make to the source code to make it happen? Is it at all possible? Thanks!

    • You'd have to take a look at the Arduino board definition files for the LinkIt ONE, and modify the source code based on pin names and pin calls in the library. You can run the basic CAN functionality over SPI, so that would be the first section I'd focus on updating. It should be possible though.

  • Ludwig Schreier / about 9 years ago / 1

    Hello, would the CAN-Bus Shield work with the latest Photon Redbord? Feasibility of such an idea? Kind regards

    • I haven't tried using the CAN-Bus shield with the Photon Redboard, but to at least get the CAN functionality working, the main thing I see that you would need to do is use the WKP pin on the Redboard as a digital I/O to work as your slave select line. It would simply be a matter of porting the code at that point. If you decide to try it and get it working, please let us know!

  • Member #1166363 / about 7 years ago * / 0

    INIT OK BUT NO VALUES

    Hello everyone I got an issue, i am already followed steps of hook up guide I did all connections at pin headers just I didnt sold LCD pins and 4 hole pins (5V hand CanH CanL). I am already use db9 cable but when I am run any demo code example from library that sparkfun released I am just get only INIT OK while db9 cable is not even plugged at vehicle ,without any other clue. If anyone knows please help .


If you've found an issue with this tutorial content, please send us your feedback!