Arduino B.Tech/Diploma Beginner

Arduino CAN Bus Tutorial | Interfacing MCP2515 CAN Module with Arduino

How to use MCP2515 CAN Bus Module with Arduino to transmit DHT11 Sensor data between transmitter receiver with MCP2515 Library & CAN_H/CAN_L

  • Suitable forB.Tech/Diploma Arduino students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

Overview
In this tutorial, we will learn about the
CAN Bus protoco
l by Interfacing
MCP2515 CAN Bus Module
with
Arduino
. We will transmit the DHT11 Sensor data over a certain distance using the
CAN protocol
Controller Area Network
also known as
CAN-BUS
is a common industrial bus because of its long travel distance, medium communication
speed
, and high
reliability
. It is commonly found on modern machine tools and as an automotive diagnostic bus.
In modern Vehicle systems, there are more than
60 to 100 sensor
units for sensing and exchanging information. Similarly, car manufacturers are constantly making their cars smarter by adding features like Autonomous driving, Airbag system, ABS (Anti-braking System), Telematics, Transmission Control, Battery management systems, Cruise control system, etc. To enable the
transmission
and
receiving
of the data at a very high-speed standard automotive
communication protocols
are required. The standard communication protocols like UART, SPI, and I2C are not
reliable
for this system. Hence we need an automobile communication protocol like the
CAN protocol
for high-speed & 1000s of data transmission at a single time.
In this guide we will learn about the CAN Bus Communication protocol using
Microchip MCP2515 CAN Bus Module
& Arduino Board. Using the pair of CAN Bus Module MCP2515, we will send the
DHT11 Sensor
data over a distance of a few centimeters. Typically the communication speed for CAN ranges from
50 Kbps
to
1Mbps
and the distance can range from
40 meters
at 1Mbps to
1000 meters
at 50kpbs.
Bill of Materials
To learn about the CAN Bus protocol and do practical stuff, we need the following components and modules. You can purchase all these components online from Amazon.
S.N.
Components
Quantity

Arduino Nano Board

Amazon
AliExpress

Arduino UNO Board

Amazon
AliExpress

CAN Module MCP2515

Amazon
AliExpress

I2C LCD Display

Amazon
AliExpress

DHT11 Sensor

Amazon
AliExpress

Jumper Wires

Amazon
AliExpress

Breadboard

