# data[].attributes.body
#define BLYNK_PRINT Serial

// 블링크 연동 정보 기재

//#define BLYNK_TEMPLATE_ID           "TMPxxxxxx"

//#define BLYNK_TEMPLATE_NAME         "Device"

//#define BLYNK_AUTH_TOKEN            "YourAuthToken"

#include <WiFi.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>

char ssid[] = "AndroidHotspot9058";

char pass[] = "78997899";

BlynkTimer timer;   //블링크 타이머함수 사용

// LED 작동

#define relayPin_L 18  //LED 릴레이핀

bool led_state;         //led_state 선언

BLYNK_WRITE(V0){                   // 블링크 V0 핀 상태 int로 가져오기

led_state = param.asInt();

}

void ledControl(){                      // 1일 때 on, 0일 때 off

if(led_state){

digitalWrite(relayPin_L, HIGH);

}

else{

digitalWrite(relayPin_L, LOW);

}

}

// fan 작동

#define relayPin_F 19   //GPIO 19번 핀에 fan 동작 릴레이

bool fan_state;          // fan_state 선언

BLYNK_WRITE(V4){            // 블링크 V4 핀 상태 int로 가져오기

fan_state = param.asInt();

}

void fanControl(){                // 1일 때 on, 0일 때 off

if(fan_state){

digitalWrite(relayPin_F, HIGH);

}

else{

digitalWrite(relayPin_F, LOW);

}

}

// 온습도 센서, 토양수분, LCD

#include <DHT.h>                    // 온습도 센서 라이브러리

#define DHTPin 25           //25번 핀에 연결

#define DHTTYPE DHT11      // 온습도 센서타입

DHT dht(DHTPin,DHTTYPE);   // 온습도 센서 함수 선언

#define soilPin 34   // 34번 핀에 토양수분센서

#define relayPin_P 23   // 23번 핀에 펌프 동작 릴레이

#include <Wire.h>                   // i2C 통신을 위한 라이브러리

#include <LiquidCrystal_I2C.h>      // LCD 1602 I2C용 라이브러리

LiquidCrystal_I2C lcd( 0x27, 16, 2); // 화면이 안나오면 0x27 -> 0x3F 로 변경

void sensorEvent(){

int tempValue = dht.readTemperature();   // 온도 측정값을 tempValue에 저장

int humValue = dht.readHumidity();       // 습도 측정값을 humValue에 저장

Blynk.virtualWrite(V1, tempValue);       // 온도 값을 블링크의 V1핀으로 전송

Blynk.virtualWrite(V2, humValue);        // 습도 값을 블링크의 V2번핀으로 전송

int soilValue = analogRead(soilPin);

int soilValue_p = map(soilValue, 950, 2600, 100, 0);  // 물티슈 등을 이용하여 최대 최소값 측정 후 변경

Serial.print("S : ");            // map 함수 값을 넣기 위해 측정값을 시리얼 모니터로 값 출력

Serial.print(soilValue);

Serial.print(" , S_P :    ");

Serial.println(soilValue_p);

Blynk.virtualWrite(V3, soilValue_p);   // 토양수분 백분율 블링크 V3번 핀으로 전송

if(soilValue_p < 40){             // 토양수분 % 측정 값에 따른 릴레이핀 동작(수중모터 동작)

digitalWrite(relayPin_P,HIGH);       // 40% 를 기준으로 사용

}

else if(soilValue_p >= 40){

digitalWrite(relayPin_P,LOW);

}

lcd.begin(); // 리셋(자리수 수정 함수 안넣기;; -> 간소화)

lcd.backlight();      // 백라이트 켜기

lcd.setCursor(0, 0);  // (X축 넘길 갯수, 라인번호) 첫 번째 칸, 첫 번째 줄에 표시

lcd.print("T : ");

lcd.print(tempValue);

lcd.print("C");

lcd.setCursor(8, 0);  // (1칸 띄고, 첫번째 라인)

lcd.print("H : ");

lcd.print(humValue);

lcd.print("%");

lcd.setCursor(2, 1);  // (2칸 띄고, 2번째 라인)

lcd.print("Soil_M : ");

lcd.print(soilValue_p);

lcd.setCursor(14, 1);  // (14칸 띄고, 2번째 라인)

lcd.print("%");

}

void setup()

{

Serial.begin(9600);

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

pinMode(relayPin_L, OUTPUT);        // LED 릴레이핀 output으로 설정

timer.setInterval(300L, ledControl);     //함수 호출하여 0.3초마다 LED 동작 버튼 체크

pinMode(relayPin_F, OUTPUT);        // Fan 릴레이핀 output으로 설정

timer.setInterval(300L, fanControl);  //함수 호출하여 0.3초마다 fan 동작 버튼 체크

pinMode(relayPin_P, OUTPUT);

timer.setInterval(1000L, sensorEvent);    // 1초마다 데이터 확인, 전송 및 동작

}

void loop()

{

Blynk.run();

timer.run();       //timer 사용

}

# data[].attributes.body
#define BLYNK_PRINT Serial

// 블링크 연동 정보 기재

//#define BLYNK_TEMPLATE_ID           "TMPxxxxxx"

//#define BLYNK_TEMPLATE_NAME         "Device"

//#define BLYNK_AUTH_TOKEN            "YourAuthToken"

#include <WiFi.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>

char ssid[] = "sunchip64";

char pass[] = "1234qwer";

BlynkTimer timer;   //블링크 타이머함수 사용

// LED 작동

#define relayPin_L 18  //LED 릴레이핀

bool led_state;         //led_state 선언

BLYNK_WRITE(V0){                   // 블링크 V0 핀 상태 int로 가져오기

led_state = param.asInt();

}

void ledControl(){                      // 1일 때 on, 0일 때 off

if(led_state){

digitalWrite(relayPin_L, HIGH);

}

else{

digitalWrite(relayPin_L, LOW);

}

}

// fan 작동

#define relayPin_F 19   //GPIO 19번 핀에 fan 동작 릴레이

bool fan_state;          // fan_state 선언

BLYNK_WRITE(V4){            // 블링크 V4 핀 상태 int로 가져오기

fan_state = param.asInt();

}

