สอบถามเกี่ยวกับ การโปรแกรม ESP8266 ครับ

(ขอโทษนะครับพอดีเป็นมือใหม่หัดเล่น) พอดีว่าผมอยากให้ ESP ของผมส่งไลน์ ทุกๆ 6 ชั่วโมงครับซึ่งผมก็เขียนโค้ดไว้แล้ว ใช้งานได้ แต่ผมอยากให้โค้ดมันสั้นกว่านี้ พอจะทำได้ไหมครับ ? พี่ๆช่วยชี้แนวทางหน่อยครับ

โค้ด..........
//-----------------------------------------------------------------------------------------------------------------------------------------
#include "DHT.h"
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <time.h>


#define LINE_TOKEN "3Pe7Jt1EedF6PvVyl932fVlkT0klFKJKOgvIisLFBOE"
char tempF[6];


String message3;
String message4;
String message5;

#define DHTPIN D6     
#define DHTTYPE DHT22   
DHT dht(DHTPIN, DHTTYPE);

const char* ssid     = "whitezone";
const char* password = "whitezone";
int timezone = 7 * 3600;                    //ตั้งค่า TimeZone ตามเวลาประเทศไทย
int dst = 0;                                //กำหนดค่า Date Swing Time

WiFiClient client;

void setup() {

  configTime(timezone, dst, "pool.ntp.org", "time.nist.gov");     //ดึงเวลาจาก Server
   Serial.println("\nWaiting for time");
    while (!time(nullptr)) {
     Serial.print(".");
     delay(1000);
    }
   
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  Serial.println("DHTxx test!");

   WiFi.begin(ssid, password);

  //???????????? WIfi
  //???????????? WIFI_AP, WIFI_STA, WIFI_AP_STA or WIFI_OFF
  WiFi.mode(WIFI_STA);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
//  ThingSpeak.begin(client);

  dht.begin();
}

void Line_Notify(String message) {
WiFiClientSecure client;

if (!client.connect("notify-api.line.me", 443)) {
Serial.println("connection failed");
return;
}

String req = "";
req += "POST /api/notify HTTP/1.1\r\n";
req += "Host: notify-api.line.me\r\n";
req += "Authorization: Bearer " + String(LINE_TOKEN) + "\r\n";
req += "Cache-Control: no-cache\r\n";
req += "User-Agent: ESP8266\r\n";
req += "Content-Type: application/x-www-form-urlencoded\r\n";
req += "Content-Length: " + String(String("message=" + message).length()) + "\r\n";
req += "\r\n";
req += "message=" + message;
Serial.println(req);
client.print(req);
delay(10);

Serial.println("-------------");
while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
break;
}
Serial.println(line);
}
Serial.println("-------------");
}   
void LCD(){
  }
