Hey,
I want to connect my Arduino Uno (or just a ATMEGA328) with an ELM327 (cheap version but with bluetooth Module).
Now I desoldered the bluetooth module and connected Wires to RX/TX just like in the pictures. I've got the Idea from a Youtube video but he did not posted his code sadly...
I also tried this code:
#include <SoftwareSerial.h>
#include "ELMduino.h"
SoftwareSerial mySerial(2, 3); // RX, TX
#define ELM_PORT mySerial
ELM327 myELM327;
uint32_t rpm = 0;
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
Serial.begin(38400);
ELM_PORT.begin(38400);
Serial.println("Attempting to connect to ELM327...");
if (!myELM327.begin(ELM_PORT))
{
Serial.println("Couldn't connect to OBD scanner");
while (1);
}
Serial.println("Connected to ELM327");
}
void loop()
{
float tempRPM = myELM327.rpm();
if (myELM327.status == ELM_SUCCESS)
{
rpm = (uint32_t)tempRPM;
Serial.print("RPM: "); Serial.println(rpm);
}
else
{
Serial.print(F("\tERROR: "));
Serial.println(myELM327.status);
delay(100);
}
}
I've got the ELMduino library ofc and I also tried this code:
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
String inputString = ""; // a string to hold incoming data
SoftwareSerial softwareSerial(8, 9);
int serIn;
char serInString[100]; // array that will hold the different bytes 100=100characters;
// -> you must state how long the array will be else it won't work.
int serInIndx = 0; // index of serInString[] in which to insert the next incoming byte
int serOutIndx = 0; // index of the outgoing serInString[] array;
//This is a character buffer that will store the data from the serial port
char rxData[20];
char rxIndex=0;
//Variables to hold the speed and RPM data.
int vehicleSpeed=0;
int vehicleRPM=0;
void setup()
{
Serial.begin(38400);
softwareSerial.begin(38400);
Serial.println("Start...");
delay(1000);
softwareSerial.flush();
softwareSerial.println("ATZ");
delay(1000);
softwareSerial.print("ATZ\r");
delay(5000);
softwareSerial.print("ATE0\r");
delay(1000);
softwareSerial.print("ATL0\r");
delay(1000);
softwareSerial.print("ATSP0\r");
delay(1000);
softwareSerial.print("0100\r");
delay(5000);
}
void readOBD() {
char inChar;
String rec = "[";
// only if there are bytes in the serial buffer execute the following code
if(softwareSerial.available()) {
Serial.print("available!");
//keep reading and printing from serial untill there are bytes in the serial buffer
while (softwareSerial.available()>0){
inChar = softwareSerial.read(); //read Serial
if(inChar == '\r' || inChar == '\n') break;
rec += String(inChar);
}
rec += "]";
if(rec.length() > 4)
{
Serial.println(rec);
}
else {
rec = "";
}
}
}
void loop()
{
softwareSerial.println("010C");
readOBD();
delay(200);
}
I'am also more than sure that I have to use the ELM327 chip for my car and I also have sucessfully connected one like 1 year ago but with a MCP2515 and a Renault Twingo. Now I've got a Renault Clio 5 (2020) and it uses the ELM327 with the CAN protocol. Found it on this site: OBD-2 Liste (erfolgreich) gescannter Fahrzeuge
So after hours of googling and trying is my last chance to ask in this forum for help I also could try to connect the ELM327 via bluetooth but I'm pretty sure there will be a delay in the transfer via bluetooth and in the end I want to build a REV limiter and a shifting light. I just need to know how I can connect to the ELM327 via Serial connection. I hope you can help!