โดยทำงานผ่านปุ่มblynk บ้างไหมครับ
เงื่อนไขการทำงาน รบกวนช่วยเขียนโค๊ดเป็นแนวทางด้วยนะครับ พึ่งหัดทำครับ
ทำอะไรไปแล้วบ้างครับ วางโค้ตให้ดูหน่อย
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); //Module IIC/I2C Interface บางรุ่นอาจจะใช้ 0x3f
int dustPin = A0; // dust sensor - Wemos A0 pin
int ledPin = D6;
int i=1;
float voltsMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
#define D7 13 // manual
#define FAN D7
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// library ส่ง line ฝีมือคนไทย
// https://github.com/TridentTD/TridentTD_LineNotify
#include <TridentTD_LineNotify.h>
// กำหนด line token
#define LINE_TOKEN "OW5BQLiT9F7yWqs5HDEhJrBjAQh6OVEZ6V7DcGRFx97"
// กำหนด Blynk Config
char auth[] = "12cdb921954f4dd2ba390c09cfe6aeae";
char ssid[] = "iPhone";
char pass[] = "0813901147";
BLYNK_WRITE(V1) // manual
{
if (param.asInt()==1) { // เมื่อ V1 มีค่าเป็น 1
digitalWrite(D7, HIGH); //Relay1 on
int pinValue = param.asInt();
if (pinValue == 1){
Serial.println(pinValue);
LINE.notifySticker("เครื่องฟอกอากาศ PM 2.5 ทำงาน ^^ ", 1, 407);
}
}else{
digitalWrite(D7, LOW); //Relay 1 off
int pinValue = param.asInt();
if (pinValue == 0){
Serial.println(pinValue);
LINE.notifySticker("เครื่องฟอกอากาศ PM 2.5 หยุดทำงาน ^^ ", 1, 408);
}
}
}
BLYNK_WRITE(V2) // Auto Mode
{
if (dustDensity < 200) {
digitalWrite(D7, HIGH); //Relay1 on
int pinValue = param.asInt();
if (pinValue == 1){
Serial.println(pinValue);
LINE.notifySticker("คุณภาพอากาศอันตรายมีผลต่อสุขภาพ ควรป้องกัน", 1, 418);
}
}
}
void setup()
{
Serial.begin(57600);
pinMode(ledPin,OUTPUT);
lcd.begin();
lcd.backlight(); // เปิด backlight
pinMode(FAN,OUTPUT); // setup output
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass,"blynk.jpnet.co.th",8080);
LINE.setToken(LINE_TOKEN);
}
void loop() {
digitalWrite(ledPin,LOW); // power on the LED
delayMicroseconds(280);
voltsMeasured = analogRead(dustPin); // read the dust value
delayMicroseconds(40);
digitalWrite(ledPin,HIGH); // turn the LED off
delayMicroseconds(9680);
//measure your 5v and change below
calcVoltage = voltsMeasured * (3.3 / 1024.0);
dustDensity = 0.17 * calcVoltage - 0.1;
Serial.print("Raw Signal Value (0-1023): ");
Serial.print(voltsMeasured);
Serial.print(" - Voltage: ");
Serial.print(calcVoltage);
Serial.print(" - Dust Density: ");
Serial.println(dustDensity);
if (dustDensity <= 0.00) {
dustDensity == 0.00;
}
dustDensity = dustDensity * 1000;
Serial.print(" - Dust Density: ");
Serial.print(dustDensity);
Serial.println(" µg/m³");
lcd.home();
lcd.setCursor(1, 0);
lcd.print("Dust Density ");
lcd.setCursor(2, 1);
lcd.print(dustDensity);
lcd.print(" ug/m3 ");
delay(1000);
{
Blynk.run();
}
}
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); //Module IIC/I2C Interface บางรุ่นอาจจะใช้ 0x3f
int dustPin = A0; // dust sensor - Wemos A0 pin
int ledPin = D6;
int i=1;
float voltsMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
#define D7 13 // manual
#define FAN D7
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// library ส่ง line ฝีมือคนไทย
// https://github.com/TridentTD/TridentTD_LineNotify
#include <TridentTD_LineNotify.h>
// กำหนด line token
#define LINE_TOKEN “OW5BQLiT9F7yWqs5HDEhJrBjAQh6OVEZ6V7DcGRFx97”
// กำหนด Blynk Config
char auth[] = “12cdb921954f4dd2ba390c09cfe6aeae”;
char ssid[] = “iPhone”;
char pass[] = “0813901147”;
BLYNK_WRITE(V1) // manual
{
if (param.asInt()==1) { // เมื่อ V1 มีค่าเป็น 1
Copy
digitalWrite(D7, HIGH); //Relay1 on
int pinValue = param.asInt();
if (pinValue == 1){
Serial.println(pinValue);
LINE.notifySticker("เครื่องฟอกอากาศ PM 2.5 ทำงาน ^^ ", 1, 407);
}
}else{
Copy
digitalWrite(D7, LOW); //Relay 1 off
int pinValue = param.asInt();
if (pinValue == 0){
Serial.println(pinValue);
LINE.notifySticker("เครื่องฟอกอากาศ PM 2.5 หยุดทำงาน ^^ ", 1, 408);
}
}
}
Preformatted text
BLYNK_WRITE(V2) // Auto Mode
{
if (dustDensity < 200) {
digitalWrite(D7, HIGH); //Relay1 on
int pinValue = param.asInt();
if (pinValue == 1){
Serial.println(pinValue);
LINE.notifySticker(“คุณภาพอากาศอันตรายมีผลต่อสุขภาพ ควรป้องกัน”, 1, 418);
}
}
}
type or paste code here
void setup()
{
Serial.begin(57600);
pinMode(ledPin,OUTPUT);
lcd.begin();
lcd.backlight(); // เปิด backlight
pinMode(FAN,OUTPUT); // setup output
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass,“blynk.jpnet.co.th”,8080);
LINE.setToken(LINE_TOKEN);
}
void loop() {
digitalWrite(ledPin,LOW); // power on the LED
delayMicroseconds(280);
voltsMeasured = analogRead(dustPin); // read the dust value
delayMicroseconds(40);
digitalWrite(ledPin,HIGH); // turn the LED off
delayMicroseconds(9680);
//measure your 5v and change below
calcVoltage = voltsMeasured * (3.3 / 1024.0);
dustDensity = 0.17 * calcVoltage - 0.1;
Serial.print("Raw Signal Value (0-1023): ");
Serial.print(voltsMeasured);
Serial.print(" - Voltage: ");
Serial.print(calcVoltage);
Serial.print(" - Dust Density: ");
Serial.println(dustDensity);
if (dustDensity <= 0.00) {
dustDensity == 0.00;
}
dustDensity = dustDensity * 1000;
Serial.print(" - Dust Density: “);
Serial.print(dustDensity);
Serial.println(” µg/m³");
lcd.home();
lcd.setCursor(1, 0);
lcd.print("Dust Density “);
lcd.setCursor(2, 1);
lcd.print(dustDensity);
lcd.print(” ug/m3 ");
delay(1000);
{
Blynk.run();
}
}
ผมพึ่งลองหัดทำดูครับยังไงขอคำชี้แนะด้วยนะครับ
สิ่งที่อยากทำ กดปุ่ม Auto ON เซ็นวัดค่าปริมาณ ถ้ามีค่าฝุ่นมากกว่า 200 เครื่องทำงาน แจ้งเตือนผ่านไลน์ ถ้าน้อยกว่า 50 เครื่องจะหยุดทำงาน แจ้งเตือนผ่านไลน์ ครับ ประมาณนี้ แต่อยากได้ ตามตารางที่ทดลอง
แก้เป็นไฮไลหน่อยครับมันดูยาก