/* Comment this out to disable prints and save space */ #define BLYNK_PRINT Serial #include #include #include // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "......ใส่โทเค้น......"; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = ",,,,,,,ชื่อไวไฟ,,,,,,,,,"; char pass[] = ".............รหัสไวไฟ.........."; #define D1 5 #define RL1 D1 #define DHTPIN 2 // Uncomment whatever type you're using! #define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321 //#define DHTTYPE DHT21 // DHT 21, AM2301 DHT dht(DHTPIN, DHTTYPE); BlynkTimer timer; // 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() { 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; } Blynk.virtualWrite(V5, h); Blynk.virtualWrite(V6, t); } // Keep this flag not to re-sync on every reconnection bool isFirstConnect = true; // This function will run every time Blynk connection is established BLYNK_CONNECTED() { if (isFirstConnect) // Request Blynk server to re-send latest values for all pins 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-cloud.com", 8442); //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442); pinMode(RL1,INPUT_PULLUP); dht.begin(); // Setup a function to be called every second timer.setInterval(1000L, sendSensor); } void loop() { Blynk.run(); timer.run(); }
ของผมไม่ผ่านครับ ขึ้นว่าBuild options changed, rebuilding all C:\Users\user\Documents\Arduino\esp8266001\esp8266001.ino:6:32: fatal error: BlynkSimpleEsp8266.h: No such file or directory #include ^ compilation terminated. exit status 1 Error compiling for board Generic ESP8266 Module.
ทำแจ้งเตือนผ่านไลน์ต้องใส่โค็ตตัวใหนเพิ่มครับ
ขอลิงค์ดาวโหลดโค๊ดหน่ยครับ
โค๊ดตัวอย่างนี้ copy ได้จากไหนครับ
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include
#include
#include
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "......ใส่โทเค้น......";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = ",,,,,,,ชื่อไวไฟ,,,,,,,,,";
char pass[] = ".............รหัสไวไฟ..........";
#define D1 5
#define RL1 D1
#define DHTPIN 2
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
// 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()
{
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;
}
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}
// Keep this flag not to re-sync on every reconnection
bool isFirstConnect = true;
// This function will run every time Blynk connection is established
BLYNK_CONNECTED() {
if (isFirstConnect)
// Request Blynk server to re-send latest values for all pins
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-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
pinMode(RL1,INPUT_PULLUP);
dht.begin();
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}
ของผมไม่ผ่านครับ
ขึ้นว่าBuild options changed, rebuilding all
C:\Users\user\Documents\Arduino\esp8266001\esp8266001.ino:6:32: fatal error: BlynkSimpleEsp8266.h: No such file or directory
#include
^
compilation terminated.
exit status 1
Error compiling for board Generic ESP8266 Module.
ถ้าไม่ได้ แอดไลน์มานะ audiais