void fanControl(){                // 1일 때 on, 0일 때 off

if(fan_state){

digitalWrite(relayPin_F, HIGH);

}

else{

digitalWrite(relayPin_F, LOW);

}

}

// 온습도 센서, 토양수분, LCD

#include <DHT.h>                    // 온습도 센서 라이브러리

#define DHTPin 25           //25번 핀에 연결

#define DHTTYPE DHT11      // 온습도 센서타입

DHT dht(DHTPin,DHTTYPE);   // 온습도 센서 함수 선언

#define soilPin 34   // 34번 핀에 토양수분센서

#define relayPin_P 23   // 23번 핀에 펌프 동작 릴레이

#include <Wire.h>                   // i2C 통신을 위한 라이브러리

#include <LiquidCrystal_I2C.h>      // LCD 1602 I2C용 라이브러리

LiquidCrystal_I2C lcd( 0x27, 16, 2); // 화면이 안나오면 0x27 -> 0x3F 로 변경

void sensorEvent(){

int tempValue = dht.readTemperature();   // 온도 측정값을 tempValue에 저장

int humValue = dht.readHumidity();       // 습도 측정값을 humValue에 저장

Blynk.virtualWrite(V1, tempValue);       // 온도 값을 블링크의 V1핀으로 전송

Blynk.virtualWrite(V2, humValue);        // 습도 값을 블링크의 V2번핀으로 전송

int soilValue = analogRead(soilPin);

int soilValue_p = map(soilValue, 950, 2600, 100, 0);  // 물티슈 등을 이용하여 최대 최소값 측정 후 변경

Serial.print("S : ");            // map 함수 값을 넣기 위해 측정값을 시리얼 모니터로 값 출력

Serial.print(soilValue);

Serial.print(" , S_P :    ");

Serial.println(soilValue_p);

Blynk.virtualWrite(V3, soilValue_p);   // 토양수분 백분율 블링크 V3번 핀으로 전송

if(soilValue_p < 40){             // 토양수분 % 측정 값에 따른 릴레이핀 동작(수중모터 동작)

digitalWrite(relayPin_P,HIGH);       // 40% 를 기준으로 사용

}

else if(soilValue_p >= 40){

digitalWrite(relayPin_P,LOW);

}

lcd.begin(); // 리셋(자리수 수정 함수 안넣기;; -> 간소화)

lcd.backlight();      // 백라이트 켜기

lcd.setCursor(0, 0);  // (X축 넘길 갯수, 라인번호) 첫 번째 칸, 첫 번째 줄에 표시

lcd.print("T : ");

lcd.print(tempValue);

lcd.print("C");

lcd.setCursor(8, 0);  // (1칸 띄고, 첫번째 라인)

lcd.print("H : ");

lcd.print(humValue);

lcd.print("%");

lcd.setCursor(2, 1);  // (2칸 띄고, 2번째 라인)

lcd.print("Soil_M : ");

lcd.print(soilValue_p);

lcd.setCursor(14, 1);  // (14칸 띄고, 2번째 라인)

lcd.print("%");

}

void setup()

{

Serial.begin(9600);

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

pinMode(relayPin_L, OUTPUT);        // LED 릴레이핀 output으로 설정

timer.setInterval(300L, ledControl);     //함수 호출하여 0.3초마다 LED 동작 버튼 체크

pinMode(relayPin_F, OUTPUT);        // Fan 릴레이핀 output으로 설정

timer.setInterval(300L, fanControl);  //함수 호출하여 0.3초마다 fan 동작 버튼 체크

pinMode(relayPin_P, OUTPUT);

timer.setInterval(1000L, sensorEvent);    // 1초마다 데이터 확인, 전송 및 동작

}

void loop()

{

Blynk.run();

timer.run();       //timer 사용

}

# data[].attributes.body
#define BLYNK_PRINT Serial

// 블링크 연동 정보 기재
#define BLYNK_TEMPLATE_ID "TMPL6zNX06Foh"
#define BLYNK_TEMPLATE_NAME "0611"
#define BLYNK_AUTH_TOKEN "F5IQGALOEYCPEIpQ98_e5xoK1KtJnEAo"

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

char ssid[] = "Jun01";
char pass[] = "12345678";

BlynkTimer timer;   // 블링크 타이머 함수 사용

// LED 작동
#define relayPin_L 18
bool led_state;

BLYNK_WRITE(V0) {
  led_state = param.asInt();
}

unsigned long lastLedTriggerTime = 0;
bool ledRunning = false;

void ledControl() {
  unsigned long currentMillis = millis();

  if (led_state) {
    if (!ledRunning && (currentMillis - lastLedTriggerTime >= 30000)) {
      digitalWrite(relayPin_L, HIGH);
      ledRunning = true;
      lastLedTriggerTime = currentMillis;
    }

    if (ledRunning && (currentMillis - lastLedTriggerTime >= 10000)) {
      digitalWrite(relayPin_L, LOW);
      ledRunning = false;
    }
  } else {
    digitalWrite(relayPin_L, LOW);
    ledRunning = false;
    lastLedTriggerTime = millis();
  }
}

// FAN 작동
#define relayPin_F 19
bool fan_state;

BLYNK_WRITE(V4) {
  fan_state = param.asInt();
}

unsigned long lastFanTriggerTime = 0;
bool fanRunning = false;

void fanControl() {
  unsigned long currentMillis = millis();

  if (fan_state) {
    if (!fanRunning && (currentMillis - lastFanTriggerTime >= 30000)) {
      digitalWrite(relayPin_F, HIGH);
      fanRunning = true;
      lastFanTriggerTime = currentMillis;
    }

    if (fanRunning && (currentMillis - lastFanTriggerTime >= 10000)) {
      digitalWrite(relayPin_F, LOW);
      fanRunning = false;
    }
  } else {
    digitalWrite(relayPin_F, LOW);
    fanRunning = false;
    lastFanTriggerTime = millis();
  }
}

// 온습도 센서, 토양수분, LCD
#include <DHT.h>
#define DHTPin 25
#define DHTTYPE DHT11
DHT dht(DHTPin, DHTTYPE);

