-1

I've never used arduino before but am using one for a school project. I am using an arduino leonardo and I've uploaded the sample code below

#include "Adafruit_CCS811.h"
Adafruit_CCS811 ccs;

void setup() {
    Serial.begin(9600);
    Serial.println("CCS811 test");
    if(!ccs.begin()){
        Serial.println("Failed to start sensor! Please check your wiring.");
        while(1);
    }

    //calibrate temperature sensor
    while(!ccs.available());
    float temp = ccs.calculateTemperature();
    ccs.setTempOffset(temp - 25.0);
}

void loop() {
    if(ccs.available()){
        float temp = ccs.calculateTemperature();
        if(!ccs.readData()){
            Serial.print("CO2: ");
            Serial.print(ccs.geteCO2());
            Serial.print("ppm, TVOC: ");
            Serial.print(ccs.getTVOC());
            Serial.print("ppb Temp:");
            Serial.println(temp);
        } else {
            Serial.println("ERROR!");
            while(1);
        }
    }
    delay(500);
}

But when I upload it, all I see a message that states

Sketch uses 8830 bytes (30%) of program storage space. Maximum is 28672 bytes.
Global variables use 487 bytes (19%) of dynamic memory, leaving 2073 bytes for local variables. Maximum is 2560 bytes.

Does this mean there is not enough storage in my computer or is there not enough space in the arduino? This arduino was given to me second hand.

I'm unsure if it is now appropriate to be able to see results show up on the serial monitor? Because nothing is showing up.

2
  • Where it is a Leonardo, you may want to put while (!Serial) {} immediately following your Serial.begin. This will essentially wait until the Serial monitor establishes a connection so that you are not losing any diagnostic messages.
    – timemage
    Commented Nov 13, 2020 at 0:55
  • Please read your problem carefully. It says that your program uses 30% of your space and 19% of dynamic memory. You are nowhere close to full. @jwh20 answered it perfectly. Commented Nov 26, 2020 at 18:55

2 Answers 2

3

There is no problem here, please read the message carefully!

It says you are ONLY using 30% of the available program memory and 19% of the dynamic memory.

You have a LOT more room left.

5
  • So is this not a real error message then? This should show up after every upload? I'm unsure whether to tell if it was successful because there are no data values that show in the serial monitor. Commented Nov 12, 2020 at 20:01
  • 1
    This is not an error message. It's an informational message. Yes, this will show up after every upload to the Arduino.
    – jwh20
    Commented Nov 12, 2020 at 20:08
  • As far as nothing showing up in the serial monitor, that's another issue altogether. Perhaps you should try one of the simpler examples as a starting point to help get yourself familiar with the Arduino and its toolchain? The Blink Example is a good place to start.
    – jwh20
    Commented Nov 12, 2020 at 20:09
  • 1
    @jwh20 your comment about the message showing after an upload is incorrect ... the message shows at the end of the code compile process .... the upload happens afterward
    – jsotola
    Commented Nov 12, 2020 at 21:22
  • Thanks for the clarification. It's too late to edit the comment.
    – jwh20
    Commented Nov 12, 2020 at 22:34
1

What you are seeing there is not an error message, it is only for information. It shows how much memory you have left on the Arduino.

Sketch uses 8830 bytes (30%) of program storage space. Maximum is 28672 bytes.

This is about the program storage, also known as flash storage (which is the type of storage technology used here). It is, where the actual program is saved, and is non-volatile (which means, that it holds the data/your code even during power loss). The message tells you, that the Arduino Leonardo has a total of 28672 bytes of storage for your program. When you write bigger programs, you will also use more of the flash/program storage. That means, that the size of the flash/program storage (which is a hardware limit in the microcontroller) gives you an upper limit to the size of the compiled program, as it cannot be more than 100% of the maximum given there and still upload. Though note, that the compiler does a lot of optimization to your code, so there is no easy relation between C/C++ code size and compiled code size. You need to actually compile your code to see, what size it will be and if it fits onto your Arduino. And that is exactly, what this message is meant for.

The message tells you, that you are using 30% of the flash/program storage. Thus you are very well inside the limits.

Global variables use 487 bytes (19%) of dynamic memory, leaving 2073 bytes for local variables. Maximum is 2560 bytes.

The second line is about the memory, where variables are stored, aka dynamic memory aka RAM. Of course this means the RAM inside of the Arduino. The RAM is volatile, which means, that every data in it will vanish, when the Arduino is powered off or reset.

Every time, that you declare a variable in your code, this variable is put into the RAM. Calculating the maximum amount of RAM, that will be used in your code, is rather complex, as variables are created and destroyed very often, when calling functions or other programming constructs. But global variables (the ones declared outside of any function) are created right at the start of the program, thus the compiler can easily calculate their size.

This message gives you a hint, if you are going to run out of RAM with your program. It is only a hint. Because of that, the compiler will show a warning at that point, if you are going in the realm of 75% or higher of the available RAM, that this might not leave enough room for local variables and thus risks instability in the program. (Note, that I'm not sure about the exact limit, from which on the warning is displayed. You may try to research this detail).

When you program runs out of RAM, it will fail or producing instability. So you want to prevent that from happening. Currently you are at 19%. Also you are using few local variables, so you are save here.

I'm unsure if it is now appropriate to be able to see results show up on the serial monitor? Because nothing is showing up.

You should at least be able to see the message CCS811 test on the Serial monitor. If not, please make sure, that you really uploaded the code (by clicking on the upload button, not on the verify button). In the preferences you can turn on verbose output for compilation and upload, to find possible problem sources. Also make sure, that you chose the correct port and that your Serial Monitor is configured for the same baudrate as your sketch (in this case 9600 baud).

If that still doesn't give any output at all, try to upload the Blink example, that you can find in the Arduino IDE in the menu under examples -> Basics. If it uploads successfully, watch, if the buildin LED starts to blink. If yes, that code is working correctly.

If the init message is showing up, but the temperature values are not, you need to first check for your connections. Then you could try to upload the standard I2C scanner sketch, that shows you, what devices can be found on the I2C bus and what addresses they have.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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