ตั้งเงือนไข การตรวจสอบอุหภูมิ และความชื่น เพื่อสั่งรีเลย์ทำงานอัตโนมัติ

รบกวนท่าน สมาชิก ผู้รู้ช่วยหน่อยครับ คือผมอยากเขียนเงื่อนไขการทำงานอัตโมมัติ เช่น
1.ตั้งอุหภูมิไว้ที่ 30 จากปุ่มสไลด์ แล้วอุหภููมิเกินกว่าค่ากำหนด ก็ให้รีเลย์พัดลมน้ำทำงาน
2.ปุ่มสไลด์ความชื่น ถ้าตั้งค่าไว้ที่ ไม่ต่ำกว่า 70% เมื่อค่าที่เซนเซ่อวันได้ออกมาต่ำกว่า ก็สั่งให้รีเลย์ปั้มน้ำทำงาน
3.ในขณะที่รีเลย์ทำงานอัตโนมัติ ก็อยากให้สามารถกดปุ่มปิดการทำงานได้ด้วย

คร่าวๆประมาณนี้ครับ รบกวนผู้รู้แนะนำเพิ่มเติมได้

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Social networks:            http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  This example runs directly on NodeMCU.

  Note: This requires ESP8266 support package:
    https://github.com/esp8266/Arduino

  Please be sure to select the right NodeMCU module
  in the Tools -> Board menu!

  For advanced settings please follow ESP examples :
   - ESP8266_Standalone_Manual_IP.ino
   - ESP8266_Standalone_SmartConfig.ino
   - ESP8266_Standalone_SSL.ino

  Change WiFi ssid, pass, and Blynk auth token to run :)
  Feel free to apply it to any other example. It's simple!
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleDHT.h>
#include <SimpleTimer.h>

// DHT Config
int pinDHT22 = D5;
SimpleDHT22 dht22;

// SET Timer
SimpleTimer timer;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "BK4sCmrEbVrLSEChjvVSSuHma_RMK50G";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Cinternet_7777_2.4GHz";
char pass[] = "68807054";

BLYNK_CONNECTED() {
    Blynk.syncAll();
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  //Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  Blynk.begin(auth, ssid, pass, "blynk.iot-cm.com", 8080);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
  timer.setInterval(4000L, sendTemp);
}

void sendTemp()
{
  float temperature = 0;
  float humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht22.read2(pinDHT22, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("Read DHT22 failed, err="); Serial.println(err);delay(2000);
    return;
  }  
  Blynk.virtualWrite(10, temperature); // virtual pin 
  Blynk.virtualWrite(11, humidity); // virtual pin 
}

void loop()
{
  Blynk.run();
  timer.run();
}

เบื้องต้นอ่านกระทู้นี้ครับ