Hi friends,
I’m trying to get the RPM information connect to OBDII input, we use Arduino Mega and Arduino Canbus. The code is below we use :
#include <Wire.h>
// Cooking API libraries
#include <arduinoUtils.h>
// Include always these libraries before using the CAN BUS functions
#include <arduinoCAN.h>
#include <SPI.h>
// Create an instance
CAN myCAN = CAN();
void setup()
{
// Inits the UART
Serial.begin(115200);
delay(100);
// Print init message
Serial.println(“Initializing CANBUS…”);
// Configuring the BUS at 500 Kbit/s
// Only allowed in SOCKET 0
myCAN.begin(500);
Serial.println(“CANBUS initialized at 500 KBits/s”);
}
void loop()
{
// Read the value of RPM if the engine
long engineRpm = myCAN.getEngineRPM();
// Print received data in the serial monitor
Serial.print("RPM of engine : ");
Serial.println(engineRpm);
delay(1000);
}
I wonder , we have error code or wrong arduino mega&can bus connection? Could you help ?