Arduino Mcp2515

Developer tools

Arduino MCP2515 CAN interface library.

Your AI app calls the Arduino Mcp2515 MCP server, which does the developer tools work and sends the result back to the chat.

About Arduino Mcp2515

Arduino Mcp2515 is a community MCP server from autowp, filed in our directory under developer tools. Arduino MCP2515 CAN interface library.

At a glance

Publisher
autowp (community)
Runs
See the README for setup
Written in
C++
License
MIT
GitHub stars
1,044

How to set up Arduino Mcp2515

  1. Follow the install steps in the Arduino Mcp2515 README; it is written in C++, so have that toolchain ready.
  2. Check the Arduino Mcp2515 README for keys or settings; the registry lists none that Arduino Mcp2515 requires.
  3. Add Arduino Mcp2515 to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Arduino Mcp2515 tools to confirm the connection.
  5. Run one read-only task with Arduino Mcp2515 first, and keep your app asking before each tool call until the results look right.

Arduino Mcp2515 compared with similar servers

  • Opentabs by opentabs-dev has fewer GitHub stars than Arduino Mcp2515 (1k against 1k); both are community servers, and both run locally.
  • Awwwards by INSANE0777 has more GitHub stars than Arduino Mcp2515 (1.1k against 1k); both are community servers, and both run locally.
  • Mcpm Sh by pathintegral-institute has fewer GitHub stars than Arduino Mcp2515 (1k against 1k); both are community servers, and both run locally.

Before you connect Arduino Mcp2515

  • Give Arduino Mcp2515 its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Arduino Mcp2515 tool call until you trust what it does with them.
  • Treat text that Arduino Mcp2515 fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Arduino Mcp2515 on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Arduino Mcp2515

How marketing and sales teams put Arduino Mcp2515 to work, by company size. Pick the size closest to yours and start Arduino Mcp2515 on one use case.

Small business

  • A small business with a developer can use Arduino Mcp2515 to ship site and tracking fixes faster, with the AI reading the code it changes.
  • Technical founders can ask Arduino Mcp2515 to explain and fix a marketing site issue without context switching between tools.
  • Arduino Mcp2515 runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Growth engineers can use Arduino Mcp2515 to build landing pages, tracking and integrations in fewer cycles, with reviews kept in the normal flow.
  • Marketing ops engineers can connect Arduino Mcp2515 to keep scripts and automations documented and versioned as they change.
  • Start Arduino Mcp2515 on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprise engineering teams can roll out Arduino Mcp2515 with repo scopes and audit logs, so agents work only where they are allowed.
  • Platform teams can standardize on Arduino Mcp2515 so web and marketing engineering share one reviewed way of working with AI.
  • Arduino Mcp2515 is a community server, so have security review the code and pin a version before Arduino Mcp2515 touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Arduino Mcp2515 README

From autowp/arduino-mcp2515 on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

Arduino MCP2515 CAN interface library


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. This CAN-BUS Shield gives your Arduino/Seeeduino CAN-BUS capability. With an OBD-II converter cable added on and the OBD-II library imported, you are ready to build an onboard diagnostic device or data logger.
  • Implements CAN V2.0B at up to 1 Mb/s
  • SPI Interface up to 10 MHz
  • Standard (11 bit) and extended (29 bit) data and remote frames
  • Two receive buffers with prioritized message storage

Contents:

  • Hardware
    • CAN Shield
    • Do It Yourself
  • Software Usage
    • Library Installation
    • Initialization
    • Frame data format
    • Send Data
    • Receive Data
    • Set Receive Mask and Filter
    • Examples

Hardware:

CAN Shield

The following code samples uses the CAN-BUS Shield, wired up as shown:

Do It Yourself

If you want to make your own CAN board for under $10, you can achieve that with something like this:

