Serial1 receive buffer size (on the Arduino Zero / Adafruit Feather M0)


Does anyone know a good/easy/efficient way to increase the size of only the Serial1 receive buffer on the Zero?

I am using the Adafruit Feather M0:

When I edit RingBuffer.h and increase the SERIAL_BUFFER_SIZE to (e.g.) 6144, it uses up four times as much RAM as it needs to as it increases both the receive and transmit buffers for both Serial1 and Serial5.

If I edit variant.h and variant.cpp and comment out the Serial5 definitions, I can reduce this to a factor of two.

Ideally, I would like to increase the size of the Serial1 receive RingBuffer only - without having to create my own variant.

Any suggestions?

Many thanks in advance,


Any suggestions?

usually (not in all cases) when one want to increase the buffer size, it’s due to a weak design of the code. You should read the buffers yourself often enough to empty them and not let them overflow.

Seems here you want a HUGE buffer… may be good to look exactly at what you are trying to achieve. (the libraires have been developed to use the same SERIAL_BUFFER_SIZE (within their RingBuffer) for all UArt instances)

Hopefully not weak design in this case! :smiley:

I'm logging high data rate GNSS RAWX serial data to SD card. I need the receive buffer to be large enough so I don't drop any data when closing one SD log file and opening the next.



Thanks J-M-L. That’s got me thinking. Maybe it is weak design…

What if I created my own RingBuffer:

RingBufferN<6144> SerialBuffer;

and then used a Timer interrupt to check Serial1.available say every 500us and copy any data it finds into my RingBuffer:

if (Serial1.available()) {

and then replaced my usual calls with:


I feel some tests coming on…


worth exploring but then you don't need a new RingBuffer, just a buffer to store the data

in your interrupt other interrupts would be stopped, including Serial data coming in. so you would need to empty the buffer but not go one step too far.

Seems to work OK:

Happy days!