#define soilPin 34
#define relayPin_P 23

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C 주소 확인 필요 (0x27 or 0x3F)

void sensorEvent() {
  int tempValue = dht.readTemperature();
  int humValue = dht.readHumidity();
  Blynk.virtualWrite(V1, tempValue);
  Blynk.virtualWrite(V2, humValue);

  int soilValue = analogRead(soilPin);
  int soilValue_p = map(soilValue, 950, 2600, 100, 0);
  Serial.print("S : ");
  Serial.print(soilValue);
  Serial.print(" , S_P : ");
  Serial.println(soilValue_p);
  Blynk.virtualWrite(V3, soilValue_p);

  if (soilValue_p < 25) {
    digitalWrite(relayPin_P, HIGH);
  } else {
    digitalWrite(relayPin_P, LOW);
  }

  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("T : ");
  lcd.print(tempValue);
  lcd.print("C");
  lcd.setCursor(8, 0);
  lcd.print("H : ");
  lcd.print(humValue);
  lcd.print("%");
  lcd.setCursor(2, 1);
  lcd.print("Soil_M : ");
  lcd.print(soilValue_p);
  lcd.setCursor(14, 1);
  lcd.print("%");
}

void setup() {
  Serial.begin(9600);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

  pinMode(relayPin_L, OUTPUT);
  pinMode(relayPin_F, OUTPUT);
  pinMode(relayPin_P, OUTPUT);

  timer.setInterval(300L, ledControl);       // 0.3초마다 상태 체크
  timer.setInterval(300L, fanControl);
  timer.setInterval(1000L, sensorEvent);     // 1초마다 센서 읽기
}

void loop() {
  Blynk.run();
  timer.run();
}

# data[].attributes.body
#define BLYNK_PRINT Serial

// 블링크 연동 정보 기재
#define BLYNK_TEMPLATE_ID "TMPL6zNX06Foh"
#define BLYNK_TEMPLATE_NAME "0611"
#define BLYNK_AUTH_TOKEN "F5IQGALOEYCPEIpQ98_e5xoK1KtJnEAo"

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

char ssid[] = "sunchip64";
char pass[] = "1234qwer";

BlynkTimer timer;   // 블링크 타이머 함수 사용

// LED 작동
#define relayPin_L 18
bool led_state;

BLYNK_WRITE(V0) {
  led_state = param.asInt();
}

unsigned long lastLedTriggerTime = 0;
bool ledRunning = false;

void ledControl() {
  unsigned long currentMillis = millis();

  if (led_state) {
    if (!ledRunning && (currentMillis - lastLedTriggerTime >= 30000)) {
      digitalWrite(relayPin_L, HIGH);
      ledRunning = true;
      lastLedTriggerTime = currentMillis;
    }

    if (ledRunning && (currentMillis - lastLedTriggerTime >= 10000)) {
      digitalWrite(relayPin_L, LOW);
      ledRunning = false;
    }
  } else {
    digitalWrite(relayPin_L, LOW);
    ledRunning = false;
    lastLedTriggerTime = millis();
  }
}

// FAN 작동
#define relayPin_F 19
bool fan_state;

BLYNK_WRITE(V4) {
  fan_state = param.asInt();
}

unsigned long lastFanTriggerTime = 0;
bool fanRunning = false;

void fanControl() {
  unsigned long currentMillis = millis();

  if (fan_state) {
    if (!fanRunning && (currentMillis - lastFanTriggerTime >= 30000)) {
      digitalWrite(relayPin_F, HIGH);
      fanRunning = true;
      lastFanTriggerTime = currentMillis;
    }

    if (fanRunning && (currentMillis - lastFanTriggerTime >= 10000)) {
      digitalWrite(relayPin_F, LOW);
      fanRunning = false;
    }
  } else {
    digitalWrite(relayPin_F, LOW);
    fanRunning = false;
    lastFanTriggerTime = millis();
  }
}

// 온습도 센서, 토양수분, LCD
#include <DHT.h>
#define DHTPin 25
#define DHTTYPE DHT11
DHT dht(DHTPin, DHTTYPE);

#define soilPin 34
#define relayPin_P 23

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C 주소 확인 필요 (0x27 or 0x3F)

void sensorEvent() {
  int tempValue = dht.readTemperature();
  int humValue = dht.readHumidity();
  Blynk.virtualWrite(V1, tempValue);
  Blynk.virtualWrite(V2, humValue);

  int soilValue = analogRead(soilPin);
  int soilValue_p = map(soilValue, 950, 2600, 100, 0);
  Serial.print("S : ");
  Serial.print(soilValue);
  Serial.print(" , S_P : ");
  Serial.println(soilValue_p);
  Blynk.virtualWrite(V3, soilValue_p);

  if (soilValue_p < 25) {
    digitalWrite(relayPin_P, HIGH);
  } else {
    digitalWrite(relayPin_P, LOW);
  }

  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("T : ");
  lcd.print(tempValue);
  lcd.print("C");
  lcd.setCursor(8, 0);
  lcd.print("H : ");
  lcd.print(humValue);
  lcd.print("%");
  lcd.setCursor(2, 1);
  lcd.print("Soil_M : ");
  lcd.print(soilValue_p);
  lcd.setCursor(14, 1);
  lcd.print("%");
}

void setup() {
  Serial.begin(9600);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

  pinMode(relayPin_L, OUTPUT);
  pinMode(relayPin_F, OUTPUT);
  pinMode(relayPin_P, OUTPUT);

  timer.setInterval(300L, ledControl);       // 0.3초마다 상태 체크
  timer.setInterval(300L, fanControl);
  timer.setInterval(1000L, sensorEvent);     // 1초마다 센서 읽기
}

void loop() {
  Blynk.run();
  timer.run();
}

# data[].attributes.body
#define BLYNK_PRINT Serial

// 블링크 연동 정보 기재

#define BLYNK_TEMPLATE_ID "TMPL6zNX06Foh"

#define BLYNK_TEMPLATE_NAME "0611"

#define BLYNK_AUTH_TOKEN "F5IQGALOEYCPEIpQ98_e5xoK1KtJnEAo"

#include <WiFi.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>

char ssid[] = "Jun01";

