"Full version" of Electronoobs code will also work on arduino UNO or NANO (ATmega328P) if you store all string in program memory (flash) via "F( )" macro.
e.g.: Serial.println(F("READY TO SEND")); ( or lcd.print(F("...")); )
Like this I reduce the used RAM to 70% (595 bytes left).
original code: 2185 byte (RAM) - 2048max 16566 byte (FLASH) - 30720max
modified code: 1453 byte (RAM) 16950 byte (FLASH)
//part of code for demonstrate
lcd.clear();
lcd.setCursor(0,0);
lcd.print(F("N1: ")); lcd.print(received_nr_1); lcd.print(F(" N2: ")); lcd.print(received_nr_2);
lcd.setCursor(0,1);
lcd.print(F("N3: ")); lcd.print(received_nr_3); lcd.print(F(" N4: ")); lcd.print(received_nr_4);
delay(1000);//5 seconds between tries
Also I have problem with compiling the sketch because my I2C LCD library does not include member "init()" but instead of it I just write "begin()". lcd.begin();
It depends on version of your library, just try which one would work for you. And if you have still problem with it open example sketch of your LCD I2C library and find the correct form of initializing command.
Or in some libraries you have to write some variables in this command like "lcd.begin(0x27,20,4);" (address and size).
#include
LiquidCrystal_I2C lcd(0x27,20,4);
lcd.begin();
lcd.init();
// one of these should work for you
Due to your modifications of code, if 595 bytes in RAM would not be enough (if it will still cause stability problems) you can also write other string (e.g.: const char SSID_ESP[] = "..."; const char SSID_KEY[] = "..."; ...) to program memory via PROGMEM macro.
e.g.: PROGMEM const char SSID_ESP[] = "...";
But you will need to write a little bit of code.
You will need to create a buffer (in RAM) where you will write one of strings from flash which will be use in next piece of code.
Something like:
PROGMEM const char SSID_ESP[] = "someSSID";
unsigned char buffer[bufferMaxLength];
for(i=0; i
buffer[i] = pgm_read_byte_near(&SSID_ESP[0]+i);
if(buffer[i]=='\0' /*end of string*/) break;
}
4 Comments
-
Noob 1513
about 4 years ago
Hi , I am having an issue with the #include
, how can I download this library? MAIN_ESP8266:3:23: error: avr/power.h: No such file or directory -
Noob 13506
about 4 months ago
Hola muy buen día a esta boinita comunidad tengo un problema a la hora de crear el sitio web y en la parte de subir los archivos que ELECTRONOOBS compartió, me arroja un error en el código (index.php) y a la hora de entrar al sitio web me arroja este error "Uncaught TypeError: mysqli_query(): Argument #1 ($mysql) must be of type mysqli, bool given in /storage/ssd3/757/20785757/public_html/index.php:34 Stack trace: #0 /storage/ssd3/757/20785757/public_html/index.php(34): mysqli_query() #1 {main} thrown in /storage/ssd3/757/20785757/public_html/index.php on line 34". Alguien me podria ayudar con este tema por favor, se lo agradeceria mucho.
-
Alex Juvion
about 29 days ago
congratulations and thanks for letting us know how to save SRAM / RAM of an arduino by using "F()" and "PROGMEM" macros of arduino wiring language and how to fix initialization of I2C LCD. Alex, Worried about deadlines? Our UK-based coursework help UK guarantees on-time delivery. Let us assist you in completing your coursework stress-free and well before your submission date.
ELECTRONOOBS
Thanks for all these improvements!