My basic question is this: If I attach VCC (5V), GND, TX (pin 1), RX (pin 0) to my serial device, will commands I send to Arduino via the Serial Monitor get passed onto the serial device automatically? Also, will information being received from the attached serial device be passed back through arduino to the serial monitor on my computer?
I am hoping that this simple code will allow this transaction:
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
Basically, the arduino (for the time being) just needs to become a serial interface for the computer.
I did all of this, and I know my serial device is running at 9600, but all i get is trash on the serial monitor.
You can only have one driver on a serial line; your scenario has two drivers on each line.
You can use the arduino board as an rs232/USB adapter if you pull the ATmega chip first.
Also, rs232 has different voltages and levels than TTL devices (like the arduino). If your custom devices has true rs232 voltages (e.g. it has a DB9 port) you'll have to have a bit of hardware between it and the arduino board to convert those signals to TTL levels and voltages.
Ok, so the circuit I have contains a chip and then a circuit for RS232 adapter. See schem below.
Could I just chop out the RS232 adapter (attach directly to pin 5 & 6 on the ELM chip) and have arduino just send it HIGH/LOW bits? Would the same be for reception? I could then use the serial library to translate the binary coming in and spit the ASCII out to my computer.
may have answered my own question here. From the manual of the device I am building:
If connecting the ELM624's pin 6 directly to another logic circuit, you can eliminate the RS232 interface entirely. Your circuit need only be compatible with the CMOS logic levels, and you should expect that pin 6 will be at a high level when idle.
I think the signals might be the wrong way up for the connection directly to the Arduino. (as opposed to the computers RS232 line)
The data sheet says:-
Rx (pin5)
The computer's RS232 transmit signal is directly
connected to this pin through a single current
limiting resistor (typically about 47KW). Internal
signal inversion and Schmitt trigger waveshaping
provide the necessary signal conditioning.
This means if you are feeding the TX from an Arduino the signal will be upside down as the Arduino produces a logic one to indicate mark but the chip is expecting a logic zero.
The data sheet is a little more ambiguous about pin 6 but that should be all right.
Interesting about the reverse logic. Can i easily reverse the signal?
...if I just change the transmission style (reverse HIGH and LOW) in SoftwareSerial.cpp, do I need to recompile to SoftwareSerial.o to work when I include in my sketch? Is that the easiest way to solve this problem?
Another question I have been wrestling with. How exactly am I going to address the ELM chip? It's expecting HEX commands (to be passed on to the LANC device). So, if I want to send "1839" or "2CA9" to the lanc, what is the correct syntax for serial printing?