Useing delay unsted of RTC

Hi ,everyone i made a skecth useing a dth 11 and a HX711 I i don't want to use a rtc it's a little complicate for me . Iam thinking of useing delays in the void loop , i whant the arduino to send me 2 text a day in diferent hours. e,x . turn on arduino 1st text delay 28800000 (8 hours) 2nd text delay 57600000(16 hours) , is there a way not to right 2 times the code. thanks

An RTC is easy to use, accurate and they are about 3-4 dollars.

However, you can use millis() to time things.

BWD
Read this: Demonstration code for several things at the same time - Project Guidance - Arduino Forum

“is there a way not to right 2 times the code.”

What does this mean?

Do you want 8, 16, 24, 32 etc. hrs.

Hi larryd. the "is there a way not to right 2 times the code" i mean like the sketch below i wrote the same code in the loop. For the rtc i dont whant to use it .thanks

/////////////////////////////////////////////////////////////////
//          Arduino Sends SMS with Sensor Value       v1.01    //
//       Get the latest version of the code here:              //
//     http://educ8s.tv/arduino-sensor-values-via-sms/          //
/////////////////////////////////////////////////////////////////

#include "SIM900.h"
#include <SoftwareSerial.h>
#include <DHT.h>
#include "sms.h"

SMSGSM sms;
#define DHTPIN 7
#define DHTTYPE DHT22

boolean started = false;
char sms_text[160];

DHT dht(DHTPIN, DHTTYPE);

void setup()
{
  dht.begin();
  Serial.begin(9600);

  if (gsm.begin(9600))
  {
    Serial.println("\nstatus=READY");
    started = true;
  }
  else
    Serial.println("\nstatus=IDLE");
}





void loop()
{
  float humidity, temperature;
  String smsText = "";
  delay(2000);
  humidity = dht.readHumidity();
  temperature = dht.readTemperature();
  delay(2000);
  smsText = "Temperature: " + String(temperature, 1) + "C Humidity: " + String(humidity, 1) + "%";
  smsText.toCharArray(sms_text, 160);
  //Serial.println(smsText);
  sms.SendSMS("+306900000000", sms_text);


  Serial.println("TALKING. Line busy.");



  delay(28800000);


  
  float humidity, temperature;
  String smsText = "";
  delay(2000);
  humidity = dht.readHumidity();
  temperature = dht.readTemperature();
  delay(2000);
  smsText = "Temperature: " + String(temperature, 1) + "C Humidity: " + String(humidity, 1) + "%";
  smsText.toCharArray(sms_text, 160);
  //Serial.println(smsText);
  sms.SendSMS("+306900000000", sms_text);


  Serial.println("TALKING. Line busy.");
  delay(57600000);
}

Put the code that is repeated in a function and call that from loop() instead of having it twice in loop()

Hi UKHeliBob i am not good in arduino codes can you explane more easy or write an example code. thanks

A function is a group of commands that can be called from a program to perform an action or a series of actions. Functions are particularly useful when the same actions need to be performed at more than one place in the program as code does not have to be duplicated.

Rather than me explain functions to you I suggest that you read up on them on line. A basic tutorial on C programming will give you all the detail that you need.

o.k thanks i read the c programing

Function