MCP2515 SendMSGBuf with Arduino Nano Every

I am using the coryjfowler library for MCP2515 with an Arduino Nano Every and I am continually getting error 6 when attempting to transmit data with sendMsgBuf(). I am trying to use the gear indicator at the links below:

https://www.powertraincontrolsolutions.com/aftermarket/displays/sku/GDR5005
https://pcswebsite.s3.amazonaws.com/resources/PCS%20J1939%20Messages%20v2_1.pdf

Any help is greatly appreciated. My current code is shown below. I am trying to the J1939 protocol, but I have also tried to use the GMLAN protocol at the link below:

https://pcswebsite.s3.amazonaws.com/resources/PCS%20Proprietary%20CAN%20Messages%20v1_1.pdf

#include <Arduino.h>
#include <mcp_can.h>
#include <SPI.h>

MCP_CAN sendCAN(10);  // Set CS to pin 10

void setup() {
  // put your setup code here, to run once:
  pinMode(readCAN_INT, INPUT);
  Serial.begin(115200);

  // Initialize MCP2515 running at 8MHz with a baudrate of 250kb/s and the masks and filters disabled.
  if (sendCAN.begin(MCP_ANY, CAN_250KBPS, MCP_8MHZ) == CAN_OK)
    Serial.println("MCP2515 Initialized Successfully on Pin 10!");
  else
    Serial.println("Error Initializing MCP2515...on Pin 10");
  sendCAN.setMode(MCP_NORMAL);  // Change to normal mode to allow messages to be transmitted
}

byte dataToScreen[8] = { 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

void loop() {
  // put your main code here, to run repeatedly:
  sendCAN();
}

void sendCAN(){
  byte sndStat = sendCAN.sendMsgBuf(0x18F00504, 1,8, dataToScreen);
  if(sndStat == CAN_OK){
    Serial.println(dataToScreen[0]);
    Serial.println("Message Sent Successfully!");
  } else {
    Serial.println("Error Sending Message...");
    Serial.println(sndStat);
  }
  delay(100);   // send data per 100ms
}

Please post an annotated schematic showing exactly how you have wired everything. Be sure to include all components, such as resistors, capacitors, and any other relevant parts. I have used that library in many projects and have not experienced any issues.


This is how the MCP2515 is connected to the Nano.

The MCP2515 does have a jumper on the internal 120ohm resistor to enable it. I have a 120ohm on the other end of the CAN bus as well. Only 2 nodes on the bus. Is there a good online tool that would let me easily produce a schematic?

As an aside, I have used a multimeter and confirmed that each end of the can bus measures 120ohm when disconnected. The system measures 60ohm between CANHI and CANLOW. And both CANH and CANL measure ~2.4-2.6V during operation. All of these checks lead me to believe that the bus itself is healthy and wired correctly.

FYI
Literally today I finished my first project with an MCP2515. Its all working now but I had problems. I was looking to transmit 0x18FEFC00 with an 8 byte payload. Luckily I have an oscilloscope which allowed me to see the data sent. Some libraries worked for me and others didn't. I just wanted something to work. I ended up with the CAN library by Sandeep Mistry. With this library I was able to see the full 29 bit transmission and check the important bits, including bit stuffing. Perhaps this library is worth a try for your project

I agree, as you later confirmed. I will continue using the library I currently have, as I have about 25 copies running without any issues and see no reason to change.

Thank you for letting us know that it is working.