Blynk ตั้งเวลารดน้ำต้นไม้ ใช้ delay 1นาที การเชื่อมต่อหลุด มีวิธีแก้ไขอย่างไรครับ

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


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "maintenance";
char pass[] = "[quote="yothin, post:1, topic:2592, full:true"]
![Screenshot_2019-12-20-15-42-08-25_980d3cd05c70b8deb691e1a04aeb6aca|236x500](upload://rDqLegOOREVIbjqbnWrQnebQfso.png)
[/quote]

`Preformatted text`744130";

#define DHTPIN 14          // What digital pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
#define DHTTYPE DHT21   // DHT 21, AM2301
WidgetLED led_1(V1);  //แสดงสถานะ Zone1 on/off
WidgetLED led_2(V2);  //แสดงสถานะ Zone2 on/off
WidgetLED led_3(V3); //แสดงสถานะ Zone3 on/off
WidgetLED led_4(V4);//แสดงสถานะ Zone4 on/off
WidgetLED led_5(V10);//แสดงสถานะ main pump on/off
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
 BLYNK_WRITE(V0)
{
  // You'll get HIGH/1 at startTime and LOW/0 at stopTime.
  // this method will be triggered every day
  // until you remove widget or stop project or
  // clean stop/start fields of widget
  Serial.print("Got a value: ");
  Serial.println(param.asInt());
  
  if(param.asInt() == 0)
  {
    digitalWrite(D4, HIGH);
    led_1.off();
    led_2.off();
    led_3.off();
    led_4.off();
     led_5.off();
  }
  if(param.asInt() == 1)
  {
    digitalWrite(D4, LOW);
   led_1.on();
   led_5.on();
   delay(60000);
   led_1.off();
    led_2.on();
    led_5.on();
    delay(60000);
    led_2.off();
    led_3.on();
    led_5.on();
    delay(60000);
    led_3.off();
    led_4.on();
    led_5.on();
    delay(6000);
    led_4.off();
    
  }
}



// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
int val = analogRead(A0);
  int s = map(val,0,1023,0,100);
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
  Blynk.virtualWrite(V7, s);
}

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

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  dht.begin();

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

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

หลุดแน่ๆ ครับแบบนี้

มันรอเชื่อมต่อนานเกินไป wifi มันจะหลุด

1 Likes

ต้องแบบไหนครับรบกวนด้วยครับ

ตรงนี้คือต้องการปรับค่าหน่วงเวลาได้หรอ

ครับว่าจะเอาไว้ปรับ ค่า delay ทุกโซนครับ

ตอนนี้ slider ยังไม่ได้ผูกโค้ตใช่ไหมครับ

ใช่ครับว่าจะเอามาปรับค่าดีเลย์ของทุกโซนครับ

รอตัวอย่างการใช้งาน timer นะครับ

ลองดู ตัวอย่างนี้เพิ่มเติมครับ

ขอบคุณ คุณ Permpol มากครับ คำตอบของคุณ อาจเป็นประโยชน์ กับงานของผม