CLEAR BLUETOOTH BUFFER

Hi Everyone,

I'm using a bluetooth module RN-42 in order to transmit data from 2 sensors( flow sensor and pressure sensor) to my PC. I would like to know how i could clear the bluetooth buffer between two transmission. I have read something about "Serial.flush()" and i have already tried it, but it seems don't work well.

Do you have any idea?

Thank you, Kaisy

You shouldn't need serial flush and there is no such thing as a bluetooth buffer.

Serial.print(flow);
Serial.print",";
Serial.println(pressure);

is about all you need.

is about all you need.

Well, posting the code that seems to need fixing would be a good idea.

The Arduino is sending data to the bluetooth device using an instance HardwareSerial or SoftwareSerial. Both have incoming and outgoing buffers. Which one are you thinking you need to flush? The outgoing serial buffer if emptied by using flush() (to wait until the data has been completely sent). "flushing" the incoming buffer means throwing away random amounts of unread data. While that can be done, I think it is such a stupid thing to do that I won't repeat the really simple code that does it. A little gray matter application will reveal that throwing away random amounts of unprocessed data is no different from actually processing the data, except that you don't actually do the processing.