I am attempting to communicate with my Arduino Mega using a standard "telnet" terminal through my computer's serial port.
It is working, when I send a character it shows up in the monitor, but it is gibberish even though I have the baud settings the same on both my terminal and the Arduino ports (9600).
Here is the full sketch:
void setup() {
// initialize both serial ports:
Serial.begin(9600);
Serial3.begin(9600);
}
void loop() {
// read from port 3, send to port 0:
if (Serial3.available()) {
int inByte = Serial3.read();
Serial.print(inByte, BYTE);
}
}
In my terminal I have it set to 9600,8,N,1, and when I sent "test" I get this in the monitor:
"
QSt
"
Any hints/ideas/links/etc. would be greatly appreciated!
You might try running the telnet and software serial at 2400 bps to see if there is a difference. I would think software serial would be somewhat timing critical when receiving data.
@zoomkat: I have tried at every standard baud, and get varying results with different baud rates - but nothing that works (similar results as my first post). Also, I am using hardware serial ports, not software.
@tkbyd: Thanks for the link, I went over everything there, and I don't see any explanation or reason for the results that I am seeing. The bytes he sends is simply the bytes he receives here:
@BenF: The rx and tx is hooked up straight from the serial port of the PC to the arduino.
The guide link posted by tkbyd states that the voltage is not the same and a PC serial port can fry an arduino, but I already had it hooked before I read that, and sense it didn't fry it I assumed it must be OK.
Might you please explain the difference or provide a link that does?
How can it even works?
A 0 in rs-232 is a 12v signal and a 1 is a -12v signal, how can your arduino can even still work after getting -12v in one pin?
To connect an rs-232 device as your pc, you need a transceiver, that is basically a signal(voltage) shifter, such as max232
A more practical solution is to build a rs-232 to ttl voltage converter, most utilize a max232 chip or equivalent. Another method is to purchase a converter:
The TTL voltage levels are +5volt equals a one or a mark (from the
-12v rs-232 state and ground equals zero or a space (from the +12v rs-232 state).
A more fundamental questions is why are you not using the USB serial interface built into your mega? Your board has a FTDI USB serial converter chip that can handle both uploading new sketches to your board as well as to communicate to any PC program that can work with a comm port.
Thats really good to know about the USB port too. Eventually though, I will need to simulate (using a PC instead of instruments) for four simultaneous RS-232 devices (one for each serial port on the Mega).
So I just got a RS-232 converter to TTL and it is still doing the same exact thing.
Exactly the same thing as before you put the TTL / RS232 converter in line.
I don't think so.
If it truly is doing the same thing then you have not connected it up correctly.