Arduino Uno limited program storage space

Hello

I just discover the Cayenne tool and give it a try.

Pretty nice, but to my surprise ( i’m un experimented) it use nearly 50% of my program storage space. Project is not finished and I’m using 90% of the available space.

Sketch uses 29074 bytes (90%) of program storage space. Maximum is 32256 bytes.
Global variables use 1445 bytes (70%) of dynamic memory, leaving 603 bytes for local variables. Maximum is 2048 bytes.

Any trick to reduce it?

I understand that an easy solution is to get another processor, but for the moment, this is the one that I got.

Martin

My amateur code… I’m a newby

#include “HX711.h”
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <CayenneMQTTEthernet.h>

LiquidCrystal_I2C lcd(0x21, 20, 4); // set the LCD address to 0x27 for a 16 chars and 2 line display

//#define CAYENNE_DEBUG // Uncomment to show debug messages
//#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “2d0bc3f0-2390-11ea-a38a-d57172a4b4d4”;
char password = “0ec6d172b2ad6324253cef027df4e87c1faf32c7”;
char clientID = “7e949c00-2391-11ea-8221-599f77add412”;

int calibration = 15000;

#define calibration_factor calibration //This value is obtained using the SparkFun_HX711_Calibration sketch 5VDC
//#define calibration_factor 15350.0 //This value is obtained using the SparkFun_HX711_Calibration sketch 3.3 VDZ

#define DOUT 3
#define CLK 2

byte _data; //KeySwitch
byte aButton;//KeySwitch
unsigned long previousMillis = 0;
const int interval = 1000;
long Poids;

HX711 scale;

void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID);

//Key SwitchWire.begin();
Wire.beginTransmission(0x20);
Wire.write(0xff); // put a high level on pins
Wire.endTransmission();

// Serial.println(“HX711 scale demo”);

scale.begin(DOUT, CLK);
scale.set_scale (calibration); //(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0

lcd.init();
lcd.setCursor(0, 0);
lcd.print("Balance: ");
//Serial.println(“Readings:”);
}

void loop() {
int Button();
aButton = Button();

if (aButton == 1) {
lcd.setCursor(0, 1);
lcd.print(“TARE”);
scale.tare();
// delay(1000);
lcd.setCursor(0, 1);
lcd.print(" ");
}
//if (aButton == 3) {Serial.println(aButton);}
//if (aButton == 4) {Serial.println(aButton);}
//if (aButton == 5) {

if (aButton == 6) {
(calibration = calibration + 100);

}

//Call reset
if (aButton == 7) {
lcd.setCursor(0, 2);
lcd.print(“Reset”);
//delay(1000);
softReset();
}
aButton == 10;

//____________________

//Serial.print(“Reading: “);
//Serial.print(scale.get_units(), 2); //scale.get_units() returns a float
//Serial.print(” kg”); //You can change this to kg but you’ll need to refactor the calibration_factor
// Serial.println();
lcd.setCursor(0, 3);
lcd.print(scale.get_units(10), 2);
lcd.print(" kg ");

}
//Function______________________________________________

byte Button() {
byte data;
const int debounce = 225;
byte aButton
= (0);
Wire.begin();
Wire.requestFrom(0x20, 1);
if (Wire.available()) {
_data = Wire.read();

if (_data < 255) {
  delay(debounce);
  if (_data == 254) aButton_ = 1;
  if (_data == 251) aButton_ = 3;
  if (_data == 247) aButton_ = 4;
  if (_data == 239) aButton_ = 5;
  if (_data == 223) aButton_ = 6;
  if (_data == 191) aButton_ = 7;
  return aButton_ ;
}

}
}

//Reset
void softReset() {
asm volatile (" jmp 0");
}

is there any thing else to be added to the code? 90% memory should be fine to make your project work.

guarda, io ho gli stessi problemi, prova a sostituire serial.print o lcd.print con serial.print(F( che libera memoria.
altri , leggendo in giro, dicono di lavorare sulle stringhe…ma non sono ancora capace. speriamo qualcuno ci aiuti

Hello Shramik

Yes there is still code to be implant. I guess that I still need to add another 25% of code to the project.

The goal is to take weight measurement of 4 scales then send the data to either a cloud (Cayenne) or directly to a Google sheet (https). The data doesn’t need to be live. Only one measurement per day could be done.

Problems:

  • Arduino with Ethernet shield is not suitable to handle the “https” protocol.

  • Arduino with Cayenne take too much code memory space.

Solution could be to move the project to a bigger processor.

Martin

I guess best will be an esp8266 development board like nodemcu or wemos.