I have an Android app that sends 4 letters messages every 500 milisseconds, my Arduino is supposed to receive each message and print it on the screen. Just it, receive the message, and Println it.
The problem is that seems that my bluetooth is kind of Buffering the received data, waiting for a new receive and printing all together, if there isn't about a 1 second delay between one message and the other, my arduino get them like it was only one message and print it all once.
Example: App send "0000" every 500 mili forever, Arduino prints nothing for 4 seconds and them prints 8 times "0000" at once and repeats that randomly
I already know the problem is not in my Android code, so I came here for a answer.
My bluetooth module is running in a baud rate of 54600.
Since bluetooth is faster and serial is slower, consider switching the bluetooth to the hardware USART and printing from the software serial port. It is also possible to receive bluetooth on the Rx pin and print on the Tx pin of the same USART. Also, avoid using readString() and stick with counting characters and read(), then print when charsRead >=3 (assuming 0 is the first char).
B4rbosa:
My bluetooth module is running in a baud rate of 54600.
In that case, consider yourself lucky to get anything intelligible at all, and change it to 38400 maximum straight away. The best you can expect out of Software serial is 38400.
You can be pretty crude with serial input, and I do almost exactly the same as reply #3, but not as repetitively. If I recall correctly, I had to add a short delay to make it reliable.
while (bluetooth.available()>0)
{
delay(3);
char c = bluetooth.read();
This is not to deny doing a kosher job as in reply #2. If you don't need to now, you probably will eventually.