0% found this document useful (0 votes)
7 views4 pages

Smart Garden Blynk Automation Code

This document contains a program for a Smart Garden system using Blynk and various sensors. It includes code for temperature and humidity monitoring, soil moisture detection, and control of a water pump based on set points. The program is designed to operate in both automatic and manual modes, with real-time data displayed on an LCD and sent to the Blynk app.

Uploaded by

khoirulfatihi511
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Smart Garden Blynk Automation Code

This document contains a program for a Smart Garden system using Blynk and various sensors. It includes code for temperature and humidity monitoring, soil moisture detection, and control of a water pump based on set points. The program is designed to operate in both automatic and manual modes, with real-time data displayed on an LCD and sent to the Blynk app.

Uploaded by

khoirulfatihi511
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Kode Program

#disesuaikan dengan token blynk yang didapat


#define BLYNK_TEMPLATE_ID "TMPL3LtAqaDi"
#define BLYNK_DEVICE_NAME "Smart Garden"
#define BLYNK_AUTH_TOKEN "sCRrH5sFT8ycjwo2GlwLocmFc04mmmLS"
//================================//
#include <DallasTemperature.h>
#include <OneWire.h>
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#include <Blynk.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial
#define ONE_WIRE_BUS D5
#define DHTPIN D3
#define DHTTYPE DHT11
#define pump D6
DHT dht(DHTPIN, DHTTYPE);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int AirValue = 620;
const int WaterValue = 310;
int soilMoistureValue = 0;
int soilmoist=0;
int humi, temp,fp,sistem;
int buttonState;
#disesuaikan dengan nilai set point anda
int SP_LOW=30;
int SP_HIGH=50;
#diisi sesuai dengan token blynk anda
char auth[] = "sCRrH5sFT8ycjwo2GlwLocmFc04mmmLS";
#ganti dengan jaringan wifi atau hotspot anda
char ssid[] = "realme 5";
char pass[] = "iwang182";
//======================================
BLYNK_WRITE(V4){
buttonState = [Link]();
if(buttonState==HIGH){
sistem=1;//automatic
fp=0;
delay(10);
}
else if(buttonState==LOW){
sistem=0;//manual
delay(10);
}
}
//======================================
BLYNK_WRITE(V5){
buttonState = [Link]();
if(sistem==0){
if(buttonState==HIGH){
digitalWrite(pump,HIGH);
[Link](9,1);
[Link](" P= ON ");
delay(10);
}
else if(buttonState==LOW){
digitalWrite(pump,LOW);
[Link](9,1);
[Link](" P= OFF ");
delay(10);
}
}
}
//======================================
void setup(void)
{
[Link](16,2);
[Link]();
[Link]();
[Link]();
[Link](" Smart Garden ");
[Link](0, 1);
[Link](" NodeMCU ");
[Link](9600);
[Link]();
[Link]();
pinMode(pump,OUTPUT);
digitalWrite(pump,HIGH);
delay(1200);
digitalWrite(pump,LOW);
delay(1200);
[Link](auth, ssid, pass);
delay(1500);
[Link]();
[Link]("Mst= %, T= ");
[Link](0, 1);
[Link]("Hum= %, P= OFF");
}

void loop(void)
{
[Link]();
[Link]();
temp=[Link](0);
[Link]("Temp :");
[Link](temp);
[Link](12,0);
[Link](temp);
[Link]("C ");
soilMoistureValue = analogRead(A0);
soilmoist= map(soilMoistureValue, AirValue, WaterValue, 0, 100);
if(soilmoist >= 100)
{
soilmoist=100;
}
else if(soilmoist <=0)
{
soilmoist=0;
}

[Link]("Soil Moisture :");


[Link](soilmoist);
[Link]("%");
[Link](4,0);
[Link](soilmoist);
[Link]("% ");
humi = [Link]();

if (isnan(humi) ) {
[Link]("DHT11 tidak terbaca...!");
return;
}
else{
[Link]("Humi:");
[Link](humi);
[Link]();
[Link](4,1);
[Link](humi);
[Link]("% ");
}
//------control
if(sistem==1){
if((soilmoist<SP_LOW)&&(fp==0)){
digitalWrite(pump,HIGH);
[Link](13,1);
[Link]("ON ");
fp=1;
}
else if((soilmoist>SP_HIGH)&&(fp==1)){
digitalWrite(pump,LOW);
[Link](13,1);
[Link]("OFF");
fp=0;
}
}
[Link](V1, temp);
[Link](V2,soilmoist);
[Link](V3,humi);

[Link]("Sistem=");
[Link](sistem);
[Link]("fp=");
[Link](fp);

delay(1500);
}

You might also like