Go Down

Topic: Change Baud Rate of SoftwareSerial Communication after initial .begin (Read 3334 times) previous topic - next topic


I've got a GPS device that does not remember its settings once switched off, and I can't keep it switched on all the time. Its default baud rate that it will always start at is therefore 9600. However, I can configure it through serial to go to a higher baud rate, which is required for a function I wish my program to have.

I can send the change baud signal fine, but then of course I need to change the baud rate of the arduino to match it, otherewise I just get meaningless squiggles.

Can anyone help?
In case that explanation is a bit confusing, here is what I (essentiallu) want to do in code:

Code: [Select]
mySerial.write("XXXXXXXX"); // string to send to change baud rate
  mySerial.write(13); // returns to accept change
  mySerial.write(10); // ^^^^^^^^^^^^^^^^^^^
mySerial.begin(38400) // ISSUE: How can I change the baud rate HERE!

Thanks everyone who took time to read this and especially anyone who can help!


Your issue isn't an issue, you should do it exactly as you're already doing it: by calling begin() again with the changed baud rate. There's no problem in calling the begin() method multiple times on the same object. Keep in mind that 38400 is the maximum baudrate that works with SoftwareSerial and this already will keep your Arduino quite busy if lots of data is transferred.


Keep in mind that 38400 is the maximum baudrate that works with SoftwareSerial

Where did that "fact" come from?


Where did that "fact" come from?

Personal experience. I should have added "reliably" to my sentence. I never got 57600 baud running reliably with SoftwareSerial, although you could go up to 115200 baud theoretically. Maybe my serial devices were a bit picky about timing, have you got other experiences?


Maybe my serial devices were a bit picky about timing, have you got other experiences?

I've used it at 57600 to talk to XBees.

The NewSoftSerial web site says that it can work at 115200, but I was not successful transferring more than a few bytes at a time at that speed.


I find 115200 works just find for transmitting on softserial. I never tried receiving greater then 9600.
Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!


Hey Guys,
I am new in the forum.
I would like to ask a question about the baud rate change. I can explain my idea below:
I would like to set a MASTER ( like Arduino nano) baud rate (example 10000). Another side will be the SLAVE ( like Arduino UNO) that will read and change your baud rate to the new one.
To be clear I don't want to use the conventional baud rate like 300,1200,2400,9600,11200.... etc......

What do you think??
I would like to know your point of view!

Thanks in advance!


They both need to talk at the same baud rate.  Is the Slave going to talk to something else at the different baud rate using the hardware serial? You will have some piece of external (to the arduino) switching logic so the something else is not flooded with the master/slave traffic at the wrong baud rate?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


It will likely work if both Arduinos are using the same CPU chip and compiled using the same libraries. A slight error in one will be matched by the same error in the other. The one chance of failure is that the two CPUs have mismatched crystal frequencies and you're operating at very high rates.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131