Pages: [1]   Go Down
Author Topic: Library sizes on ATTiny85 - what size are they?  (Read 680 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm considering a couple of projects with the ATTiny85 which has 8KB of flash.

Is it correct that when you include a library, it sits in flash and reduces overall available space?

I want to consider SoftwareSerial and also TinyWire - how do I calculate how much space they will take up in flash??

Is there a list of libraries and compiled sizes anywhere?

Many thanks for your help.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5677
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm considering a couple of projects with the ATTiny85 which has 8KB of flash.

Is it correct that when you include a library, it sits in flash and reduces overall available space?

Yes. That's what the flash is for.

I want to consider SoftwareSerial and also TinyWire - how do I calculate how much space they will take up in flash??

Compile them and see. You don't even need a Tiny85 to do it, just compile without uploading.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 506
Posts: 19120
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it correct that when you include a library, it sits in flash and reduces overall available space?

I want to consider SoftwareSerial and also TinyWire - how do I calculate how much space they will take up in flash??

All your code goes into flash, library or not.

Quote
Is there a list of libraries and compiled sizes anywhere?

It would vary by processor, and also adding two libraries almost certainly would use less combined space than each one alone. This is because they are likely to share functions (eg. floating point maths). So you can't just add up the figures for each library and get a total.

Even adding a library, the memory used depends on whether you use all its features. Example:

Code:
void setup ()
  {
  Serial.begin (115200);
  }  // end of setup

void loop () { }

Compiles (for the Uno) to 1,744 bytes.

Now add one line (from the same library):

Code:
void setup ()
  {
  Serial.begin (115200);
  Serial.flush ();
  }  // end of setup

void loop () { }

Now it compiles to 1,760 bytes.

Add another couple of lines:

Code:
void setup ()
  {
  Serial.begin (115200);
  Serial.flush ();
  if (Serial.available ())
    Serial.print (Serial.read ());
  }  // end of setup

void loop () { }

Now 2,270 bytes.

And that is all from the HardwareSerial library.

So, there is no easy answer. Try it and see.
Logged


Melbourne, Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 567
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm considering a couple of projects with the ATTiny85 which has 8KB of flash.

Is it correct that when you include a library, it sits in flash and reduces overall available space?

I want to consider SoftwareSerial and also TinyWire - how do I calculate how much space they will take up in flash??

Is there a list of libraries and compiled sizes anywhere?

Many thanks for your help.

It depends on what you use from the library. Just because a class or method is defined in the library, does not mean it gets compiled into your sketch.
Typically, only the methods you actually call will get compiled (linked) in. Everything else gets left out.

Only reliable way to tell is to write the code, compile it and see.
Logged

Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

Pages: [1]   Go Up
Jump to: