Cookies: Our site uses cookies in order to deliver better content. By continuing you accept these cookies.

Ok
AutoPi > Blog > How Raspberry Pi connects to CAN Bus

How Raspberry Pi connects to CAN Bus

Updated at 19 Oct, 2021

— The Raspberry Pi does not have an inherent CAN support, but it can be added using USB or SPI adapters.

How Raspberry Pi connects to CAN Bus
Find the perfect solution service for your business

All solutions are customizable and designed to meet all your needs.

Find the solution

The CAN bus is a communication protocol that is mostly utilized in automobiles. The CAN bus was initially developed to connect ECUs in the automobile sector.

Today, this tough communication bus may be found not only in automobiles, but also at the factory in automation e.g., CANopen and other applications.

The Raspberry Pi does not have an inherent CAN support, due to the Raspberry Pi’s Broadcom SoCs (System on a Chip) do not have a CAN controller, but it can be added using USB or SPI adapters.

What is Raspberry Pi?

The Raspberry Pi is essentially a tiny computer that is roughly the size of a deck of cards.

It employs SoCs, which combine the CPU and GPU onto a single integrated circuit, with the RAM, USB ports, and other components soldered to the board for an all-in-one packaging.

The Raspberry Pi lacks onboard storage; however, it does feature a SD card port for storing the operating system and data.

Note: The Raspberry Pi was created by the non-profit Raspberry Pi Foundation as a low-cost computer for teaching programming, but it rapidly became popular among DIYers (Do it yourself) searching for a more powerful brain in their electronics projects.

Many Raspberry Pi versions have been launched since its beginning, some with numerous revisions, such as the Raspberry Pi 3 Model B+, which increased the networking capabilities of the preceding Model B.

The most recent Raspberry Pi is the Raspberry Pi 4, which has a 1.5GHz quad-core ARM CPU, a 500MHz Videocore VI GPU, and 1GB, 4GB, or 8GB of RAM.

CAN is supported by the Linux kernel, which provides SocketCAN drivers for the Microchip MCP2515 stand-alone CAN controller with SPI interface.

There are several add-on expansions boards for the Raspberry Pi, including the PiCAN2, PiCAN3, and other variants.

2-Channel Isolated CAN FD Expansion HAT.

MCP2515 CAN Bus Module Board TJA1050.

We explain more in depth about the Raspberry Pi here.

What is CAN bus HAT on Raspberry Pi?

Simply put, HAT stands for Hardware Attached on Top and was created specifically for Raspberry Pi computers. There are numerous benefits to using HATs in your projects, especially since they are virtually plug and play.

Each HAT is designed for a specific function, such as measuring pressure with sensors, receiving power over ethernet or connecting to the CAN bus.

Without getting into too much detail on the other HATs, we will be focusing on how the CAN bus HAT on Raspberry Pi. Essentially, the AutoPi TMU device is built on top of the Raspberry Pi as a standalone and scalable product, enabling the device to communicate with vehicles using the can0 protocol via a SocketCAN interface.

Furthermore, the device can typically communicate with vehicles of any origin, and the most common protocols used by our clients are the OBD-II protocol and SAE J1939.





How AutoPi TMU device utilizes Raspberry Pi Can bus

The AutoPi TMU device, which is based on Raspberry Pi technology, and serves as the heart of our hardware dongle. In addition, we created our own HAT for the Raspberry Pi that has the necessary IOs.

Keep in mind that the Raspberry Pi boards are not CAN bus ready out of the box.

They may be summarized in two points:

  • The Raspberry Pi hardware does not support the CAN Bus (GPIO).

  • The Raspberry Pi Software did not support the CAN Bus (Raspbian).

We added a solution to this problem to fix it:

  • SPI Bus will be used as a bridge between the Raspberry Pi and the CAN bus.

  • We will utilize the MCP2518FD CAN controller, which is Linux/Raspbian-compatible.

Due to this, we created a CAN bus (FD) shield for Raspberry Pi (MCP2518FD) that supports CAN FD. This allows us to fully connect the Raspberry Pi to the CAN bus.

One of the automotive industry’s trends is connection, and the AutoPi TMU device can correlate your vehicle to the cloud and provide with numerous capabilities.

Learn more about this here.

Article by

Nikola Velichkov

Software Developer

Like what we do? Contact us.

Find the perfect solution service for your business

All solutions are customizable and designed to meet all your needs.

Find the solution

Other posts you will like

What is Geofencing? Easily Explained
What is Geofencing? Easily Explained
Automotive Ethernet Changes the Automotive Industry
Automotive Ethernet Changes the Automotive Industry
A Simple Guide to Automotive Software
A Simple Guide to Automotive Software

STILL HAVE QUESTIONS?

Get in touch with us – We're ready to answer any and all questions.

* Mandatory fields

Email our engineers

We are here to help!