Trying to read CAN Bus with MCP2515 and coryjfowler MCP_CAN_lib

Hello,

I have a MCP2515 board like this:
mcp2515
I connected it to an Arduino nano and I tried to use coryjfowler's MCP_CAN_lib, but without any success.
The CAN Bus is from a Stiebel Eltron heat pump which I would like to monitor.

For debugging I have another professional tool which works fine with the CAN Bus.
This shows following information:
CAN Bus
So the CAN Bus works fine.

I already modified the example code from

Serial.begin(115200);

to

Serial.begin(9600);

and from

if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK)

to

if(CAN0.begin(MCP_ANY, CAN_20KBPS, MCP_16MHZ) == CAN_OK)

After compiling and uploading the serial monitor shows:

Entering Configuration Mode Successful!
Setting Baudrate Successful!
MCP2515 Initialized Successfully!
MCP2515 Library Receive Example...

But nothing else...
Any hint what could be the problem and any hint how to get the data from the CAN Bus?

Thanks and best regards,
Chris

Hopefully it is as easy as changing the crystal frequency.
if(CAN0.begin(MCP_ANY, CAN_20KBPS, MCP_16MHZ) == CAN_OK)
Should probably be
if(CAN0.begin(MCP_ANY, CAN_20KBPS, MCP_8MHZ) == CAN_OK)
Those boards use an 8MHz crystal. See the 8.000 on the silver can? The shields tend to be 16MHz.

This is also the first time someone send me a screen shot of PCAN-View! Awesome! :slight_smile:

It really is as easy like that.
Nice, it works like charm:

Entering Configuration Mode Successful!
Setting Baudrate Successful!
MCP2515 Initialized Successfully!
MCP2515 Library Receive Example...
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x28
Standard ID: 0x69F       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xD3
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0E 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF2
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x24 0x16 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x26 0x0F 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x23 0x0C 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x25 0x10 0x00
Standard ID: 0x69E       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0C 0x00 0x28
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x0F 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0F 0x00 0xF9
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x11 0x00 0xD3
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x28
Standard ID: 0x69F       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xD3
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0E 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF3
Standard ID: 0x69E       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0C 0x00 0x28
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x0F 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0F 0x00 0xF8
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x11 0x00 0xD3
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x28
Standard ID: 0x69F       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xD3
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0E 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF2
Standard ID: 0x69E       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0C 0x00 0x28
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x0F 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0F 0x00 0xF9
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x11 0x00 0xD3
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x28
Standard ID: 0x69F       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xD3
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0E 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF2

Thank you so much!

Best regards,
Chris

1 Like

hmmmm, now I have another issue: CAN data output from MCP2515 on ESP8266 is different than on Arduino nano

I have hooked up a MCP2515 on my heat pump to monitor the status.
I found that the output is different on an ESP8266 (my preferred solution because of wifi capability) versus an Arduino nano.
On the ESP8266 the adresses above 1000 are missing?!

On the ESP8266 I have this sketch running:

#include <mcp_can.h>
#include <SPI.h>
long unsigned int rxId;
unsigned char len = 0;
unsigned char rxBuf[8];
char msgString[128];          // Array to store serial string
#define CAN0_INT 16           // Set INT to pin 2 (nodemcu = 16, nano = 2)
MCP_CAN CAN0(5);              // Set CS to pin 10 (nodemcu = 5, nano = 10)

void setup()
{
  Serial.begin(9600);
  delay(200);
  if (CAN0.begin(MCP_ANY, CAN_20KBPS, MCP_8MHZ) == CAN_OK)
    Serial.println("MCP2515 Initialized Successfully!");
  else
    Serial.println("Error Initializing MCP2515...");
  CAN0.setMode(MCP_NORMAL);                     // Set operation mode to normal so the MCP2515 sends acks to received data.
  pinMode(CAN0_INT, INPUT);                     // Configuring pin for /INT input
  Serial.println("MCP2515 Library Receive Example...");
}

void loop()
{
  if (!digitalRead(CAN0_INT))                 // If CAN0_INT pin is low, read receive buffer
  {
    CAN0.readMsgBuf(&rxId, &len, rxBuf);      // Read data: len = data length, buf = data byte(s)
    if ((rxId & 0x80000000) == 0x80000000)    // Determine if ID is standard (11 bits) or extended (29 bits)
      sprintf(msgString, "Extended ID: 0x%.8lX  DLC: %1d  Data:", (rxId & 0x1FFFFFFF), len);
    else
      sprintf(msgString, "Standard ID: 0x%.3lX       DLC: %1d  Data:", rxId, len);
    Serial.print(msgString);
    if ((rxId & 0x40000000) == 0x40000000) {  // Determine if message is a remote request frame.
      sprintf(msgString, " REMOTE REQUEST FRAME");
      Serial.print(msgString);
    } else {
      for (byte i = 0; i < len; i++) {
        sprintf(msgString, " 0x%.2X", rxBuf[i]);
        Serial.print(msgString);
      }
    }
    Serial.println();
  }
}

and this is the output:

Entering Configuration Mode Successful!
Setting Baudrate Successful!
MCP2515 Initialized Successfully!
MCP2515 Library Receive Example...
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x23 0x0C 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x24 0x16 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x25 0x0B 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x26 0x33 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x22 0x14 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x00 0x01 0x00 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x5D
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF8
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0C 0x00 0x5D
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0F 0x00 0xEB
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x26 0x34 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x5D
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF9
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0C 0x00 0x5D
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0F 0x00 0xEB
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x5E
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF9
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0C 0x00 0x5E
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0F 0x00 0xEB
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x5D
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF9
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x00 0x01 0x00 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x76 0x04 0x01
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x12 0x0B 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x22 0x14 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x26 0x34 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x21 0x01 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x5E
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF9
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x5D
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF8
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0C 0x00 0x5E
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0F 0x00 0xEB
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x25 0x0B 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x26 0x34 0x00
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x00 0x01 0x00 0x00

on the Arduino nano I have this sketch running (the only difference are the pin assignments "#define CAN0_INT 2" and "MCP_CAN CAN0(10);"

#include <mcp_can.h>
#include <SPI.h>
long unsigned int rxId;
unsigned char len = 0;
unsigned char rxBuf[8];
char msgString[128];          // Array to store serial string
#define CAN0_INT 2           // Set INT to pin 2 (nodemcu = 16, nano = 2)
MCP_CAN CAN0(10);              // Set CS to pin 10 (nodemcu = 5, nano = 10)

void setup()
{
  Serial.begin(9600);
  delay(200);
  if (CAN0.begin(MCP_ANY, CAN_20KBPS, MCP_8MHZ) == CAN_OK)
    Serial.println("MCP2515 Initialized Successfully!");
  else
    Serial.println("Error Initializing MCP2515...");
  CAN0.setMode(MCP_NORMAL);                     // Set operation mode to normal so the MCP2515 sends acks to received data.
  pinMode(CAN0_INT, INPUT);                     // Configuring pin for /INT input
  Serial.println("MCP2515 Library Receive Example...");
}

void loop()
{
  if (!digitalRead(CAN0_INT))                 // If CAN0_INT pin is low, read receive buffer
  {
    CAN0.readMsgBuf(&rxId, &len, rxBuf);      // Read data: len = data length, buf = data byte(s)
    if ((rxId & 0x80000000) == 0x80000000)    // Determine if ID is standard (11 bits) or extended (29 bits)
      sprintf(msgString, "Extended ID: 0x%.8lX  DLC: %1d  Data:", (rxId & 0x1FFFFFFF), len);
    else
      sprintf(msgString, "Standard ID: 0x%.3lX       DLC: %1d  Data:", rxId, len);
    Serial.print(msgString);
    if ((rxId & 0x40000000) == 0x40000000) {  // Determine if message is a remote request frame.
      sprintf(msgString, " REMOTE REQUEST FRAME");
      Serial.print(msgString);
    } else {
      for (byte i = 0; i < len; i++) {
        sprintf(msgString, " 0x%.2X", rxBuf[i]);
        Serial.print(msgString);
      }
    }
    Serial.println();
  }
}

here is the output:

Entering Configuration Mode Successful!
Setting Baudrate Successful!
MCP2515 Initialized Successfully!
MCP2515 Library Receive Example...
Standard ID: 0x69E       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0C 0x00 0x5D
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x0F 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0F 0x00 0xEE
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x180       DLC: 7  Data: 0xD0 0x3C 0xFA 0x01 0x26 0x02 0x00
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x5D
Standard ID: 0x69F       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0E 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF8
Standard ID: 0x69E       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0C 0x00 0x5D
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x0F 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0F 0x00 0xEE
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x402       DLC: 7  Data: 0x60 0x01 0xFA 0x00 0x11 0x00 0xE0
Standard ID: 0x402       DLC: 7  Data: 0x60 0x01 0xFA 0x00 0x75 0xFD 0xA8
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x5E
Standard ID: 0x69F       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0E 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF8
Standard ID: 0x69E       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0C 0x00 0x5D
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x0F 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0F 0x00 0xEE
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0C 0x00 0x5E
Standard ID: 0x69F       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x11 0x00 0xCE
Standard ID: 0x69F       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0E 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1F 0xFA 0x00 0x0E 0x01 0xF9
Standard ID: 0x69E       DLC: 7  Data: 0x31 0x00 0xFA 0x00 0x0C 0x00 0xB0
Standard ID: 0x180       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0C 0x00 0x5E
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x0F 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x0F 0x00 0xF0
Standard ID: 0x69E       DLC: 7  Data: 0x61 0x01 0xFA 0x00 0x11 0x00 0xB0
Standard ID: 0x301       DLC: 7  Data: 0xD2 0x1E 0xFA 0x00 0x11 0x00 0xCE

As you can see on the ESP8266 the Standard IDs 0x402, 0x69E and 0x69F are missing.

Any idea why and how to solve this issue?

Thank you and best regards,
Chris

Huh, super strange. I would expect the opposite if it were the microcontroller speed as I believe the ESP8266 has a faster crystal and execution speed. Fortunately I recently acquired some of those, so I will see if I can recreate this issue and get back with you.

I am unfortunately unable to recreate the issue with the information I have, everything seems to work fine. I will note that at 20kbps, you will need to increase the send timeout value to avoid the error associated with it.

Sending these messages at some speeds to match what I seen from your screen shot

Receiving them on the second channel of my peak adapter.
The ESP is sending the 0x100 message.

And the ESP8266 capturing it.

Hi Cory,

thanks a lot for your support :slight_smile:

I guess it has something to do with the number range of a variable or something similar.
I guess it compiles differently for the Arduino nano than for the ESP8266.
But that's just my feeling without being a professional programmer.
I'm doing this at a low level hobby style without much time for programming and debugging.

I switched to linear mode and enabled all option: Log data frames, Log RTR, Log Status Changes, Log Error Frames, Log Error Counter Changes and Log Events

I recorded about 10 minutes and sent the zipped tracefile via PM.

Thank you and best regards,
Chris

By the way, I don't think it matters, but the Arduino nano has 5V GPIOs and the ESP8266 has only 3.3V GPIOs.

I think it does not matter because the ESP already receives data.
I also do not think that the pins I use matter.



I found the schematics here:


Source: http://forum.amperka.ru/attachments/cansan-jpg.16904/

I was reading that the ESP8266 has 5V tolerant IO. I have the CAN interface on my setup powered via VIN which is tied to USB 5V. I tried using a 3V3 pin out of curiosity and the CAN transceiver on the board would not see any of the traffic I was sending, but the library was talking to the MCP2515 just fine as there were no configuration issues.

In theory the transceiver on the Niren board is supposed to be the 5v version and therefore shouldn't work at all with 3.3v as there is an under voltage shutdown feature in the chip.

However, the worldwide shortage of CAN related chips has resulted in a flood of fake transceivers that have characteristics that don't match up with any known datasheet. The Niren boards almost certainly have these fake chips.

The board may be more reliable at 5v.

I bought this board in 2020, not recently.
The board works fine with 3,3V so far. Maybe I exchange the ESP8266 to a ESP32 to check if it works differently. Or I can add a level shifter to see if this changes anything.

Best regards,
Chris

@mikb55, that is super useful info! I know the NiRen boards I have predate the pandemic which could explain the differences we see here.

Would you be willing to try the NiRen board supplied with 5v first?

Simply swap the vcc Pin of the niren Board from 3,3V to Vin on the nodemcu, or something more?

That is it. That is how I have it setup.

If this works, then that suggests to me there is a subtle difference in the voltage levels of those missing messages and they just are not getting through the transceiver. From there, if you want to run the NiRen IO at 3v3, you would need to modify the NiRen board so that only the transceiver gets 5V power. (Eg, lifting a pin or cutting a trace and adding a wire)

Unbelievable! It works! :star_struck:

Here are the received Standard IDs:
Arduino nano:
0384
0769
1026
1694
1695

ESP8266 3,3V connected to vcc of niren Board
0384
0769

ESP8266 5,0V connected to vcc of niren Board
0384
0769
1026
1694
1695

Crazy!
Never in my life would I have expected this, that the received adresses are related to the supply voltage. I thought all or nothing, but not only a part of the result. This is really crazy for me.

So I need to hook up the board on Vin / 5V
What could be the risk?
Maybe the ESP8266 will not survive this for very long?!

Thank you so much and best regards,
Chris

1 Like

Meanwhile I purchased another CAN Board SN65HVD230 VP230, but it has not arrived yet:


This should work with 3,3V.
So this could be an alternative for correct working with the ESP8266

That SN65HVD230 is just the transceiver, the micro it connects to will need a CAN peripheral in it.

As for the ESP8266, there are sources that suggest and confirm the ESP8266 has always officially been 5V tolerant, but Espressif removed the information from the datasheet due to some incorrectly believing the ESP8266 can be powered directly from 5V and smoking their hardware. See this link for more info on this: Are the ESP32 and ESP8266 5V tolerant (Yes they officially are) – QWORQS

Depending on your soldering skills, you could put the SN65HVD230 on the NiRen board in place of the TJA1050 and the NiRen board should work fine at 3.3V because of that transceiver.

They are pin compatible! :smiley:
pin_compare

I think the ESP32 has can peripheral built in, i’ve Seen a video where the gentleman swapped from MCP2515 as with the system he was working kept messing up and kept missingthe system/data up. So he swapped to a MAX3051, Which I think is the same spec as the SN65HVD230.

I’ve just started to play with canbus and I’m using ESP32 and MAX3051 and so far so good and all working, I’ve used Arduino as a mock to send the extract same data as a battery monitor sends out as i don't always have access to it and so far all is working great.

I’m enjoying this topic and following with great interest. keep up the good work.