Gadget999:
the obd device needs a port
and i want to transmit the data to a pc using serial
so 2 ports needed
i will try the leonardo / mega
do you just name the serial to Serial1 etc ?
no need, just use SoftwareSerial library the pro mini is quite capable of handling it, what's the UART baud rate? there's a limit to high softSerial can handle.
#include <NewSoftSerial.h>
//
NewSoftSerial mySerial(2, 3);
/
//void setup()
{
mySerial.begin(9600); //replace 9600 with baud rate of the UART.
}
void loop()
{
char c;
if (mySerial.available())
{
c = (char)mySerial.read(); // get the UART OBDC data
Serial.println(c); //spit it out to the pc.
}
}
code]
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
mySerial.begin(9600);
}
void loop() // run over and over
{
char c;
if (mySerial.available())
{
c=mySerial.read();
mySerial.print(c);
}
}
Stick the UART of the ODBC into pins 2&3 remember to change the Serial baud rate to match or it will be garbage you'll get back and send.
Yes these will be better to use than the nano. The Leonardo can emulate a USB serial device back to the computer leaving the hardware UART free. Or as nick said the Mega has four serial ports.
Using software serial on a nano is a poor choice given the resources you have.