Arduino pro mini problems

I am using an arduino pro mini, but when the size of the sckecth increases it begins to fail, for example the serial port does not fully read what it receives or the oled screen no longer shows anything.

Please how can I solve it?

Reduce the size of the sketch you didn't post

Please read your post with the mindset that folks in the forum have no prior knowledge of what you are doing. Can you even imagine how we might be able to answer?

sorry, I think I explained in a very superficial way, what I mean by if it is that when my sketch takes more than 60% occupied, arduino pro mini begins to fail mainly with the reading of strings that it receives through SoftwareSerial.

I thought that the percentage is still not so high as to fail

#include <Wire.h> // libreria para bus I2C
#include <Adafruit_GFX.h> // libreria para pantallas graficas
#include <Adafruit_SSD1306.h> // libreria para controlador SSD1306
#include <SoftwareSerial.h>

SoftwareSerial Bus(2, 3); // RX, TX

static const unsigned char PROGMEM opdoor {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x03, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0x83, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xfb, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x3f, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x3f, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x3f, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

#define ANCHO 128
#define ALTO 64

#define reading 0
#define writing 1
#define rs485 12
#define bot 4

bool Start = false;
bool Press = false;

String incoming = "";
String sending = "";

int Push = 0;

#define OLED_RESET 5
Adafruit_SSD1306 oled(ANCHO, ALTO, &Wire, OLED_RESET);

void setup() {
  Wire.begin();
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  Serial.begin(9600);
  Bus.begin(9600);
  Serial.println("Panel botonera iniciado");

  oled.clearDisplay(); // limpia pantalla
  oled.setTextColor(WHITE); // establece color al unico disponible (pantalla monocromo)
  oled.setCursor(0, 0); // ubica cursor en inicio de coordenadas 0,0
  oled.setTextSize(2); // establece tamano de texto en 1
  oled.print("OPEN ");
  oled.setCursor(50, 7);
  oled.setTextSize(1.8);
  oled.print("Systems");
  oled.setCursor(62, 56);
  oled.setTextSize(1);
  oled.print("open.com.gt");
  oled.display();

  pinMode(bot, INPUT_PULLUP);
  pinMode(rs485, OUTPUT);
  delay(3000);

  digitalWrite(rs485, writing);
  delay(10);
  Bus.print("P1");
  digitalWrite(rs485, reading);
  delay(10);
}

void loop() {

  Push = digitalRead(bot);

  if (Push == LOW)
  {
    delay(1000);
    Botonera();
  }

  while (Bus.available() > 0)
  {
    incoming = Bus.readString();
    delay(20);
    commands();
  }
}

void commands()
{

  / if (incoming.indexOf("CBE3") > -1)
  {
    oled.clearDisplay();
    oled.setCursor(0, 20);
    oled.setTextSize(1);
    oled.print("Conectado a central");
    oled.setCursor(0, 40);
    oled.setTextSize(2);
    oled.print(incoming);
    oled.display();
    Serial.println("Conexion panel central establecida");
    Start = true;
    delay(3000);
  } /

  if (incoming.indexOf("F1") > -1)
  {
    oled.clearDisplay();
    oled.setCursor (45, 5); // ubica cursor en coordenas 10,30
    oled.setTextSize(8);
    oled.print("1");
    oled.display();
  }

  if (incoming.indexOf("F2") > -1)
  {
    oled.clearDisplay();
    oled.setCursor (45, 5); // ubica cursor en coordenas 10,30
    oled.setTextSize(8);
    oled.print("2");
    oled.display();
  }

  if (incoming.indexOf("F3") > -1)
  {
    oled.clearDisplay();
    oled.setCursor (45, 5); // ubica cursor en coordenas 10,30
    oled.setTextSize(8);
    oled.print("3");
    oled.setCursor (98, 25);
    oled.setTextSize(5);
    oled.cp437(true);
    oled.write(24);
    oled.setCursor (2, 5);
    oled.setTextSize(5);
    oled.cp437(true);
    oled.write(25);
    oled.display();
  }

  if (incoming.indexOf("D1") > -1)
  {
    oled.clearDisplay();
    oled.setCursor(65, 10);
    oled.setTextSize(1);
    oled.print("Puerta");
    oled.setCursor(65, 25);
    oled.print("nivel 1");
    oled.setCursor(65, 40);
    oled.print("Abierta!!");
    oled.drawBitmap(0, 0, opdoor, 128, 64, WHITE);
    oled.display();
  }

  if (incoming.indexOf("D2") > -1)
  {
    oled.clearDisplay();
    oled.setCursor(65, 10);
    oled.setTextSize(1);
    oled.print("Puerta");
    oled.setCursor(65, 25);
    oled.print("nivel 2");
    oled.setCursor(65, 40);
    oled.print("Abierta!!");
    oled.drawBitmap(0, 0, opdoor, 128, 64, WHITE);
    oled.display();
  }

  if (incoming.indexOf("D3") > -1)
  {
    oled.clearDisplay();
    oled.setCursor(65, 10);
    oled.setTextSize(1);
    oled.print("Puerta");
    oled.setCursor(65, 25);
    oled.print("nivel 3");
    oled.setCursor(65, 40);
    oled.print("Abierta!!");
    oled.drawBitmap(0, 0, opdoor, 128, 64, WHITE);
    oled.display();
  }

  / if (Start)
  {
    oled.clearDisplay();
    oled.setCursor(5, 0);
    oled.setTextSize(2);
    oled.print("Bienvenido");
    oled.display();
    Start = false;
    delay(2000);
    oled.clearDisplay();
    sending = "Floor?";
    Buscom();
  } /
  Serial.println(incoming);
}

void Botonera()
{
  Serial.println("Solicitud de elevador");

  digitalWrite(rs485, writing);
  delay(10);

  Bus.print("S1");

  digitalWrite(rs485, reading);
  delay(10);

  oled.clearDisplay();
  oled.setCursor(0, 5);
  oled.setTextSize(2);
  oled.print("Ascensor");
  oled.setCursor(0, 35);
  oled.setTextSize(2);
  oled.print("solicitado");
  / oled.setCursor (2, 5);
  oled.setTextSize(5);
  oled.cp437(true);
  oled.write(25); /
  oled.display();
}

void Buscom()
{
  digitalWrite(rs485, writing);
  delay(10);

  Bus.print(sending);

  digitalWrite(rs485, reading);
  delay(10);
}

as is the sketch works fine, I can fully read the strings that I receive through (incoming = Bus.readString ():wink:
but at the time of adding anything to the sketch the failure begins, I do not receive the complete values ​​of Bus.readString (); or I do not receive them in their entirety, it does not matter what I add to the sketch but the failure begins

What memory usage does the compiler report when you upload the sketch?

El Sketch usa 19304 bytes (62%) del espacio de almacenamiento de programa. El máximo es 30720 bytes.
Las variables Globales usan 808 bytes (39%) de la memoria dinámica, dejando 1240 bytes para las variables locales. El máximo es 2048 bytes.

Hi,
To add code please click this link;

Thanks... Tom... :smiley: :+1: :coffee: :australia:

thanks friend, i didn't know how to do that

The library for your OLED probably allocates a buffer of 128x64 bits = 1024 bytes of RAM in addition to the 808 bytes already reported.
That pushes you close to your 2048 bytes of RAM, and then a few Strings could push you over.
You could make better use of the F() macro for the string literals in your prints, but I doubt that would be enough to cure this.

:sob: Sure, I understand, is there a library for OLED that is less heavy?

u8g2?

Thank you so much my friend :star_struck:

If you only need text and no graphics you can use the Bill Greiman library, it is considerably smaller.

Thank you so much bro

This one

library has the option to work without a buffer at all.
And this

is a lightweight version of the Wire library.

1 Like

Thank you very much bro, I will try it immediately

Good afternoon friends, I have good news, my problem has already been solved, what caused the failures were the libraries that I was using, these are very heavy as mentioned by TheMemberFormerlyKnownAsAWOL
I used the libraries that flashko suggested to me and PUM freed the consumption of all the resources of my arduino, now I can even put animations, images or whatever I want in addition to the code that I had mentioned previously,

Thank you very much for your support.

I thank you too much, you helped me a lot, these libraries are crazy, they are great