Global variables

Questions about the Waspmote v15 and its modules
Post Reply
Posts: 25
Joined: Tue Jul 23, 2019 10:47 am
Company: IBEC

Global variables

Post by jburgues » Fri Oct 18, 2019 2:21 pm


I produced a sketch with only a few global variables, but when I compile, the compiler says:

Global variables use 6,518 bytes (79%) of dynamic memory, leaving 1,674 bytes for local variables. Maximum is 8,192 bytes.
Low memory available, stability problems may occur

Where are these 6518 bytes of global variables coming from if I'm only declaring around 100 bytes of global variables? How can I reduce the number of global variables or increase the limit of 8192 bytes.

This is the beggining of the sketch before the setup() function:

#include <WaspXBee868LP.h>
#include <WaspFrame.h>
#include <WaspSensorGas_Pro.h>
#include "Wasp4G.h"

#define MOX_ENABLED 0
#define GPS_ENABLED 0
#define EC_CONC_ENABLED 0 // Decides if Libelium's concentration of EC sensors is to be computed
#define RTC_ENABLED 0

float CO2_adc; // Stores the concentration level in ppm
float CO_we; // Stores the concentration level in ppm
float CO_ae; // Stores the concentration level in ppm
float NH3_we; // Stores the concentration level in ppm
float SO2_we; // Stores the concentration level in ppm
float SO2_ae; // Stores the concentration level in ppm
float H2S_we; // Stores the concentration level in ppm

uint8_t battery; // Stores the pressure in Pa

uint8_t error;

bmeGasesSensor bme;
float temperature; // Stores the temperature in ºC
float humidity; // Stores the realitve humidity in %RH
float pressure; // Stores the pressure in Pa

Gas CO2_sensor(SOCKET_1);
Gas NH3_sensor(SOCKET_3);
Gas H2S_sensor(SOCKET_2);
Gas CO_sensor(SOCKET_5);
Gas SO2_sensor(SOCKET_4);

////////////////// XBee configuration ////////////////////////
// Destination MAC address
char RX_ADDRESS[] = "0013A2002312330AB";

// Define the Waspmote ID
char WASPMOTE_ID[] = "n1";

uint8_t show_frame = 0; // print the frame to the USB port

// Local function prototypes
uint8_t xBee_send (char* rx_addr, uint8_t* frame_buffer, uint16_t frame_length);
uint8_t initializeGPS(void);


////////////////// SD card configuration ////////////////////////
// folder and file to store data
char path[]="/data";
char filename[]="/data/log";

Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Global variables

Post by libelium-dev » Mon Oct 21, 2019 10:16 am


It's due to the variables declared in the libraries. You can check the .h files to know all the declared variables.


Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest