TIME AND DATE

I would like to put time and date inot this code, after the SALES line if possible?

[/#include <LiquidCrystal.h>                                       // include the LCD driver library

                                                                  //declare variables
 float tempC = 0;                                                 // Variable for holding Celcius temp (floating for decimal points precision)
 float tempf = 0;                                                 // variable for holding Fareghneit temp
 int tempPin = 0;                                                 // Declaring the Analog input to be 0 (A0) of Arduino board.
 float samples[8];                                                // Array to hold 8 samples for Average temp calculation
 float maxi = 0,mini = 100;                                       // Max/Min temperature variables with initial values. LM35 in simple setup only measures Temp above 0.
 int i;

                                              
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);                          // initialize the library with the numbers of the interface pins

 void setup()
 {
 Serial.begin(9600);                                             // Opens serial port, sets data rate to 9600 bps

 lcd.begin(16, 2);                                               // Set up the LCD's number of columns and rows:

 }

 void loop()
 {
 lcd.setCursor(2, 0);                                            // Set LCD cursor position (column, row)
 lcd.print("INSTALLED BY");                                      // Print text to LCD
 lcd.setCursor(0, 1);                                            // Set LCD cursor position (column,row) 
 lcd.print("EUROTECK SYSTEMS");                                       // Print text to LCD
 delay(3000); // wait 500ms                                      // Delay to read text
 lcd.clear(); // clear LCD display                               // Clear the display
 lcd.setCursor(0, 0);                                            // Set LCD cursor position (column, row)
 lcd.print("CALL 01827312455");                                      // Print text to LCD
 lcd.setCursor(0, 1);                                            // Set LCD cursor position (column,row) 
 lcd.print("FOR A ENGINEER");                                       // Print text to LCD
 delay(5000); // wait 500ms                                      // Delay to read text
 lcd.clear(); // clear LCD display
 lcd.setCursor(4, 0);                                            // Set LCD cursor position (column, row)
 lcd.print("OR SALES");                                      // Print text to LCD
 lcd.setCursor(0, 1);                                            // Set LCD cursor position (column,row) 
 delay(2000); // wait 500ms                                      // Delay to read text
 lcd.clear(); // clear LCD display                                            


 Serial.println("");                                            // Blank line for spacing in the serial monitor
 Serial.println("You are looking at a project built by WWC.");  // Print text to Serial monitor
 Serial.print("Feal free to use and modife as needed.");
 Serial.println("");                                            // Blank line for spacing in the serial monitor
 Serial.print("LM35 Raw data: ");                               // Print text to Serial monitor 
 Serial.println(analogRead(tempPin));                           // Displays on serial monitor the sampled value before conversion to real Temperature reading
  
                                                                // Start of calculations FOR loop.
 for(i = 0;i<=7;i++){                                           // gets 8 samples of temperature
 samples[i] = ( 4.4 * analogRead(tempPin) * 100.0) / 1024.0;    // conversion math of LM35 sample to readable temperature and stores result to samples array. 

                                                                // 5v is the supply volts of LM35. Change appropriatelly to have correct measurement. My case is 4.4Volts.
                                                                // If powered from USB then use value 4.4v to 4.6v. If power is 7v< to the Arduino then use 4.9v to 5.1v                                                                
                                                                // The voltage is critical for accurate readings
 Serial.println(samples[i]);                                    // Print samples [i] to sertiual monitor                                            
                                                                                                                         
                                                                // ( LCD note: line 1 is the second row, since counting begins with 0):
 lcd.setCursor(0, 0);                                           // Set LCD cursor position (column 0, row 0)
 lcd.print("TODAYS TEMP IS: ");                                // Print text to LCD
 lcd.setCursor(5, 1);                                           // Set LCD cursor position (column 1, row 1)
 lcd.print("  C   ");                                     // Print text to LCD
 lcd.setCursor(1, 1);                                          // Set LCD cursor position (column 12, row 1)
 lcd.print(samples[i]);                                         // print current Temp sample to LCD
 tempC = tempC + samples[i];                                    // do the addition for average temperature
 delay(800);                                                    // wait 800ms

 }                                                              // END of FOR loop

 Serial.println("");                                            // Blank line for spacing in the serial monitor
 Serial.println("");                                            // Blank line for spacing in the serial monitor
 tempC = tempC/8.0;                                             // calculated the averare of 8 samples in Celcius

 tempf = (tempC * 9)/ 5 + 32;                                   // converts to fahrenheit

 if(tempC > maxi) {maxi = tempC;}                               // set max temperature
 if(tempC < mini) {mini = tempC;}                               // set min temperature

                                                                // Send Results to Serial Monitor
 Serial.println("New measurement:");
 Serial.print(" Average Temperature in Celcius is " );          // Print text to Serial monitor
 Serial.println(tempC);//send the data to the computer          // Send the data to the computer
 Serial.print(" Average Temperature in Farenait is " );         // Print text to Serial monitor
 Serial.println(tempf);//send the data to the computer          // Send the data to the computer
 Serial.print(" MAX Temperature in Celcius is " );              // Print text to Serial monitor
 Serial.println(maxi);//send the data to the computer           // Send the data to the computer
 Serial.print(" MIN Temperature in Celcius is " );              // Print text to Serial monitor
 Serial.println(mini);//send the data to the computer           // Send the data to the computer

                                                                // Send results to LCD.
 lcd.setCursor(6, 1);                                           // Set LCD cursor position (column 0, line 1)
 lcd.print(" F ");                                     // Print text to LCD
 lcd.setCursor(1, 1);                                          // Set LCD cursor position (column 12, line 1)
 lcd.print(tempf);                                              // Send the data to the LCD

 delay(5000);                                                   // Wait 3 seconds to display the Fahrenheit temp and 3 seconds to display results to LCD screen befor starting the loop again = 6 seconds.
 tempC = 0;                                                     // Set tempC to 0 so calculations can be done again
 lcd.clear(); code]