char pass[] = "12345678";

BlynkTimer timer; // 블링크 타이머함수 사용

// LED 작동

#define relayPin_L 18

bool led_state;

BLYNK_WRITE(V0) {

led_state = param.asInt();

}

unsigned long lastLedTriggerTime = 0;

bool ledRunning = false;

void ledControl() {

unsigned long currentMillis = millis();

if (led_state) {

if (!ledRunning && (currentMillis - lastLedTriggerTime >= 1800000)) { // 30분마다

digitalWrite(relayPin_L, HIGH); // 1분간 켜기

ledRunning = true;

lastLedTriggerTime = currentMillis;

}

if (ledRunning && (currentMillis - lastLedTriggerTime >= 60000)) { // 1분 후 끄기

digitalWrite(relayPin_L, LOW);

ledRunning = false;

}

} else {

digitalWrite(relayPin_L, LOW);

ledRunning = false;

lastLedTriggerTime = millis(); // 초기화

}

}

// FAN 작동

#define relayPin_F 19

bool fan_state;

BLYNK_WRITE(V4) {

fan_state = param.asInt();

}

unsigned long lastFanTriggerTime = 0;

bool fanRunning = false;

void fanControl() {

unsigned long currentMillis = millis();

if (fan_state) {

if (!fanRunning && (currentMillis - lastFanTriggerTime >= 1800000)) { // 30분마다

digitalWrite(relayPin_F, HIGH); // 1분간 켜기

fanRunning = true;

lastFanTriggerTime = currentMillis;

}

if (fanRunning && (currentMillis - lastFanTriggerTime >= 60000)) { // 1분 후 끄기

digitalWrite(relayPin_F, LOW);

fanRunning = false;

}

} else {

digitalWrite(relayPin_F, LOW);

fanRunning = false;

lastFanTriggerTime = millis(); // 초기화

}

}

// 온습도 센서, 토양수분, LCD

#include <DHT.h>

#define DHTPin 25

#define DHTTYPE DHT11

DHT dht(DHTPin, DHTTYPE);

#define soilPin 34

#define relayPin_P 23

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C 주소 확인 필요 (0x27 또는 0x3F)

void sensorEvent() {

int tempValue = dht.readTemperature();

int humValue = dht.readHumidity();

Blynk.virtualWrite(V1, tempValue);

Blynk.virtualWrite(V2, humValue);

int soilValue = analogRead(soilPin);

int soilValue_p = map(soilValue, 950, 2600, 100, 0);

Serial.print("S : ");

Serial.print(soilValue);

Serial.print(" , S_P : ");

Serial.println(soilValue_p);

Blynk.virtualWrite(V3, soilValue_p);

if (soilValue_p < 25) {

digitalWrite(relayPin_P, HIGH);

} else {

digitalWrite(relayPin_P, LOW);

}

lcd.begin();

lcd.backlight();

lcd.setCursor(0, 0);

lcd.print("T : ");

lcd.print(tempValue);

lcd.print("C");

lcd.setCursor(8, 0);

lcd.print("H : ");

lcd.print(humValue);

lcd.print("%");

lcd.setCursor(2, 1);

lcd.print("Soil_M : ");

lcd.print(soilValue_p);

lcd.setCursor(14, 1);

lcd.print("%");

}

void setup() {

Serial.begin(9600);

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

pinMode(relayPin_L, OUTPUT);

pinMode(relayPin_F, OUTPUT);

pinMode(relayPin_P, OUTPUT);

timer.setInterval(300L, ledControl);

timer.setInterval(300L, fanControl);

timer.setInterval(1000L, sensorEvent);

}

void loop() {

Blynk.run();

timer.run();

}

# data[].attributes.body
#define BLYNK_PRINT Serial

// 블링크 연동 정보 기재

#define BLYNK_TEMPLATE_ID "TMPL6zNX06Foh"

#define BLYNK_TEMPLATE_NAME "0611"

#define BLYNK_AUTH_TOKEN "F5IQGALOEYCPEIpQ98_e5xoK1KtJnEAo"

#include <WiFi.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>

char ssid[] = "YEiPhone";

char pass[] = "12345678";

BlynkTimer timer; // 블링크 타이머함수 사용

// LED 작동

#define relayPin_L 18

bool led_state;

BLYNK_WRITE(V0) {

led_state = param.asInt();

}

unsigned long lastLedTriggerTime = 0;

bool ledRunning = false;

void ledControl() {

unsigned long currentMillis = millis();

if (led_state) {

if (!ledRunning && (currentMillis - lastLedTriggerTime >= 1800000)) { // 30분마다

digitalWrite(relayPin_L, HIGH); // 1분간 켜기

ledRunning = true;

lastLedTriggerTime = currentMillis;

}

if (ledRunning && (currentMillis - lastLedTriggerTime >= 60000)) { // 1분 후 끄기

digitalWrite(relayPin_L, LOW);

ledRunning = false;

}

} else {

digitalWrite(relayPin_L, LOW);

ledRunning = false;

lastLedTriggerTime = millis(); // 초기화

}

}

// FAN 작동

#define relayPin_F 19

bool fan_state;

BLYNK_WRITE(V4) {

fan_state = param.asInt();

}

unsigned long lastFanTriggerTime = 0;

bool fanRunning = false;

void fanControl() {

unsigned long currentMillis = millis();

if (fan_state) {

if (!fanRunning && (currentMillis - lastFanTriggerTime >= 1800000)) { // 30분마다

digitalWrite(relayPin_F, HIGH); // 1분간 켜기

fanRunning = true;

lastFanTriggerTime = currentMillis;

}

if (fanRunning && (currentMillis - lastFanTriggerTime >= 60000)) { // 1분 후 끄기

digitalWrite(relayPin_F, LOW);

fanRunning = false;

}

} else {

digitalWrite(relayPin_F, LOW);

fanRunning = false;

lastFanTriggerTime = millis(); // 초기화

}

}

// 온습도 센서, 토양수분, LCD

#include <DHT.h>

#define DHTPin 25

#define DHTTYPE DHT11

DHT dht(DHTPin, DHTTYPE);

#define soilPin 34

#define relayPin_P 23

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C 주소 확인 필요 (0x27 또는 0x3F)

void sensorEvent() {

int tempValue = dht.readTemperature();

int humValue = dht.readHumidity();

Blynk.virtualWrite(V1, tempValue);

Blynk.virtualWrite(V2, humValue);

int soilValue = analogRead(soilPin);

int soilValue_p = map(soilValue, 950, 2600, 100, 0);

Serial.print("S : ");

Serial.print(soilValue);

Serial.print(" , S_P : ");

Serial.println(soilValue_p);

Blynk.virtualWrite(V3, soilValue_p);

if (soilValue_p < 25) {

digitalWrite(relayPin_P, HIGH);

} else {

digitalWrite(relayPin_P, LOW);

}

lcd.begin();

lcd.backlight();

lcd.setCursor(0, 0);

lcd.print("T : ");

lcd.print(tempValue);

lcd.print("C");

lcd.setCursor(8, 0);

lcd.print("H : ");

lcd.print(humValue);

lcd.print("%");

lcd.setCursor(2, 1);

lcd.print("Soil_M : ");

lcd.print(soilValue_p);

lcd.setCursor(14, 1);

lcd.print("%");

}

void setup() {

Serial.begin(9600);

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

pinMode(relayPin_L, OUTPUT);

pinMode(relayPin_F, OUTPUT);

pinMode(relayPin_P, OUTPUT);

timer.setInterval(300L, ledControl);

timer.setInterval(300L, fanControl);

timer.setInterval(1000L, sensorEvent);

}

void loop() {

Blynk.run();

timer.run();

}

# data[].attributes.body
#define BLYNK_PRINT Serial

// 블링크 연동 정보 기재

#define BLYNK_TEMPLATE_ID "TMPL6zNX06Foh"

#define BLYNK_TEMPLATE_NAME "0611"

#define BLYNK_AUTH_TOKEN "F5IQGALOEYCPEIpQ98_e5xoK1KtJnEAo"

#include <WiFi.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>

char ssid[] = "sunchip64";

char pass[] = "1234qwer";

BlynkTimer timer; // 블링크 타이머함수 사용

// LED 작동

#define relayPin_L 18

bool led_state;

BLYNK_WRITE(V0) {

led_state = param.asInt();

}

unsigned long lastLedTriggerTime = 0;

bool ledRunning = false;

void ledControl() {

unsigned long currentMillis = millis();

if (led_state) {

if (!ledRunning && (currentMillis - lastLedTriggerTime >= 1800000)) { // 30분마다

digitalWrite(relayPin_L, HIGH); // 1분간 켜기

ledRunning = true;

lastLedTriggerTime = currentMillis;

}

if (ledRunning && (currentMillis - lastLedTriggerTime >= 60000)) { // 1분 후 끄기

digitalWrite(relayPin_L, LOW);

ledRunning = false;

}

} else {

digitalWrite(relayPin_L, LOW);

ledRunning = false;

lastLedTriggerTime = millis(); // 초기화

}

}

// FAN 작동

#define relayPin_F 19

bool fan_state;

BLYNK_WRITE(V4) {

fan_state = param.asInt();

}

unsigned long lastFanTriggerTime = 0;

bool fanRunning = false;

void fanControl() {

unsigned long currentMillis = millis();

if (fan_state) {

if (!fanRunning && (currentMillis - lastFanTriggerTime >= 1800000)) { // 30분마다

digitalWrite(relayPin_F, HIGH); // 1분간 켜기

fanRunning = true;

lastFanTriggerTime = currentMillis;

}

if (fanRunning && (currentMillis - lastFanTriggerTime >= 60000)) { // 1분 후 끄기

digitalWrite(relayPin_F, LOW);

fanRunning = false;

}

} else {

digitalWrite(relayPin_F, LOW);

fanRunning = false;

lastFanTriggerTime = millis(); // 초기화

}

}

// 온습도 센서, 토양수분, LCD

#include <DHT.h>

#define DHTPin 25

#define DHTTYPE DHT11

DHT dht(DHTPin, DHTTYPE);

#define soilPin 34

#define relayPin_P 23

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C 주소 확인 필요 (0x27 또는 0x3F)

void sensorEvent() {

int tempValue = dht.readTemperature();

int humValue = dht.readHumidity();

Blynk.virtualWrite(V1, tempValue);

Blynk.virtualWrite(V2, humValue);

int soilValue = analogRead(soilPin);

int soilValue_p = map(soilValue, 950, 2600, 100, 0);

Serial.print("S : ");

Serial.print(soilValue);

Serial.print(" , S_P : ");

Serial.println(soilValue_p);

Blynk.virtualWrite(V3, soilValue_p);

if (soilValue_p < 25) {

digitalWrite(relayPin_P, HIGH);

} else {

digitalWrite(relayPin_P, LOW);

}

lcd.begin();

lcd.backlight();

lcd.setCursor(0, 0);

lcd.print("T : ");

lcd.print(tempValue);

lcd.print("C");

lcd.setCursor(8, 0);

lcd.print("H : ");

lcd.print(humValue);

lcd.print("%");

lcd.setCursor(2, 1);

lcd.print("Soil_M : ");

lcd.print(soilValue_p);

lcd.setCursor(14, 1);

lcd.print("%");

}

void setup() {

Serial.begin(9600);

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

pinMode(relayPin_L, OUTPUT);

pinMode(relayPin_F, OUTPUT);

pinMode(relayPin_P, OUTPUT);

timer.setInterval(300L, ledControl);

timer.setInterval(300L, fanControl);

timer.setInterval(1000L, sensorEvent);

}

void loop() {

Blynk.run();

timer.run();

}

# data[].attributes.body
#define BLYNK_PRINT Serial

// 블링크 연동 정보 기재
#define BLYNK_TEMPLATE_ID "TMPL6zNX06Foh"
#define BLYNK_TEMPLATE_NAME "0611"
#define BLYNK_AUTH_TOKEN "F5IQGALOEYCPEIpQ98_e5xoK1KtJnEAo"

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

char ssid[] = "YEiPhone";
char pass[] = "12345678";

BlynkTimer timer;   // 블링크 타이머 함수 사용

// LED 작동
#define relayPin_L 18
bool led_state;

BLYNK_WRITE(V0) {
  led_state = param.asInt();
}

unsigned long lastLedTriggerTime = 0;
bool ledRunning = false;

void ledControl() {
  unsigned long currentMillis = millis();

  if (led_state) {
    if (!ledRunning && (currentMillis - lastLedTriggerTime >= 30000)) {
      digitalWrite(relayPin_L, HIGH);
      ledRunning = true;
      lastLedTriggerTime = currentMillis;
    }

    if (ledRunning && (currentMillis - lastLedTriggerTime >= 10000)) {
      digitalWrite(relayPin_L, LOW);
      ledRunning = false;
    }
  } else {
    digitalWrite(relayPin_L, LOW);
    ledRunning = false;
    lastLedTriggerTime = millis();
  }
}

// FAN 작동
#define relayPin_F 19
bool fan_state;

BLYNK_WRITE(V4) {
  fan_state = param.asInt();
}

unsigned long lastFanTriggerTime = 0;
bool fanRunning = false;

void fanControl() {
  unsigned long currentMillis = millis();

  if (fan_state) {
    if (!fanRunning && (currentMillis - lastFanTriggerTime >= 30000)) {
      digitalWrite(relayPin_F, HIGH);
      fanRunning = true;
      lastFanTriggerTime = currentMillis;
    }

    if (fanRunning && (currentMillis - lastFanTriggerTime >= 10000)) {
      digitalWrite(relayPin_F, LOW);
      fanRunning = false;
    }
  } else {
    digitalWrite(relayPin_F, LOW);
    fanRunning = false;
    lastFanTriggerTime = millis();
  }
}

// 온습도 센서, 토양수분, LCD
#include <DHT.h>
#define DHTPin 25
#define DHTTYPE DHT11
DHT dht(DHTPin, DHTTYPE);

#define soilPin 34
#define relayPin_P 23

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C 주소 확인 필요 (0x27 or 0x3F)

void sensorEvent() {
  int tempValue = dht.readTemperature();
  int humValue = dht.readHumidity();
  Blynk.virtualWrite(V1, tempValue);
  Blynk.virtualWrite(V2, humValue);

  int soilValue = analogRead(soilPin);
  int soilValue_p = map(soilValue, 950, 2600, 100, 0);
  Serial.print("S : ");
  Serial.print(soilValue);
  Serial.print(" , S_P : ");
  Serial.println(soilValue_p);
  Blynk.virtualWrite(V3, soilValue_p);

  if (soilValue_p < 25) {
    digitalWrite(relayPin_P, HIGH);
  } else {
    digitalWrite(relayPin_P, LOW);
  }

  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("T : ");
  lcd.print(tempValue);
  lcd.print("C");
  lcd.setCursor(8, 0);
  lcd.print("H : ");
  lcd.print(humValue);
  lcd.print("%");
  lcd.setCursor(2, 1);
  lcd.print("Soil_M : ");
  lcd.print(soilValue_p);
  lcd.setCursor(14, 1);
  lcd.print("%");
}

void setup() {
  Serial.begin(9600);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

  pinMode(relayPin_L, OUTPUT);
  pinMode(relayPin_F, OUTPUT);
  pinMode(relayPin_P, OUTPUT);

  timer.setInterval(300L, ledControl);       // 0.3초마다 상태 체크
  timer.setInterval(300L, fanControl);
  timer.setInterval(1000L, sensorEvent);     // 1초마다 센서 읽기
}

void loop() {
  Blynk.run();
  timer.run();
}

# data[].attributes.body
#define BLYNK_PRINT Serial

// 블링크 연동 정보 기재

#define BLYNK_TEMPLATE_ID "TMPL6RSpDMToA"

#define BLYNK_TEMPLATE_NAME "공주"

#define BLYNK_AUTH_TOKEN "VqKIUvo9JhRN0T4CImYCzB60lKSPpWAc"

#include <WiFi.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>

char ssid[] = "Jun01";

char pass[] = "12345678";

BlynkTimer timer;   //블링크 타이머함수 사용

// LED 작동

#define relayPin_L 18  //LED 릴레이핀

bool led_state;         //led_state 선언

BLYNK_WRITE(V0){                   // 블링크 V0 핀 상태 int로 가져오기

led_state = param.asInt();

}

void ledControl(){                      // 1일 때 on, 0일 때 off

if(led_state){

digitalWrite(relayPin_L, HIGH);

}

else{

digitalWrite(relayPin_L, LOW);

}

}

// fan 작동

#define relayPin_F 19   //GPIO 19번 핀에 fan 동작 릴레이

bool fan_state;          // fan_state 선언

BLYNK_WRITE(V4){            // 블링크 V4 핀 상태 int로 가져오기

fan_state = param.asInt();

}

void fanControl(){                // 1일 때 on, 0일 때 off

if(fan_state){

digitalWrite(relayPin_F, HIGH);

}

else{

digitalWrite(relayPin_F, LOW);

}

}

// 온습도 센서, 토양수분, LCD

#include <DHT.h>                    // 온습도 센서 라이브러리

#define DHTPin 25           //25번 핀에 연결

#define DHTTYPE DHT11      // 온습도 센서타입

DHT dht(DHTPin,DHTTYPE);   // 온습도 센서 함수 선언

#define soilPin 34   // 34번 핀에 토양수분센서

#define relayPin_P 23   // 23번 핀에 펌프 동작 릴레이

#include <Wire.h>                   // i2C 통신을 위한 라이브러리

#include <LiquidCrystal_I2C.h>      // LCD 1602 I2C용 라이브러리

LiquidCrystal_I2C lcd( 0x27, 16, 2); // 화면이 안나오면 0x27 -> 0x3F 로 변경

void sensorEvent(){

int tempValue = dht.readTemperature();   // 온도 측정값을 tempValue에 저장

int humValue = dht.readHumidity();       // 습도 측정값을 humValue에 저장

Blynk.virtualWrite(V1, tempValue);       // 온도 값을 블링크의 V1핀으로 전송

Blynk.virtualWrite(V2, humValue);        // 습도 값을 블링크의 V2번핀으로 전송

int soilValue = analogRead(soilPin);

int soilValue_p = map(soilValue, 950, 2600, 100, 0);  // 물티슈 등을 이용하여 최대 최소값 측정 후 변경

Serial.print("S : ");            // map 함수 값을 넣기 위해 측정값을 시리얼 모니터로 값 출력

Serial.print(soilValue);

Serial.print(" , S_P :    ");

Serial.println(soilValue_p);

Blynk.virtualWrite(V3, soilValue_p);   // 토양수분 백분율 블링크 V3번 핀으로 전송

if(soilValue_p < 40){             // 토양수분 % 측정 값에 따른 릴레이핀 동작(수중모터 동작)

digitalWrite(relayPin_P,HIGH);       // 40% 를 기준으로 사용

}

else if(soilValue_p >= 40){

digitalWrite(relayPin_P,LOW);

}

lcd.begin(); // 리셋(자리수 수정 함수 안넣기;; -> 간소화)

lcd.backlight();      // 백라이트 켜기

lcd.setCursor(0, 0);  // (X축 넘길 갯수, 라인번호) 첫 번째 칸, 첫 번째 줄에 표시

lcd.print("T : ");

lcd.print(tempValue);

lcd.print("C");

lcd.setCursor(8, 0);  // (1칸 띄고, 첫번째 라인)

lcd.print("H : ");

lcd.print(humValue);

lcd.print("%");

lcd.setCursor(2, 1);  // (2칸 띄고, 2번째 라인)

lcd.print("Soil_M : ");

lcd.print(soilValue_p);

lcd.setCursor(14, 1);  // (14칸 띄고, 2번째 라인)

lcd.print("%");

}

void setup()

{

Serial.begin(9600);

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

pinMode(relayPin_L, OUTPUT);        // LED 릴레이핀 output으로 설정

timer.setInterval(300L, ledControl);     //함수 호출하여 0.3초마다 LED 동작 버튼 체크

pinMode(relayPin_F, OUTPUT);        // Fan 릴레이핀 output으로 설정

timer.setInterval(300L, fanControl);  //함수 호출하여 0.3초마다 fan 동작 버튼 체크

pinMode(relayPin_P, OUTPUT);

timer.setInterval(1000L, sensorEvent);    // 1초마다 데이터 확인, 전송 및 동작

}

void loop()

{

Blynk.run();

timer.run();       //timer 사용

}

# data[].attributes.body
#define BLYNK_PRINT Serial

// 블링크 연동 정보 기재

//#define BLYNK_TEMPLATE_ID           "TMPxxxxxx"

//#define BLYNK_TEMPLATE_NAME         "Device"

//#define BLYNK_AUTH_TOKEN            "YourAuthToken"

#include <WiFi.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>

char ssid[] = "YEiPhone";

char pass[] = "12345678";

BlynkTimer timer;   //블링크 타이머함수 사용

// LED 작동

#define relayPin_L 18  //LED 릴레이핀

bool led_state;         //led_state 선언

BLYNK_WRITE(V0){                   // 블링크 V0 핀 상태 int로 가져오기

led_state = param.asInt();

}

void ledControl(){                      // 1일 때 on, 0일 때 off

if(led_state){

digitalWrite(relayPin_L, HIGH);

}

else{

digitalWrite(relayPin_L, LOW);

}

}

// fan 작동

#define relayPin_F 19   //GPIO 19번 핀에 fan 동작 릴레이

bool fan_state;          // fan_state 선언

BLYNK_WRITE(V4){            // 블링크 V4 핀 상태 int로 가져오기

fan_state = param.asInt();

}

void fanControl(){                // 1일 때 on, 0일 때 off

if(fan_state){

digitalWrite(relayPin_F, HIGH);

}

else{

digitalWrite(relayPin_F, LOW);

}

}

// 온습도 센서, 토양수분, LCD

#include <DHT.h>                    // 온습도 센서 라이브러리

#define DHTPin 25           //25번 핀에 연결

#define DHTTYPE DHT11      // 온습도 센서타입

DHT dht(DHTPin,DHTTYPE);   // 온습도 센서 함수 선언

#define soilPin 34   // 34번 핀에 토양수분센서

#define relayPin_P 23   // 23번 핀에 펌프 동작 릴레이

#include <Wire.h>                   // i2C 통신을 위한 라이브러리

#include <LiquidCrystal_I2C.h>      // LCD 1602 I2C용 라이브러리

LiquidCrystal_I2C lcd( 0x27, 16, 2); // 화면이 안나오면 0x27 -> 0x3F 로 변경

void sensorEvent(){

int tempValue = dht.readTemperature();   // 온도 측정값을 tempValue에 저장

int humValue = dht.readHumidity();       // 습도 측정값을 humValue에 저장

Blynk.virtualWrite(V1, tempValue);       // 온도 값을 블링크의 V1핀으로 전송

Blynk.virtualWrite(V2, humValue);        // 습도 값을 블링크의 V2번핀으로 전송

int soilValue = analogRead(soilPin);

int soilValue_p = map(soilValue, 950, 2600, 100, 0);  // 물티슈 등을 이용하여 최대 최소값 측정 후 변경

Serial.print("S : ");            // map 함수 값을 넣기 위해 측정값을 시리얼 모니터로 값 출력

Serial.print(soilValue);

Serial.print(" , S_P :    ");

Serial.println(soilValue_p);

Blynk.virtualWrite(V3, soilValue_p);   // 토양수분 백분율 블링크 V3번 핀으로 전송

if(soilValue_p < 40){             // 토양수분 % 측정 값에 따른 릴레이핀 동작(수중모터 동작)

digitalWrite(relayPin_P,HIGH);       // 40% 를 기준으로 사용

}

else if(soilValue_p >= 40){

digitalWrite(relayPin_P,LOW);

}

lcd.begin(); // 리셋(자리수 수정 함수 안넣기;; -> 간소화)

lcd.backlight();      // 백라이트 켜기

lcd.setCursor(0, 0);  // (X축 넘길 갯수, 라인번호) 첫 번째 칸, 첫 번째 줄에 표시

lcd.print("T : ");

lcd.print(tempValue);

lcd.print("C");

lcd.setCursor(8, 0);  // (1칸 띄고, 첫번째 라인)

lcd.print("H : ");

lcd.print(humValue);

lcd.print("%");

lcd.setCursor(2, 1);  // (2칸 띄고, 2번째 라인)

lcd.print("Soil_M : ");

lcd.print(soilValue_p);

lcd.setCursor(14, 1);  // (14칸 띄고, 2번째 라인)

lcd.print("%");

}

void setup()

{

Serial.begin(9600);

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

pinMode(relayPin_L, OUTPUT);        // LED 릴레이핀 output으로 설정

timer.setInterval(300L, ledControl);     //함수 호출하여 0.3초마다 LED 동작 버튼 체크

pinMode(relayPin_F, OUTPUT);        // Fan 릴레이핀 output으로 설정

timer.setInterval(300L, fanControl);  //함수 호출하여 0.3초마다 fan 동작 버튼 체크

pinMode(relayPin_P, OUTPUT);

timer.setInterval(1000L, sensorEvent);    // 1초마다 데이터 확인, 전송 및 동작

}

void loop()

{

Blynk.run();

timer.run();       //timer 사용

}

# data[].attributes.body
#define BLYNK_PRINT Serial

// 블링크 연동 정보 기재

//#define BLYNK_TEMPLATE_ID           "TMPxxxxxx"

//#define BLYNK_TEMPLATE_NAME         "Device"

//#define BLYNK_AUTH_TOKEN            "YourAuthToken"

#include <WiFi.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>

char ssid[] = "Jun01";

char pass[] = "12345678";

BlynkTimer timer;   //블링크 타이머함수 사용

// LED 작동

#define relayPin_L 18  //LED 릴레이핀

bool led_state;         //led_state 선언

BLYNK_WRITE(V0){                   // 블링크 V0 핀 상태 int로 가져오기

led_state = param.asInt();

}

void ledControl(){                      // 1일 때 on, 0일 때 off

if(led_state){

digitalWrite(relayPin_L, HIGH);

}

else{

digitalWrite(relayPin_L, LOW);

}

}

// fan 작동

#define relayPin_F 19   //GPIO 19번 핀에 fan 동작 릴레이

bool fan_state;          // fan_state 선언

BLYNK_WRITE(V4){            // 블링크 V4 핀 상태 int로 가져오기

fan_state = param.asInt();

}

void fanControl(){                // 1일 때 on, 0일 때 off

if(fan_state){

digitalWrite(relayPin_F, HIGH);

}

else{

digitalWrite(relayPin_F, LOW);

}

}

// 온습도 센서, 토양수분, LCD

#include <DHT.h>                    // 온습도 센서 라이브러리

#define DHTPin 25           //25번 핀에 연결

#define DHTTYPE DHT11      // 온습도 센서타입

DHT dht(DHTPin,DHTTYPE);   // 온습도 센서 함수 선언

#define soilPin 34   // 34번 핀에 토양수분센서

#define relayPin_P 23   // 23번 핀에 펌프 동작 릴레이

#include <Wire.h>                   // i2C 통신을 위한 라이브러리

#include <LiquidCrystal_I2C.h>      // LCD 1602 I2C용 라이브러리

LiquidCrystal_I2C lcd( 0x27, 16, 2); // 화면이 안나오면 0x27 -> 0x3F 로 변경

void sensorEvent(){

int tempValue = dht.readTemperature();   // 온도 측정값을 tempValue에 저장

int humValue = dht.readHumidity();       // 습도 측정값을 humValue에 저장

Blynk.virtualWrite(V1, tempValue);       // 온도 값을 블링크의 V1핀으로 전송

Blynk.virtualWrite(V2, humValue);        // 습도 값을 블링크의 V2번핀으로 전송

int soilValue = analogRead(soilPin);

int soilValue_p = map(soilValue, 950, 2600, 100, 0);  // 물티슈 등을 이용하여 최대 최소값 측정 후 변경

Serial.print("S : ");            // map 함수 값을 넣기 위해 측정값을 시리얼 모니터로 값 출력

Serial.print(soilValue);

Serial.print(" , S_P :    ");

Serial.println(soilValue_p);

Blynk.virtualWrite(V3, soilValue_p);   // 토양수분 백분율 블링크 V3번 핀으로 전송

if(soilValue_p < 40){             // 토양수분 % 측정 값에 따른 릴레이핀 동작(수중모터 동작)

digitalWrite(relayPin_P,HIGH);       // 40% 를 기준으로 사용

}

else if(soilValue_p >= 40){

digitalWrite(relayPin_P,LOW);

}

lcd.begin(); // 리셋(자리수 수정 함수 안넣기;; -> 간소화)

lcd.backlight();      // 백라이트 켜기

lcd.setCursor(0, 0);  // (X축 넘길 갯수, 라인번호) 첫 번째 칸, 첫 번째 줄에 표시

lcd.print("T : ");

lcd.print(tempValue);

lcd.print("C");

lcd.setCursor(8, 0);  // (1칸 띄고, 첫번째 라인)

lcd.print("H : ");

lcd.print(humValue);

lcd.print("%");

lcd.setCursor(2, 1);  // (2칸 띄고, 2번째 라인)

lcd.print("Soil_M : ");

lcd.print(soilValue_p);

lcd.setCursor(14, 1);  // (14칸 띄고, 2번째 라인)

lcd.print("%");

}

void setup()

{

Serial.begin(9600);

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

pinMode(relayPin_L, OUTPUT);        // LED 릴레이핀 output으로 설정

timer.setInterval(300L, ledControl);     //함수 호출하여 0.3초마다 LED 동작 버튼 체크

pinMode(relayPin_F, OUTPUT);        // Fan 릴레이핀 output으로 설정

timer.setInterval(300L, fanControl);  //함수 호출하여 0.3초마다 fan 동작 버튼 체크

pinMode(relayPin_P, OUTPUT);

timer.setInterval(1000L, sensorEvent);    // 1초마다 데이터 확인, 전송 및 동작

}

void loop()

{

Blynk.run();

timer.run();       //timer 사용

}