Serial reading problem


void setup() {
  Serial.begin(115200); // Serial Port initialization
void loop() {
  if(Serial.available()) // Chek for availablity of data at Serial Port
    char data =; // Reading Serial Data and saving in data variable
    Serial.print(data); // Printing the Serial data

So this is what I get with the code above.
Everything is fine and the text is ok.

#include <SoftwareSerial.h>

#define BAUDRATE 115200

SoftwareSerial hwSerial(0, 1); // RX, TX

void setup() {
  Serial.begin(BAUDRATE); // Serial Port initialization
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  Serial.println("USB COM Connected!");

void loop() {
  if(hwSerial.available()) // Chek for availablity of data at Serial Port
    char inByte =;


Then I want to distinct the two serial interfaces to be able to send some text from the terminal (not implemented in the code above).
Anyway, for some reason everything just become impossible to read…

Any suggestion?

Does software serial even work at 115200?

Yes, in the first pic is 115200, but it works :confused:

abdulalb: Yes, in the first pic is 115200, but it works :confused:

The first pic uses hardware.

Sorry i'm a bit confused.. what do you mean exactly? In the first code I declared


Sorry, I started to play with serial only today and I really want to understand what happen in the second code

That uses the microcontroller’s own hardware serial interface, which will work up to hundreds of thousands of bits per second.

At 115200 bits per second, it is barely breaking a sweat.

You’re expecting the software serial interface to be able to keep up.
That is overly optimistic.

Reduce the rate to something more realistic, like 2400.

Also, move the software instance off the pins used by the hardware.

Don't use hardware serial and software serial (on pins 0 and 1) at the same time. Remove anything Serial related from your second code and bring the baudrate down to 9600.

It does not really make sense to use SoftwareSerial on the HardwareSerial pins, but for learning it might be useful.

Thanks for the quick answers,

Actually I need 115200 because I want to read the serial output from a small computer.
Actually this is the situation:


And I really need to implement some code that can read and write trough the serial…

What can be the best way to get that?
Is there any way to add the writing function to the first code?

Either lower the bit rate, or use a device with at least two hardware serial interfaces.


if the bitrate for the minibox is fixed, then the only option is to use swSerial for the comm with the workstation, for that you may need an extra USB to TTL, you won’t need to go down as far as 2400, but swSerial does not support 115200 reliably (57600 can be done with AltSoftSerial library)