I suggest you start using the F() macro before you run out of RAM. eg.

Serial.println(F("New measurement:"));

I would like to put time and date inot this code, after the SALES line if possible?

Do you have a real-time clock?

Hmm no :-(, do you mean put a (F after every Serial.println

Sorry im new to this.

Hmm no :-(, do you mean put a (F after every Serial.println

No. The F() macro keeps the string literal from being copied from flash memory to SRAM.

Serial.print(F("This stays out of SRAM"));

Look at there the colored text is in the above state, to see where to put the F, ( and ) in your statements.

The Arduino has no idea what the date and time are. If you don't have an RTC, which does, or some other method of telling the Arduino what the date and time are, you can't add the date and time as part of your output.

Many of the Arduino family have 32K of flash memory and 2K of SRAM. The flash memory is like a thumb drive: it maintains the content of its memory even after power is removed. SRAM is volatile memory: it goes stupid when power is removed. You also have EEPROM memory which is non-volatile and a good place for storing configuration data.

Think of flash memory as program memory and SRAM as data memory. In most cases, you are more likely to run out of data space (SRAM) long before you run out of program space (flash). This is why creating large arrays is problematic on an Arduino.

One of the quirks of the Arduino compiler is that string literals, like you use with the Serial.print() object, end up being copied (i.e., duplicated) to SRAM by the compiler. This chews up the scarce SRAM faster than it should. The F() macro the other posters told you about prevents the compiler from duplicating the string literals into SRAM, which helps preserve your scarce SRAM resources.

Okay no time and date then.

Still not sure what you mean by the F.

coul you show me to different expamples please

Change:

Serial.println("New measurement:");

to:

Serial.println(F("New measurement:"));

I don't know how else to describe it.

Just for that line?, i thought you meant for all lines sorry.

If you only need to free up 17 or so bytes of RAM, yes, just that one line.

Sorted :-). thanks

englewood:
Just for that line?, i thought you meant for all lines sorry.

All lines with literals in them.

All Serial.print() and Serial.println() statements with literals, that is.

Agreed, this would look strange:

F(if(tempC > maxi) {maxi = tempC;});
F(if(tempC < mini) {mini = tempC;});

Hopefully my meaning was clear.