element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
On the Line
  • Challenges & Projects
  • Design Challenges
  • On the Line
  • More
  • Cancel
On the Line
Forum Making a CAN Network
  • News
  • Projects
  • Forum
  • DC
  • Leaderboard
  • Files
  • Members
  • More
  • Cancel
  • New
Join On the Line to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 4 replies
  • Subscribers 36 subscribers
  • Views 123 views
  • Users 0 members are here
  • On the line design challenge
  • can bus
  • MAX33041ESHLD
Related

Making a CAN Network

taifur
taifur 12 days ago

Controller Area Network (CAN) is a robust, reliable, and real-time communication protocol widely used in industrial automation and embedded systems. CAN enables multiple nodes to communicate over a single two-wire bus without requiring any central host. A CAN node can be any independent sensor or actuator unit. CAN networks are extensively used in process automation, industrial machinery, and robotic systems. It has very high noise immunity and requires only two wires for communication.

My project involves a CAN network where there will be an ESP32-based CAN node and a CAN gateway based on Arduino UNO Q and MAX33041E CAN transceiver shield from Analog Devices. The ESP32-based node collects sensor data and transmits it over the CAN bus to the central CAN gateway.

The ESP32 has a built-in CAN bus-compatible controller as TWAI which stands for Two-Wire Automotive Interface, it doesn’t have a built-in CAN transceiver, so we must use an external one to connect to a CAN network. So, in my project, I am using the MCP2551 CAN transceiver module to make a CAN node using an ESP32 microcontroller. The MCP2551  transceiver converts the CAN controller's digital TX/RX signals into the differential CANH/CANL bus signals.

I connected the VCC pin of the MCP2551 module to the VIN of the ESP32. Then, connect the GND pin to the ground. Next, connect the TX to GPIO5 and the RX to GPIO4 on the ESP32.

image

The next step is to connect the CAN Bus High and CAN Bus Low signals to the bus. I connected the CANH and CANL signals directly to the screw terminal on the MAX33041 Shield Evaluation Kit.

image

For programming the ESP32 module for CAN communication, I installed the following library:

image

For sending the test message on the CAN bus, I used the following test code. 

#include <CAN.h>

#define TX_GPIO_NUM   5
#define RX_GPIO_NUM   4

void setup() {
  Serial.begin (115200);
  while (!Serial);
  delay (1000);

  Serial.println ("CAN Sender");

  // Set the pins
  CAN.setPins (RX_GPIO_NUM, TX_GPIO_NUM);

  // start the CAN bus at 500 kbps
  if (!CAN.begin(500E3)) {
    Serial.println("Starting CAN failed!");
    while (1);
  }
}

void loop() {
  // send packet: id is 11 bits, packet can contain up to 8 bytes of data
  Serial.print("Sending packet ... ");

  CAN.beginPacket(0x12);
  CAN.write('h');
  CAN.write('e');
  CAN.write('l');
  CAN.write('l');
  CAN.write('o');
  CAN.endPacket();

  Serial.println("done");

  delay(1000);

  // send extended packet: id is 29 bits, packet can contain up to 8 bytes of data
  Serial.print("Sending extended packet ... ");

  CAN.beginExtendedPacket(0xabcdef);
  CAN.write('w');
  CAN.write('o');
  CAN.write('r');
  CAN.write('l');
  CAN.write('d');
  CAN.endPacket();

  Serial.println("done");

  delay(1000);
}

  • Sign in to reply
  • Cancel

Top Replies

  • shabaz
    shabaz 11 days ago +1
    Super-useful information! I didn't realize ESP32 contained a CAN controller. I've bought an external one to experiment with, but will probably try a microcontroller integrated peripheral at some point…
  • colporteur
    colporteur 11 days ago +1
    Envious of your project. Learning opportunities galore. You mentioned CAN Bus and I recalled reading the book The Car Hackers Handbook by Craig Smith. The CAN bus protocol is prevalent in vehicles. I…
  • Dipeshkachhi
    Dipeshkachhi 12 days ago

    Great project! CAN bus is such a robust protocol for industrial and automotive applications.
    I'm curious: are you using CAN 2.0A (11‑bit) or CAN 2.0B (29‑bit)? What bit rate did you choose, and how many nodes are in your network?
    Have you run into any issues with bus termination or cable length? I'd love to see your oscilloscope captures if you have any.
    Thanks for sharing – looking forward to your test results!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • shabaz
    shabaz 11 days ago

    Super-useful information! I didn't realize ESP32 contained a CAN controller. I've bought an external one to experiment with, but will probably try a microcontroller integrated peripheral at some point (probably MSPM0, but still useful to know about the ESP32).

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • colporteur
    colporteur 11 days ago

    Envious of your project. Learning opportunities galore.

    You mentioned CAN Bus and I recalled reading the book The Car Hackers Handbook by Craig Smith. The CAN bus protocol is prevalent in vehicles. I purchased the book but found the link to a pdf while creating this post.

    I so wanted to understand the diagnostic tools that were being used to troubleshoot problems in newer vehicles. I was fascinated by guys tweaking the engine processors beyond manufactures defaults. They were grease monkeys with keyboard skills.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • DAB
    DAB 10 days ago

    Very nice.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube