ทำโปรเจค เกี่ยวกับ Solenoid Valve

พูดคุยกันเรื่องบอร์ด Arduino, Solenoid Valve, blynk
เกี่ยวกับ Solenoid Valve ของ esp8266 ครับ ควบคุมการทำงานผ่าน blynk

ศึกษาตัวอย่างนี้ครับ

1 Likes

#include <I2S.h>

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID “xxxxx”

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include “DHT.h”
DHT dht;

char auth[] = “xxxxx”;
char ssid[] = “xxxxx”;
char pass[] = “xxxxx”;

const int relayEnable = D2;
const int sensorPin = A0;
const int tresholdMax = 1000;
const int tresholdMin = 10;

BLYNK_WRITE(V1)
{
if (param.asInt()==1) {
digitalWrite(relayEnable, HIGH);

}else{
digitalWrite(relayEnable, LOW);

}
}

void setup()
{
pinMode(relayEnable, OUTPUT);
pinMode(sensorPin, INPUT);
Serial.begin(115200);
Serial.println("Soil Moisture Level: ");
Blynk.begin(auth, ssid, pass);
Blynk.connect();
delay(1000);
}

void loop()
{
Blynk.run();
int sensorValue = analogRead(sensorPin);
sensorValue = map(sensorValue, tresholdMax, tresholdMin, 0, 100);
Serial.print(“Moisture: “);
Serial.print(sensorValue);
Serial.println(”%”);

if (sensorValue < 0)
{
digitalWrite(relayEnable, HIGH);
Serial.println(“Relay OFF”);
}
else
{
digitalWrite(relayEnable, LOW);
Serial.println(“Relay ON”);
}
delay(1000);
}

code ผมประมาณนี้อะครับ โปรเจคผม ป.ตรี ควบคุมSolenoid Valve 3ตัว ทำในย esp8266 ควบคุมผ่าน blynk แล้วควบคุมความชื้นไปด้วยครับ แล้วเปิดปิดเองได้ แล้วก็ตั้งเวลาได้ แต่ code ยังได้เท่านี้อยู่เลยครับ เป็นปัญหามาก