Aldhi Adytia Prasetio 24776
Published

Monitoring and control garden via blynk

Sometimes I want to start farming, but often because of environmental problems, weather problems, temperature, or pests that make people not

BeginnerWork in progress341
Monitoring and control garden via blynk

Things used in this project

Hardware components

ESP32
Espressif ESP32
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Infrared Receiver, Remote Control
Infrared Receiver, Remote Control
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Buzzer
Buzzer
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Schematics

wiring diagram

Code

code arduino

C/C++
#define BLYNK_TEMPLATE_ID           "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME           "Device"
#define BLYNK_AUTH_TOKEN            "YourAuthToken"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


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

char auth[] = "input your token";
char ssid[] = " ";
char pass[] = " ";

#define DHTPIN 4          // What digital pin we're connected to
#define DHTTYPE DHT11     // DHT 11
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

#include <Servo.h>
Servo servo1;
Servo servo2;

WidgetLED led1(V4);
WidgetLED led2(V3);
int sensor1 = 14;
int sensor2 = 27;
int LEDpin = 22;
int RELAYpin = 23;


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;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);

}

void setup()
{
  // Debug console
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass, "blynk-cloud.com",8080);
dht.begin();
  pinMode(sensor2,INPUT);
  pinMode(sensor1,INPUT);
pinMode(LEDpin,OUTPUT);
pinMode(LEDpin, LOW);
pinMode(RELAYpin,OUTPUT);
pinMode(RELAYpin, LOW);
servo1.attach(13);// NodeMCU 13 pin
servo2.attach(12);// 12 pin

  while (Blynk.connect() == false) {
  }
  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

void loop() {
  Blynk.run();
  int sensorval1 = digitalRead(sensor1);
  int sensorval2 = digitalRead(sensor2);
  Serial.println(sensorval1);
  Serial.println(sensorval2);
  delay(1000);
  
    if (sensorval1 == 1)
    {
  led1.on();
  }
    if (sensorval2 == 1)
    {
  led2.on();
  }

    if (sensorval1 == 0)
    {
  led1.off();
  }
    if (sensorval2 == 0)
    {
  led2.off();
  }

  Blynk.run();
  timer.run();
}

BLYNK_WRITE(V1)
{
   servo1.write(param.asInt());
}

BLYNK_WRITE(V2)

{
   servo2.write(param.asInt());
}

Credits

Aldhi Adytia Prasetio 24776

Aldhi Adytia Prasetio 24776

4 projects • 1 follower

Comments

Add projectSign up / Login