Hi, I am running a Seeeduino Mega and have another serial device downline sending data to the Mega on Serial3. I receive data at the right times, but it's all garbled. All the characters correspond to ASCII characters that are >127 (for the most part).
Does the Serial.read() command read one BYTE at a time? One INT at a time? Do I need to split the INT? How do I convert the int's I am reading into char's? I am slightly confused, if you can't tell. I would appreciate any suggestions anyone might have.
So I don't know how to set the settings for the Serial ports... only Serial.begin(9600). Could you tell me how to play with those settings? The device is set for no parity, 9600 baud. A typical data package should look something like this:
Compared to RS232 signals which can range from -12V (1) to +12V (0), the TTL signal expected by the Arduino is inverted and smaller in range: +5V (1) to 0V (0).
You need some circuitry like a MAX232 or derivative, or an inverter circuit, to invert the voltage levels. And possibly protect your Arduino from the higher voltage range.
OK I will look into that chip and report my findings... but it sounds like there could be a software fix if it's just inverted logic. Anyone else want to weigh in?
Thx, P
P.S. I still would like to know how to set the serial pot settings for any given port... parity, stop bits, etc///
A software fix could be done, but I suspect it would be much more time-consuming (and aggravating) to write (and debug), than to use a simple TTL / RS232 signal shifter.
If you're not interested in writing to the device, then all you need is 1 transistor and 2 resistors to make a simple inverting switch.
Even if you don't need to write to the device, consider getting a proper converter anyway. They are not expensive, less than $10, and you will use it a lot if you are doing much work with micro-controllers.