Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

CAN communication between PIC and Arduino

By Prabakaran P.M January 16, 2024

Summary:

This project helps in understanding the insights of CAN protocol interfacing two different Microcontroller for example, PIC and Arduino. Controller Area Network or CAN protocol is a methodology of communication between various electronic devices like engine management systems, gear control, active suspension, ABS, lighting control, air conditioning, airbags, central locking etc. embedded in an automobile. For further learnings refer this article.

Here you will get idea about the programming of PIC Microcontroller to interface with CAN Controller (MCP2515) to act as a transceiver. Here an PIC16f887 Microcontroller and an Arduino are used, one is for sensing the temperature using LM35 and another one is to display the values received through the CAN BUS.

Description:

Prerequisites & Equipment:

You will need the following:

  1. A PIC16F877A and an Arduino Board or Arduino clone(Here is a guide if you need)

  2. A 5v TTL -UART Bluetooth module.

  3. LCD and LM35 temperature Sensor.

  4. Arduino IDE for the programming.

  5. Two CAN Tranciever.

Working Principle:

This Project includes two distinct parts, transmitter section and a receiver section. Receiver section consists of an Arduino and LCD to show the Temperature reading received from the CAN Bus. The Transmitter section consists of LM35 sensor interfaced with PIC16F877A The communication between both sections are carried out by the MCP2515 CAN transceiver.

Temperature Sensor CAN Bus implementation:

The block diagram of the project is shown in Figure. The system is made up of two CAN nodes. DISPLAY node that reads the temperature from the CAN Bus and displays it on an LCD. This process is repeated continuously. The other node called COLLECTOR node reads the temperature from an LM35 temperature sensor.

Overview of Arduino and PIC Microcontroller Communication over CAN Interface

Fig. 1: Overview of Arduino and PIC Microcontroller Communication over CAN Interface

The DISPLAY Processor:

DISPLAY processor consists of an Arduino with a MCP2515 CAN module and an TJA1040 transceiver chip. The Microcontroller is operated from a 16MHz crystal. And MCP2515 has an SPI interface which is used to connect using SPI pins in Arduino. The Pins CANH and CANL of the transceiver chip are connected to the CAN bus. LCD is connected to Arduino to display the temperature values.

Receiving CAN data and Controlling Relays:

Load the program RX.ino after you save it onto your computer and open it in Arduino IDE .

  • Compile the program in the Arduino IDE

The following function is used to receive the values from the CAN bus and to display in an LCD. Detailed instruction can be found here.

CAN.readMsgBuf(&len, buf);

Loading software for Arduino:

If you are new to Arduino you can start with here. You have to start with the Arduino IDE (Integrated Development Environment) from Arduino . Download the code from below link and upload it to the Arduino board.

The COLLECTOR Processor:

The COLLECTOR processor consists of a PIC18F887 microcontroller with a MCP2515 CAN module and an TJA1040 transceiver chip. The PIC18F887 is operated from an 8MHz crystal. The MCLR input is connected to an external reset button. LM35DZ-type semiconductor temperature sensor is connected to Analog input AN0 of the Microcontroller. The sensor generates an analog voltage directly proportional to the measured temperature, the output is 10mV/C. For example, at 20 degree Celcius the output voltage is 200mV. The CANH and CANL outputs of this chip are connected directly to a twisted cable terminating at the CAN bus. The TJA1040is an 8-pin chip that supports data rates up to 1Mb/s. The chip can drive up to 112 nodes. A reference voltage equal to VDD/2 is output from pin 5 of the chip.

To change the speed of the MCP2515 Can Module in the collector side you can use the calculator software which is provided by MikroC. Download the file included in bottom to get the software.

Screenshot of CAN Calculations done for MCP2515 microcontroller on MikroC application

Fig. 2: Screenshot of CAN Calculations done for MCP2515 microcontroller on MikroC application

This is the format to change the speed of the MCP2515 can module,

CANInitialize (SJW, BRP, Phase_Seg1, Phase_Seg2, Prop_Seg, init_flag);

Here is the Initialisation made here to make it at 250Kbps

CANSPIInitialize (1,2,1,2,4,Can_Init_Flags);

For details about using MikroC to program pic controllers refer here.

The operation of the system is as follows:

  • The DISPLAY processor that waits for the current temperature message send from the COLLECTOR processor over the CAN bus.

  • The COLLECTOR processor measure the temperature, formats it, and sends to the DISPLAY processor over the CAN bus.

  • The DISPLAY processor reads the message from the CAN bus and then displays it on the LCD which is repeated every second.

Hardware assembly:

Image showing Arduino based CAN Receiver Circuit

Fig. 3: Image showing Arduino based CAN Receiver Circuit

Image showing PIC MCP2515 based CAN Transmitter Circuit

Fig. 4: Image showing PIC MCP2515 based CAN Transmitter Circuit

Prototype of CAN Transmitter and Receiver circuits designed on Breadboards

Fig. 5: Prototype of CAN Transmitter and Receiver circuits designed on Breadboards

Make the circuit as is given by the circuit diagram.

You may also like:


  • What are the top 4G modems available in India?

  • What are LoRa gateways and what types are available?

  • How does LoRa modulation enable long-range communication?

  • What are the different EV charging protocols?

  • What are the different types of EV charging connectors?

  • What is the role of embedded software in electric vehicles?

Project Source Code

 

 


Circuit Diagrams

Circuit-Diagram-Arduino-PIC-Microcontroller-Based-CAN-Transmitter-Receiver-Circuits

Project Video


Filed Under: Arduino Projects, Electronic Projects, PIC Microcontroller

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • High Side current sensing
  • How to simulate power electronics converter in PSpice?
  • Voltage mode pushpull is a nonsense SMPS?
  • Layout IRN reduction in Comparator

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe