How to test CANBUS with Raspberry PLC
CAN bus protocol and automation with Raspberry PLC
7 septiembre, 2021 por
How to test CANBUS with Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez


A Controller Area Network (CAN bus) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other's applications without a host computer.

In this blog post, we are going to learn how to send and receive CAN bus messages from our Raspberry PLC.


How to

Connect Raspberry PLC to Wi-Fi


Raspberry PLC

Family products


How to

Program Raspberry PLC Interrupt inputs with Python


Basics about

Raspberry Pi PLC Analog Outputs


Touchberry Pi

Family products


How to

Find your perfect industrial PLC



 What is CAN Bus?

CAN bus is a message-based protocol, designed originally for multiplex electrical wiring within automobiles to save on copper, but it can also be used in many other contexts. For each device, the data in a frame is transmitted sequentially but in such a way that if more than one device transmits at the same time, the highest priority device can continue while the others back off. Frames are received by all devices, including by the transmitting device.

 Prior check

First of all, let's do a prior check to make sure that the setup is ready.

  1. Make sure your Rasberry PLCs are rightly connected to the power supply.

  2. Check that your Raspberry PLC has all the config files. Check >>

  3. Ensure that the SPI is enabled.

  4. Check that the /boot/config.txt file has the following line:

  5. Go to /etc/network/interfaces.d and check that the following can0 file exists and has this content in it:

    auto can0
    iface can0 inet manual
    pre-up /sbin/ip link set can0 type can bitrate 500000 triple-sampling on restart-ms 100
    up /sbin/ifconfig can0 up
    down /sbin/ifconfig can0 down
  6. Check that you can see the interface by doing:

    ifconfig can0
  7. Make sure the can-utils library is properly installed. If it is not, then install it:

    sudo apt update
    sudo apt install can-utils


Now, it is time to connect the cables as shown in the picture below.

Odoo • Image and Text


Once everything is ready to test the CAN Bus on our Raspberry PLC, we are going to follow these basic steps:

1. In order to wait for the data on the first Raspberry PLC, open up a terminal window and type the following:

candump can0

Odoo • Image and Text

2. From the second Raspberry PLC, send the data with the following command:

cansend can0 111#FF

Odoo • Image and Text

If everything went right, you will be able to see the message like in the picture below.

Now, enjoy the CAN Bus communication with this basic example for your Raspberry PLC!

Odoo • Image and Text
How to test CANBUS with Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez
7 septiembre, 2021

¿Buscas tu controlador lógico programable ideal?

Echa un vistazo a esta comparativa de producto de varios controladores industriales basados en Arduino.

Comparamos entradas, salidas, comunicaciones y otras especificaciones con las de los equipos de otras marcas destacadas.

Comparación PLC industrial >>>

¿Quieres más información?

¡Rellena el formulario!

¡Cuéntame más!