Component References:

  • MCP2515 Stand-Alone CAN Controller with SPI Interface
  • MCP2551 High-speed CAN Transceiver - pictured above, however "not recommended for new designs"
  • MCP2562 High-speed CAN Transceiver with Standby Mode and VIO Pin - an updated tranceiver since the MCP2551 (requires different wiring, read datasheet for example, also fragmuffin.github.io/howto-micropython/slides/index.html#/7)
  • TJA1055 Fault-tolerant low speed CAN Transceiver. Mostly used in vehicles.

Software Usage:

Library Installation

  1. Download the ZIP file from https://github.com/autowp/arduino-mcp2515/archive/master.zip
  2. From the Arduino IDE: Sketch -> Include Library... -> Add .ZIP Library...
  3. Restart the Arduino IDE to see the new "mcp2515" library with examples

Initialization

To create connection with MCP2515 provide pin number where SPI CS is connected (10 by default), baudrate and mode

The available modes are listed as follows:

mcp2515.setNormalMode(); // sends and receives data normally, sends acknowledgments to other nodes, when sending data, requires an acknowledgment from another node that the message was received or else, the 2515 will autonomously keep sending the same data
mcp2515.setNormalOneShotMode(); // sends and receives data normally, sends acknoledgements to other nodes that their message was received, when sending data, does not require an acknowledgement from another node that the message was received.
mcp2515.setLoopbackMode(); // data sent is immediately received and is not written to the bus, does not send acknowledgements
mcp2515.setListenOnlyMode(); // does not send data, only receives data, does not send acknowledgements

The available baudrates are listed as follows:

enum CAN_SPEED {
    CAN_5KBPS,
    CAN_10KBPS,
    CAN_20KBPS,
    CAN_31K25BPS,
    CAN_33KBPS,
    CAN_40KBPS,
    CAN_50KBPS,
    CAN_80KBPS,
    CAN_83K3BPS,
    CAN_95KBPS,
    CAN_100KBPS,
    CAN_125KBPS,
    CAN_200KBPS,
    CAN_250KBPS,
    CAN_500KBPS,
    CAN_1000KBPS
};

Example of initialization

MCP2515 mcp2515(10);
mcp2515.reset();
mcp2515.setBitrate(CAN_125KBPS);
mcp2515.setLoopbackMode();


You can also set oscillator frequency for module when setting bitrate:
mcp2515.setBitrate(CAN_125KBPS, MCP_8MHZ);

If necessary, you can change the SPI bus speed. The default speed is 10 MHz, which is not officially supported by the Arduino Uno, for example. Example for changing it to 8 MHz:
MCP2515 mcp2515(10, 8000000);

The available clock speeds are listed as follows:
enum CAN_CLOCK {
    MCP_20MHZ,
    MCP_16MHZ,
    MCP_8MHZ
};

Default value is MCP_16MHZ

Note: To transfer data on high speed of CAN interface via UART dont forget to update UART baudrate as necessary.

Frame data format

Library uses Linux-like structure to store can frames;

struct can_frame {
    uint32_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */
    uint8_t  can_dlc;
    uint8_t  data[8];
};

For additional information see SocketCAN

Send Data

MCP2515::ERROR sendMessage(const MCP2515::TXBn txbn, const struct can_frame *frame);
MCP2515::ERROR sendMessage(const struct can_frame *frame);

This is a function to send data onto the bus.

For example, In the 'send' example, we have:

struct can_frame frame;
frame.can_id = 0x000;
frame.can_dlc = 4;
frame.data[0] = 0xFF;
frame.data[1] = 0xFF;
frame.data[2] = 0xFF;
frame.data[3] = 0xFF;

/* send out the message to the bus and
tell other devices this is a standard frame from 0x00. */
mcp2515.sendMessage(&frame);
struct can_frame frame;
frame.can_id = 0x12345678 | CAN_EFF_FLAG;
frame.can_dlc = 2;
frame.data[0] = 0xFF;
frame.data[1] = 0xFF;

/* send out the message to the bus using second TX buffer and
tell other devices this is a extended frame from 0x12345678. */
mcp2515.sendMessage(MCP2515::TXB1, &frame);

Receive Data

The following function is used to receive data on the 'receive' node:

MCP2515::ERROR readMessage(const MCP2515::RXBn rxbn, struct can_frame *frame);
MCP2515::ERROR readMessage(struct can_frame *frame);

In conditions that masks and filters have been set. This function can only get frames that meet the requirements of masks and filters.

You can choose one of two method to receive: interrupt-based and polling

Example of poll read

struct can_frame frame;

void loop() {
    if (mcp2515.readMessage(&frame) == MCP2515::ERROR_OK) {
        // frame contains received message
    }
}

Example of interrupt based read

volatile bool interrupt = false;
struct can_frame frame;

void irqHandler() {
    interrupt = true;
}

void setup() {
    ...
    attachInterrupt(0, irqHandler, FALLING);
}

void loop() {
    if (interrupt) {
        interrupt = false;

        uint8_t irq = mcp2515.getInterrupts();

        if (irq & MCP2515::CANINTF_RX0IF) {
            if (mcp2515.readMessage(MCP2515::RXB0, &frame) == MCP2515::ERROR_OK) {
                // frame contains received from RXB0 message
            }
        }

        if (irq & MCP2515::CANINTF_RX1IF) {
            if (mcp2515.readMessage(MCP2515::RXB1, &frame) == MCP2515::ERROR_OK) {
                // frame contains received from RXB1 message
            }
        }
    }
}

Set Receive Mask and Filter

There are 2 receive mask registers and 5 filter registers on the controller chip that guarantee you get data from the target device. They are useful, especially in a large network consisting of numerous nodes.

We provide two functions for you to utilize these mask and filter registers. They are:

MCP2515::ERROR setFilterMask(const MASK mask, const bool ext, const uint32_t ulData)
MCP2515::ERROR setFilter(const RXF num, const bool ext, const uint32_t ulData)

MASK mask represents one of two mask MCP2515::MASK0 or MCP2515::MASK1

RXF num represents one of six acceptance filters registers from MCP2515::RXF0 to MCP2515::RXF5

ext represents the status of the frame. false means it's a mask or filter for a standard frame. true means it's for a extended frame.

ulData represents the content of the mask of filter.

Examples

Example implementation of CanHacker (lawicel) protocol based device: https://github.com/autowp/can-usb

For more information, please refer to wiki page .

This software is written by loovee (luweicong@seeed.cc) for seeed studio,
Updated by Dmitry (https://github.com/autowp)
and is licensed under The MIT License. Check LICENSE.md for more information.

Contributing to this software is warmly welcomed. You can do this basically by
forking, committing modifications and then pulling requests (follow the links above
for operating guide). Adding change log and your contact into file header is encouraged.
Thanks for your contribution.

Seeed Studio is an open hardware facilitation company based in Shenzhen, China.
Benefiting from local manufacture power and convenient global logistic system,
we integrate resources to serve new era of innovation. Seeed also works with
global distributors and partners to push open hardware movement.

Questions about Arduino Mcp2515

What is the Arduino Mcp2515 MCP server?

Arduino MCP2515 CAN interface library. Arduino Mcp2515 is maintained by autowp on GitHub at autowp/arduino-mcp2515, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Arduino Mcp2515 MCP server?

Arduino Mcp2515 doesn't publish a one-line install in the MCP registry, so follow the setup steps in its README on GitHub (autowp/arduino-mcp2515). Like most servers, Arduino Mcp2515 ends with a command or URL you paste into your AI app's MCP config.

Does Arduino Mcp2515 need an API key?

The registry lists no required keys for Arduino Mcp2515. Check the Arduino Mcp2515 README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Arduino Mcp2515 an official MCP server?

No. Arduino Mcp2515 is a community server maintained by autowp. Community servers can be excellent; read the code and the open issues before you give Arduino Mcp2515 access to company data.

What license is Arduino Mcp2515 under?

Arduino Mcp2515 is released under the MIT license, according to its GitHub repository. The license covers the code of Arduino Mcp2515; the service it connects to has its own terms.