How to increase Arduino NG baud rate

Hello,

I'm new here and also a beginner in arduino's developpement and I have some questions about an Arduino NG with an atmega168 that I have.

I try to transfer the more informations I can (in my case it is boolean values) /second on the serial port.

For now, I just have a very simple program that just send a byte each time he could :

void setup() {
  Serial.begin(19200);
}

void loop() {
  Serial.println(255);
}

And recieved this signal with processing :

void setup() {
  Serial port = new Serial(this, Serial.list()[0], 19200);
  port.bufferUntil('\n');
}

void serialEvent(Serial port) {
   String inString = port.readStringUntil('\n');
}

I got 390 strings/second on average, so if my calculs are good that 390 * (3 + 2) * 8 = 15600 bits/seconds and 390 * 8 = 3120 boolean/second (remeber I want to transfer booleans or bits).

I can gain a bit by increasing the size of the number I'm sending and by calling print with a simple \n at the end but I want something faster.

And when I try a higher baud rate it doesn't work at all, or I got like 8 strings/seconds.

Why ? Is there a baud rate limit ? Cause when I looked at the atmega168 datasheet, they don't mention such a limit. But the boards.txt specify the upload rate to 19200.

Can I increase this limit ? Is there a way to output directly in a binary format (not an ASCII representation) my data ? This way I could send maybe 15000 booleans/second which should be enough.

EDIT : I didn't saw the Serial.write() method which answer my second question :).

Thank you for your attention, Andréas

When using serial communication you need to make both sides are using the same baude rate. So, if you set 19200 for sending then the receiving side should also be set for that.

If I remember correctly 19200 is the default of the Arduino Serial Monitor. If you want read/write at a higher rate not only need you set it higher in your sketch but you also need to set the serial monitor to that higher setting.

Thank you for your reply.

I am aware that baud rate need to be specified in both side, but I got problems with that.

I tried on a Windows machine to set the baud rate to 115200 and it worked ! And now it work on my linux machine too...

I must have missed something, maybe my tests was wrong, but the essential is that it is working now.

I can generate 30000 booleans/sec which seems to be good so far.

And if I want to have faster results, I'll look at a faster chip (lastest arduino or maybe raspberry pi).

Greetings, Andréas