Go Down

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

RjSowden

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.begin(9600);
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!

pylon

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.

PaulS

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

Where did that "fact" come from?

pylon

Quote
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?

PaulS

Quote
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.

smeezekitty

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!

Go Up