void loop() {
  delay(1000);
  configTime(timezone, dst, "pool.ntp.org", "time.nist.gov");    //ดีงเวลาปัจจุบันจาก Server อีกครั้ง
  time_t now = time(nullptr);
  struct tm* p_tm = localtime(&now);
  Serial.println(ctime(&now));
  //---------------------------------------------ส่งเข้า DB ------------------------------------------------------------------
if(p_tm->tm_min == 0 && p_tm->tm_sec == 15)
  {
   float t = NAN; float h = NAN;  
   while( isnan(t) || isnan(h) ) {
     t = dht.readTemperature();
     h = dht.readHumidity();
   }
  message3 = dtostrf(t, 6, 2, tempF);
  message5 = dtostrf(h, 6, 2, tempF);
  
   HTTPClient http;
  http.begin("http://192.168.2.60/Temp/insert.php");// ??? IP ??????????????? ??? ?????????????? Insert.php (??????????????????????????)
  http.addHeader("Content-Type", "application/x-www-form-urlencoded");
  int httpCode = http.POST("temp="+ message3 +"&humidity=" + message5);
  Serial.println(httpCode);
if(httpCode == HTTP_CODE_OK)
{
Serial.println("Insert to database success !!!");
}
else
{
   Serial.println("Error in HTTP request");
}
http.end();
}
  //--------------------------------------------------- ส่งไลน์ ------------------------------------------------------------------------------------
else if (p_tm->tm_hour == 0 && p_tm->tm_min == 1 && p_tm->tm_sec == 30){
  
    float t = NAN; float h = NAN;  
    while( isnan(t) || isnan(h) ) {
      t = dht.readTemperature();
      h = dht.readHumidity();
   }
  message3 = dtostrf(t, 6, 2, tempF);
  message5 = dtostrf(h, 6, 2, tempF);
message4 ="%E0%B8%A3%E0%B8%B0%E0%B8%9A%E0%B8%9A%E0%B9%81%E0%B8%88%E0%B9%89%E0%B8%87%E0%B9%80%E0%B8%95%E0%B8%B7%E0%B8%AD%E0%B8%99%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%8A%E0%B8%B7%E0%B9%89%E0%B8%99%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%AD%E0%B8%B8%E0%B8%93%E0%B8%AB%E0%B8%A0%E0%B8%B9%E0%B8%A1%E0%B8%B4%E0%B8%A0%E0%B8%B2%E0%B8%A2%E0%B9%83%E0%B8%99%E0%B8%AB%E0%B9%89%E0%B8%AD%E0%B8%87%20Soft%20Switch%20%E0%B8%81%E0%B8%B3%E0%B8%A5%E0%B8%B1%E0%B8%87%E0%B8%97%E0%B8%B3%E0%B8%87%E0%B8%B2%E0%B8%99%20%3A\n"
"--%3E%20%E0%B8%AD%E0%B8%B8%E0%B8%93%E0%B8%AB%E0%B8%A0%E0%B8%B9%E0%B8%A1%E0%B8%B4%3A "+ message3 + "\t%C2%B0C\n"     //?????????????????????  
"--%3E%20%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%8A%E0%B8%B7%E0%B9%89%E0%B8%99%3A"+ message5 + "\t%25" ;      //?????????????????????
    Line_Notify(message4);
}
//------------------ ส่งไลน์ ------------------
else if (p_tm->tm_hour == 6 && p_tm->tm_min == 1 && p_tm->tm_sec == 30){
  
    float t = NAN; float h = NAN;  
    while( isnan(t) || isnan(h) ) {
      t = dht.readTemperature();
      h = dht.readHumidity();
   }
  message3 = dtostrf(t, 6, 2, tempF);
  message5 = dtostrf(h, 6, 2, tempF);
message4 ="%E0%B8%A3%E0%B8%B0%E0%B8%9A%E0%B8%9A%E0%B9%81%E0%B8%88%E0%B9%89%E0%B8%87%E0%B9%80%E0%B8%95%E0%B8%B7%E0%B8%AD%E0%B8%99%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%8A%E0%B8%B7%E0%B9%89%E0%B8%99%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%AD%E0%B8%B8%E0%B8%93%E0%B8%AB%E0%B8%A0%E0%B8%B9%E0%B8%A1%E0%B8%B4%E0%B8%A0%E0%B8%B2%E0%B8%A2%E0%B9%83%E0%B8%99%E0%B8%AB%E0%B9%89%E0%B8%AD%E0%B8%87%20Soft%20Switch%20%E0%B8%81%E0%B8%B3%E0%B8%A5%E0%B8%B1%E0%B8%87%E0%B8%97%E0%B8%B3%E0%B8%87%E0%B8%B2%E0%B8%99%20%3A\n"
"--%3E%20%E0%B8%AD%E0%B8%B8%E0%B8%93%E0%B8%AB%E0%B8%A0%E0%B8%B9%E0%B8%A1%E0%B8%B4%3A "+ message3 + "\t%C2%B0C\n"     //?????????????????????  
"--%3E%20%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%8A%E0%B8%B7%E0%B9%89%E0%B8%99%3A"+ message5 + "\t%25" ;      //?????????????????????
    Line_Notify(message4);
}
//---------------------- ส่งไลน์----------------------
    else if (p_tm->tm_hour == 12 && p_tm->tm_min == 1 && p_tm->tm_sec == 30){
  
    float t = NAN; float h = NAN;  
    while( isnan(t) || isnan(h) ) {
      t = dht.readTemperature();
      h = dht.readHumidity();
   }
  message3 = dtostrf(t, 6, 2, tempF);
  message5 = dtostrf(h, 6, 2, tempF);
message4 ="%E0%B8%A3%E0%B8%B0%E0%B8%9A%E0%B8%9A%E0%B9%81%E0%B8%88%E0%B9%89%E0%B8%87%E0%B9%80%E0%B8%95%E0%B8%B7%E0%B8%AD%E0%B8%99%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%8A%E0%B8%B7%E0%B9%89%E0%B8%99%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%AD%E0%B8%B8%E0%B8%93%E0%B8%AB%E0%B8%A0%E0%B8%B9%E0%B8%A1%E0%B8%B4%E0%B8%A0%E0%B8%B2%E0%B8%A2%E0%B9%83%E0%B8%99%E0%B8%AB%E0%B9%89%E0%B8%AD%E0%B8%87%20Soft%20Switch%20%E0%B8%81%E0%B8%B3%E0%B8%A5%E0%B8%B1%E0%B8%87%E0%B8%97%E0%B8%B3%E0%B8%87%E0%B8%B2%E0%B8%99%20%3A\n"
"--%3E%20%E0%B8%AD%E0%B8%B8%E0%B8%93%E0%B8%AB%E0%B8%A0%E0%B8%B9%E0%B8%A1%E0%B8%B4%3A "+ message3 + "\t%C2%B0C\n"     //?????????????????????  
"--%3E%20%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%8A%E0%B8%B7%E0%B9%89%E0%B8%99%3A"+ message5 + "\t%25" ;      //?????????????????????
    Line_Notify(message4);
    }
//------------------------- ส่งไลน์--------------------
    else if (p_tm->tm_hour == 18 && p_tm->tm_min == 1 && p_tm->tm_sec == 30){
  
    float t = NAN; float h = NAN;  
    while( isnan(t) || isnan(h) ) {
      t = dht.readTemperature();
      h = dht.readHumidity();
   }
  message3 = dtostrf(t, 6, 2, tempF);
  message5 = dtostrf(h, 6, 2, tempF);
message4 ="%E0%B8%A3%E0%B8%B0%E0%B8%9A%E0%B8%9A%E0%B9%81%E0%B8%88%E0%B9%89%E0%B8%87%E0%B9%80%E0%B8%95%E0%B8%B7%E0%B8%AD%E0%B8%99%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%8A%E0%B8%B7%E0%B9%89%E0%B8%99%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%AD%E0%B8%B8%E0%B8%93%E0%B8%AB%E0%B8%A0%E0%B8%B9%E0%B8%A1%E0%B8%B4%E0%B8%A0%E0%B8%B2%E0%B8%A2%E0%B9%83%E0%B8%99%E0%B8%AB%E0%B9%89%E0%B8%AD%E0%B8%87%20Soft%20Switch%20%E0%B8%81%E0%B8%B3%E0%B8%A5%E0%B8%B1%E0%B8%87%E0%B8%97%E0%B8%B3%E0%B8%87%E0%B8%B2%E0%B8%99%20%3A\n"
"--%3E%20%E0%B8%AD%E0%B8%B8%E0%B8%93%E0%B8%AB%E0%B8%A0%E0%B8%B9%E0%B8%A1%E0%B8%B4%3A "+ message3 + "\t%C2%B0C\n"     //?????????????????????  
"--%3E%20%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%8A%E0%B8%B7%E0%B9%89%E0%B8%99%3A"+ message5 + "\t%25" ;      //?????????????????????
    Line_Notify(message4);
}
}
//--------------------------------------------------------------------------------------------------------------------------------------------
แก้ไขข้อความเมื่อ
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่