arduino IDE serial monitor display incorrect string

Hello,
would appreciate your help on the following problem:
at start , when I use the default serial.begin(9600) to read a string and print to my PC's serial monitor , it work well;
but after I just only changed to use serial.begin(9600,SERAIL_8E1) to do exactly the same thing, incorrect string is display on the serial monitor.....
how is the possibility...? any further configuration ? or coding need to be modified?

serial.begin(9600,SERAIL_8E1)won't compile, but you mean Serial.begin(9600,SERIAL_8E1) ? That changes the parity from 'none' to 'even' so that basically adds an extra bit to be sent. The SM is expecting 9 bits per byte and you are sending 10.

Thanks Deva_Rishi !

could you give me a simple sample code for receiving site's handling? thanks!

https://forum.arduino.cc/index.php?topic=396450

thanks, i m looking into it

The default setting is Serial.begin(9600,SERIAL_8N1)that is what the Serial monitor expects.

receiving site's handling

?? what do you mean by 'site' ?

i mean how to display correct string on my PC's serial monitor...

Deva_Rishi:

serial.begin(9600,SERAIL_8E1)

won't compile, but you mean

Serial.begin(9600,SERIAL_8E1)

? That changes the parity from 'none' to 'even' so that basically adds an extra bit to be sent. The SM is expecting 9 bits per byte and you are sending 10.

An element/character of the English Language Alphabet Set has 7-bit ASCII code and then a zero (0) bit appended to make it 8-bit. This is the basic character length in the UART domain of ATmega328P/IDE Platform. After that the STARTBit and STOPBit are added to make a 10-bit wide asynchronous UART frame (Fig-1). The Arduino IDE does not implement the parity option. The SM is expecting 10-bit per frame from which it strips out the STARTBit and STOPBit and finally the 8-bit wide character is extracted and displayed on the OutputBox.
asyncFrameX.png
Figure-1:

The OP may read this post.

asyncFrameX.png

Hi GolamMostafa ,

Tks, from what your mention, it may get problem when using Arduino IDE serial monitor to display some element/ character that is serial transfered in, with employing parity bit; but no impact on a node to node communication.
am i right?

Hi All,

Strange! the same thing can display correctly in Raspberry Pi arduino serial monitor, i mean display same between Serial.begin(9600) and Serial.begin(9600, SERIAL_8E1) when i use Raspberry Pi as an arduino ide runing platform..

samsoniot:
Hi All,

Strange! the same thing can display correctly in Raspberry Pi arduino serial monitor, i mean display same between Serial.begin(9600) and Serial.begin(9600, SERIAL_8E1) when i use Raspberry Pi as an arduino ide runing platform..

It is not a strange but a fact that Raspberry Pi supports it. I have no experience working with Raspberry Pi. To my knowledge Arduino UNO/NANO/MEGA IDE/SM supports only 10-bit wide frame; where, there is no provision for the parity bit (Fig-1). Arduino Dev Team may include parity option in their future IDE.
asyncFrame.png
Figure-1: Async UART frame with parity option

asyncFrame.png

samsoniot:
[...]but no impact on a node to node communication.
am i right?

You can communicate between two ATmega328Ps of two UNOs at any frame structure of your choice in which case, you might be required to write register level codes in place of read()/write() methods.