The estimated reading time for this post is 134 seconds
It has been so long since I connect … but I swear , I was trying to put together code and study Eagle.
I must thank the Arduino forum for all the valuable aids !
The hardest part was the memory management : I’m used to program in Net and having access to a few Kb made me crazy!
I decided to read better the documentation to understand how to use memory a little better.
ARDUINO MEMORY
The Arduino UNO micro controller is ATmega328P and it as the following types of memory :
- Flash (program space), is where the Arduino sketch ( program ) is stored .
- SRAM (static random access memory) is where the sketch creates and manages the variables when it is running .
- EEPROM is a type of non-volatile memory , a memory that can retain information even when not powered .
For each micro controller you have available a different amount of memory :
ATMega168 | ATMega328P | ATmega1280 | ATmega2560 | |
---|---|---|---|---|
Flash (1 Kbyte used for bootloader) |
16 KBytes | 32 KBytes | 128 KBytes | 256 KBytes |
SRAM | 1024 bytes | 2048 bytes | 8 KBytes | 8 KBytes |
EEPROM | 512 bytes | 1024 bytes | 4 KBytes | 4 KBytes |
For Arduino UNO :
Flash 32k bytes
SRAM 2k bytes
EEPROM 1k byte
Strings types in particular uses a large amount of memory, and in my sketch I use them a lot of time to write on the web client ( client.println ) and on the console ( Serial.print ) .
For example, the command: Serial.println ( ” Trying to connect” ) ; occupies 18 bytes of SRAM memory ( 1 char = 1 byte plus the newline character ).
I remember that SRAM has available 2048 bytes!
Since version 1.0 Arduino IDE allows use of F ( ) function which allows to storage strings in FLASH memory and not in the SRAM.
So I decided to storage in FLASH memory all the strings used in client.println , solving SRAM memory problems ( int type, float type, and strings type not grouped with F ( ) will be initialized and managed in the SRAM memory) .
If you have time read this article .
Here comes weekend and finally ( I hope) I will have time to publish the code changes and Eagle project files.
Bye!