Amazon
AliExpress
CAN BUS (Controller Area Network)
The CAN bus is an automotive bus developed by Bosch, allowing microcontrollers and devices to communicate with each other within a vehicle without a host computer. CAN bus is a message-based protocol, designed specifically for automotive applications but now also used in other areas such as
aerospace
, industrial automation, and medical equipment.
Automotive CAN BUS network
It become an international standard (ISO 11898) in 1994 and was specially developed for fast serial data exchange between electronic controllers in motor vehicles. It connects the individual systems and sensors as an alternative to conventional multi-wire looms. It allows automotive components to communicate on a single or dual-wire networked data bus up to 1Mbps.
Principle of operation of the CAN BUS
CAN bus uses two dedicated wires for communication. The wires are called CAN high and CAN low. The CAN controller is connected to all the components on the network via these two wires. Each network node has a unique identifier. All ECUs on the bus are effectively in parallel and that’s why all the nodes see all of the data, all of the time. A node only responds when it detects its own identifier. Individual nodes can be removed from the network without affecting the other nodes.
When the CAN bus is in idle mode, both lines carry 2.5V. When data bits are being transmitted, the CAN high line goes to 3.75V, and the CAN low drops to 1.25V, thereby generating a 2.5V differential between the lines.
CAN power can be supplied through the CAN bus. Or a power supply for the CAN bus modules can be arranged separately. The power supply wiring can be either totally separate from the CAN bus lines resulting in two 2-wire cables being utilized for the network, or it can be integrated into the same cable as the CAN bus lines resulting in a single 4-wire cable.
The nature of CAN bus communications allows all modules to transmit and receive data on the bus. Any module can transmit data, which all the rest of the modules receive. It is very important that the CAN bus bandwidth is allocated to the most safety-critical systems first. Nodes are usually assigned to one of a number of priority levels. A process known as arbitration decides the priority of any messages.
Most motor vehicle CAN network operate at a bus speed of 250 kB/s or 500 kB/s.
Applications of CAN BUS
The controller area network (CAN) is used for transmission airbags, antilock braking, electric power steering, etc.
It is used in audio-video systems.
The controller area network (CAN) is used in lifts and escalators.
It is used in sports cameras.
It is used in automatic doors.
It is used in telescopes and coffee machines.
The controller area network (CAN) is used in aircraft with flight state sensors,
navigation systems, and flight data analysis to aircraft engine control systems such as
fuel systems, linear actuators, and pumps.
It is used for windows, doors, and mirror adjustment.
It is used in railway applications such as streetcars, trams, undergrounds, light
railways, long-distance trains incorporate, etc.
Comparison of CAN over I2C & SPI
I2C
SPI
CAN
Speed
Standard: 100Kbps, Fast: 400 Kbps, Highspeed:3.4Mbps
3Mbps to 10Mbps
10KBps to 1MBps
Types
Synchronous
Synchronous
Asynchronous
Wires
2 wires (SDA, SCL)
4 Wires (MISO, MOSI, SCK, CS)
2 wires (CAN_H, CAN_L)
Duplex Mode
Half Duplex
Full Duplex
Half Duplex
MCP2515 CAN Bus Controller Module
The MCP2515 CAN Bus Controller is a simple Module that supports CAN Protocol version 2.0B and can be used for communication at 1Mbps.
This particular module is based on MCP2515 CAN Controller IC and TJA1050 CAN Transceiver IC. The MCP2515 IC is a standalone CAN Controller and has an integrated SPI Interface for communication with microcontrollers. Coming to the TJA1050 IC, it acts as an interface between the MCP2515 CAN Controller IC and the Physical CAN Bus.
The board has a 8 MHz Crystal oscillator. Even the 16 MHz version is also available. A jumper can be attached which will give 120ohm Termination. CAN_H & CAN_L are the two screws where wires can be attached over a distance for communicating with other CAN Module.
Following is the schematic of MCP2515 CAN Module.
MCP2515 IC is the main controller that internally consists of three main subcomponents: The CAN Module, the Control Logic, and the SPI Block. CAN Module is responsible for transmitting and receiving messages on the CAN Bus. Control Logic handles the setup and operation of the MCP2515 by interfacing all the blocks. The SPI Block is responsible for the SPI communication interface. The TJA1050 IC IC is responsible for taking the data from the controller and relaying it onto the bus.
Features and Specification of MCP2515
Uses High-speed CAN transceiver TJA1050
Dimension: 40×28mm
SPI control for expanding Multi CAN bus interface
8MHZ crystal oscillator
120Ω terminal resistance
Has independent key, LED indicator, Power indicator
Supports 1 Mb/s CAN operation
Low current standby operation
Up to 112 nodes can be connected
For more information refer to
MCP2515 Datasheet
which also has a detailed guide.
How to use MCP2515 CAN Bus Module with Arduino?
Now let us interface MCP2515 CAN Bus Module with Arduino and test the CAN Communication protocol. We will transmit the DHT11 Sensor data over a CAN Bus with the help of pair of Arduino Board & MCP2515 CAN Module. Here is the simple connection diagram.
The upper part consisting of Arduino UNO Board, CAN Module & I2C LCD is a receiver part. Similarly, the bottom part consisting of Arduino Nano Board, CAN Module & DHT11 Humidity Temperature Sensor is the transmitter part.
The transmitter & Receiver Part is connected to each other with the help of the MCP2515 CAN Bus Module. The CAN_H & CAN_L of the transmitter are connected to the CAN_H & CAN_L of the receiver respectively.
The connection bet

Technologies used

ArduinoBLEDHT11LCDRelayI2CSPIUART

Hardware components

  • Arduino
  • DHT11
  • Relay

Software & tools

  • Arduino IDE

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.