I'm running a program on a ATtiny85 and running into problems because of a lack of available RAM. When I ran avr-nm on my ELF file I found that SoftwareSerial was taking up a lot of RAM even though I'm just using it to set the data transfer rate with mySerial.begin(9600); and nowhere else.

So I'm wondering if there is another way of doing this without using so much memory:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(0,1);


Simplest thing would probably be to edit your copy of SoftwareSerial.h and replace #define _SS_MAX_RX_BUFF 64 on line 42 by something smaller. If your loop() runs fast enough (no delays, no blocking code) you could probably get away with buffering only a very few bytes.

Or you could rewrite the library so that, instead of buffering the incoming bytes, it handles them to you for processing. See for example this receive-only UART code based on the USI port for an illustration of the approach.

  • Where would I go to edit my SoftwareSerial.h? Also my program is working with a camera and I am using delays to send a clock impulse does that mean that lowering the buffer rate would not work for me? – Angel Lockhart Jun 14 '16 at 20:12
  • 1
    @AngelLockhart: It's probably somewhere like $ARDUINO_HOME/hardware/arduino/avr/libraries/SoftwareSerial/src/SoftwareSerial.h, where $ARDUINO_HOME is you Arduino installation directory. You can use the search facilities of your OS. If your clock pulses are very short (a few microseconds or so), the delays may be OK. Otherwise you should learn to control timings without delay(). – Edgar Bonet Jun 14 '16 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.