ทำถึงขั้นตอนอัพโหลดลงบอร์ด esp8266 อะไรเสร็จแต่ตรง App Blynk กลับยัง Offline ขอคำแนะนำหน่อยครับ
อันนี้คือ โค้ดที่ผมใช้ครับ
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "FrKt-tdZYmJRlS0adkiwA_H9u_S_atLu";
char ssid[] = "Loveyo";
char pass[] = "Aun612542";
#define Relay1 D0
#define Relay2 D1
#define Relay3 D2
void setup()
{
Serial.begin(9600);
//OUTPUT
Blynk.begin(auth, ssid, pass);
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(Relay3, OUTPUT);
Blynk.connect();
}
BLYNK_WRITE(V0)
{
if(param.asInt() == 1)
{
digitalWrite(Relay1, HIGH);
}
else
{
digitalWrite(Relay1, LOW);
}
}
BLYNK_WRITE(V1)
{
if(param.asInt() == 1)
{
digitalWrite(Relay2, HIGH);
}
else
{
digitalWrite(Relay2, LOW);
}
}
BLYNK_WRITE(V2)
{
if(param.asInt() == 1)
{
digitalWrite(Relay3, HIGH);
}
else
{
digitalWrite(Relay3, LOW);
}
}
BLYNK_WRITE(V3) {
switch (param.asInt())
{
case 1: // Item 1
Serial.println("Normal mode");
if(param.asInt() == 1)
{
digitalWrite(Relay1, HIGH);
digitalWrite(Relay2, HIGH);
digitalWrite(Relay3, HIGH);
}
else
{
digitalWrite(Relay1, LOW);
digitalWrite(Relay2, LOW);
digitalWrite(Relay3, LOW);
}
break;
case 2: // Item 2
Serial.println("Moonlight mode");
if(param.asInt() == 1)
{
digitalWrite(Relay1, HIGH);
}
else
{
digitalWrite(Relay1, LOW);
}
break;
case 3: // Item 3
Serial.println("CW mode");
if(param.asInt() == 1)
{
digitalWrite(Relay2, HIGH);
}
else
{
digitalWrite(Relay2, LOW);
}
break;
case 4: // Item 4
Serial.println("RGUV mode");
if(param.asInt() == 1)
{
digitalWrite(Relay3, HIGH);
}
else
{
digitalWrite(Relay3, LOW);
}
break;
case 5: // Item 5
Serial.println("CW&RGUV mode");
if(param.asInt() == 1)
{
digitalWrite(Relay2, HIGH);
digitalWrite(Relay3, HIGH);
}
else
{
digitalWrite(Relay2, LOW);
digitalWrite(Relay3, LOW);
}
break;
default:
Serial.println("OFF");
digitalWrite(Relay1, LOW);
digitalWrite(Relay2, LOW);
digitalWrite(Relay3, LOW);
}
}
void loop()
{
Blynk.run();
}
รบกวนด้วยครับผม