สวัสดีครับ แอดมิน
ผม compiled–> Uploaded code ลง ESP32 ไปแล้ว พอกด ปุ่ม Boot ค้าง 10 วิ บอร์ดไม่ reset wifi เลย เกิดจากอะไรครับ
- Aruino IDE version 2.3.2 → ลองอัพเดรต 2.3.4 ก็เหมือนเดิม
- บอร์ด ESP32 30 pin ข้างหลังมีสกรีนว่า ESP32S
- Driver พอร์ท พอร์ท CP210X ติดต่อบอร์ดได้ปกติ
- ฺBlynk version 1.3.2 ล่าสุด
- ลองไปหาดูใน กูเกิ้ล เคยมีกระทู้คำถามแบบนี้ถามเหมือนกัน และ แอดมิน Blynk ก็ตอบว่าอยู่ที่การเลือกบอร์ด ซื่งผมก็เลือกเกือบทุกบอร์ดแล้วก็ไม่สำเร็จ Troubleshooting Edgent Dynamic Provisioning Problems - FAQ - Blynk Community
ขอบคุณครับ
ปล ผมอาจจะตอบช้าเพราะไม่ได้อยู่หน้าจอบ่อย ขออภัยในความไม่สะดวก
#define BLYNK_TEMPLATE_ID "TMPL6c5exTxLz2"
#define BLYNK_TEMPLATE_NAME "Farm Sook2"
#define BLYNK_FIRMWARE_VERSION "0.1.0"
//File Edgent_ESP32_KITTI_2
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
//#define LED_BUILTIN 2
#define Relay 13
#define Pump 12
#define sensorInput 36
#define WaterLevel 14 //pin 14
// Uncomment your board, or configure a custom board in Settings.h
#define USE_ESP32_DEV_MODULE
//#define USE_ESP32C3_DEV_MODULE
//#define USE_ESP32S2_DEV_KIT
//#define USE_WROVER_BOARD
//#define USE_TTGO_T7
//#define USE_TTGO_T_OI
#include "BlynkEdgent.h"
int SoilValue ;
int MoisturePercent ;
byte MoistureSet ;
byte ForcePump ;
byte ForceRelay ;
byte PumpDelaytime = 0;
byte Schedule;
byte waterPumpDelay=0;
byte waterPumpDelay1=0;
const int LedSchedule = 5;
const int LedRelay = 18;
const int LedPump = 19;
const int LedLevel = 21;
WidgetLED led1(V2); // LED ของ ปั้ม
WidgetLED led2(V20);// LED ของ วาลว
WidgetLED led4(V19);// LED ของ Level
BlynkTimer timer;
BLYNK_CONNECTED() {
Blynk.syncAll();
}
BLYNK_WRITE(V1)
{// ค่าที่ตั้งจาก Slide bar ว่าต้องการความชื้นเท่าไร (ค่าควบคุมความชื้น)
MoistureSet = param.asInt();
}
BLYNK_WRITE(V5)
{ //รับค่ามาจากการกดรดน้ำแบบทันที
ForcePump = param.asInt();
}
BLYNK_WRITE(V7)
{ //รับค่ามาจากตารางรดน้ำประจำวัน
Schedule = param.asInt();
}
BLYNK_WRITE(V11)
{//รับค่า Delay Time จาก Blynk
PumpDelaytime = param.asInt();
}
// Blynk.syncAll();
void WaterPlant(){
SoilValue = analogRead(sensorInput);
MoisturePercent=map(SoilValue,1023,465,0,100);
Blynk.virtualWrite(V3, MoisturePercent);
Blynk.virtualWrite(V4, SoilValue);
Blynk.virtualWrite(V5, ForcePump);
Blynk.virtualWrite(V6, WaterLevel);
if(WaterLevel == 0)
{
digitalWrite(LedLevel, LOW);// LED ของ Schedule ดับ
led4.off(); //widget LED ของ Level ดับ
if( ForceRelay == 0)
{
waterPumpDelay=0;
if(Schedule == 1)//ถึงเวลาที่ตั้งค่า Schedule จะส่งค่ามาเป็น 1
{
digitalWrite(LedSchedule, HIGH);// LED ของ Schedule ติด
if(MoisturePercent >=MoistureSet)//ค่าความชื้นที่วัดได้มากกว่าค่าที่ตั้งบน แอบ จะไม่มีการทำงาน
{
digitalWrite(Pump, LOW);
digitalWrite(Relay, LOW);
led1.off();
led2.off();
waterPumpDelay1=0;
}else if(waterPumpDelay1==0)//ถ้าค่าความชื้นวัดได้ต่ำกว่าค่าที่ตั้ง Schedule และ pump จะทำงาน
{//ให้หน่วงเวลาก่อน
digitalWrite(Relay, HIGH);
led2.on();
WaterDelay();//หน่วงเวลา
digitalWrite(Pump,HIGH); //ปั้มทำงาน
led1.on();//ส่งค่าให้ LED ปั้มติด
waterPumpDelay1=1;// บันทึกว่ามีการหน่วงเวลวแล้ว
}else //ถ้ามาการเช็คว่าหน่วงเวลาแล้ว water pump Dalay =1 จะไม่มีการหน่วงใน loop นี้ เนื่องจาก blynk จะ ตรวจการทำงานใหม่ทุกครั้งไม่เหมือน arduino คือ จบ
{
digitalWrite(Relay, HIGH);
digitalWrite(Pump,HIGH);
led1.on();
led2.on();
waterPumpDelay1==0;
}
}else //กรณีไม่ถึงเวลาที่ตั้งไว้ Schedule = 0 ทุกอย่างจะถูก reset
{
digitalWrite(LedSchedule, LOW);// LED ของ Schedule ดับ
digitalWrite(Pump, LOW);
digitalWrite(Relay, LOW);
led1.off();
led2.off();
waterPumpDelay1==0;
}
}else if(ForceRelay == 1 && waterPumpDelay==0 ) // ถ้ามีการกดบังคับให้รดน้ำ ForceRelay =1
{
digitalWrite(Relay, HIGH);
led2.on();
WaterDelay();
digitalWrite(Pump,HIGH);
led1.on();
waterPumpDelay=1;
}else if(ForceRelay == 1 && waterPumpDelay==1 )
{
digitalWrite(Relay, HIGH);
led2.on();
digitalWrite(Pump,HIGH);
led1.on();
waterPumpDelay==1;
}
}else
{
digitalWrite(LedLevel, HIGH);//widget LED ของ Level ติด
led4.on(); //widget LED ของ Level ติด
}
}
void WaterDelay(){
long delay_time = PumpDelaytime*60000;
long start_millis = millis();
if (delay_time =0 ){
delay_time = 30000;
}
Serial.print("Starting ");
Serial.print(delay_time);
Serial.println(" milleseconds delay...");
delay(delay_time);
long duration = millis() - start_millis;
Serial.print("Delay completed - time taken = ");
Serial.print(duration);
if (duration < delay_time)
{
Serial.print(" <<<<< ERROR!!");
}
Serial.println();
Serial.println();
}
void setup()
{
Serial.begin(115200);
pinMode(Relay, OUTPUT);
pinMode(Pump, OUTPUT);
pinMode(WaterLevel,INPUT);
pinMode(LedSchedule , OUTPUT);
pinMode(LedRelay , OUTPUT);
pinMode(LedPump , OUTPUT);
BlynkEdgent.begin();
}
void loop(){
if (WiFi.status() == WL_CONNECTED)
{
BlynkEdgent.run();
}
timer.run(); // Initiates SimpleTimer
}