Greenuino - Smart Gardening Using Arduino and Blynk App

by abdulrahman_rijabo in Circuits > Arduino

460 Views, 3 Favorites, 0 Comments

Greenuino - Smart Gardening Using Arduino and Blynk App

INTRO.jpg

INTRODUCTION

Lets start with what is greenuino. its an IOT project to help you monitor your plants condition when you are not around them. i love plants i have couple of plant in my balcony but the problem is i travel alot and no one to take care of my plant when i'm not around, so i decided to make greenuino which i will show you how to make it in the next steps.

Who can benefits from this project ?

A) people who loves plant and have some in their house or workstation whit no one to take care of it when they are not around.

B) people who wants to start indoor gardening as you ill see i have made options to control light and fan for cooling the temperature.

in the next step i will show you the list of materials you will need for this project.


Supplies

1653945737473.jpg
1653945737481.jpg
1653945737488.jpg
m1.png
m2.jpg
m3.jpg
m4.png
m5.png
m6.jpg
m7.jpg
m8.jpg
arduino.png

materials you will need for this project is:

1) Arduino mega or Arduino uno.

2) ESP8266 chip.

3) L298N motor Driver.

4) DC 12V water pump (in the link similar to what i use)

5) moisture sensor

6) jumper cables

7) 12V power supply

8) Breadboard (optional)

9) cell phone with the Blynk app installed on it

You will need the tools below in case you want to add led and fan to your project

1) UV Light

2) 12V Fan

3) Relay (i used the relay to control the led)

Connecting the Hardware Together

esparduino.jpg
2.jpg
3.jpg
4.jpg
5.jpg

1) connecting Arduino with the ESP8266 Chip


ESP8266 PINS Arduino Uno/mega

GND ---------------------------- GND

GP2 ----------------------------- Not connected

GP0 ----------------------------- GND

RXD ---------------------------- TX

TXD ---------------------------- RX

CHPD ------------------------- 3.3V

RST ---------------------------- Not connected

VCC ---------------------------- 3.3V

2) Connecting Moisture sensor to the arduino


Moisture sensor Arduino

GND ---------------------------- GND

DATA --------------------------- A0

VCC ---------------------------- 5V

3) Connect the L298N motor driver to arduino


L298N Arduino

GND -------------------------- GND

DATA ------------------------- A0

VCC -------------------------- 5V

B1Out ------------------------ 4;

B2Out ------------------------ 5;

A1Out ------------------------ 6;

A2Out ------------------------ 7;

APWM ------------------------ 8;

BPWM ------------------------ 9;

The fan and the water pump are both 12V and connected to the L298N

my power supply adapter the 12V 2A is enough to run the arduino, led, fan and water pump

4) connecting the relay to the arduino

Relay Arduino

GND -------------------------- GND

DATA ------------------------- 13

VCC -------------------------- 5V

Led should be connected to the NO terminal and ground in the relay

5) connecting the DHT11 temperature sensor to arduino

DHT11 Arduino

GND -------------------------- GND

DATA ------------------------- A3

VCC -------------------------- 5V

Blynk App and How to Set Everything in It

b1.png
b2.png
b3.png
b4.png
b5.png
b6.png
b7.png

what is Blynk?


Blynk is a software company that provides infrastructure for the internet of Things. In 2014 Blynk pioneered the no-code approach to IoT app building and gained global popularity for its mobile app editor. Today businesses of all sizes — from new startups to large enterprises.

Click here to visit the blynk website

1) you need to sign up and create an account it will ask your to write your email after that they will sent you an email to create a password.

2) it will ask you to choose your hardware so choose arduino and the connection type wifi.

3) you choose arduino IDE after that it will ask you to go download the BLYNK library follow the instruction in the site.

4) write your wifi and password and copy the code past it to ardunio upload it and click next.

5) from the could menu on the left Click on template then click on make a new template give a name and choose the hardware and type of connection.

6) you should recive to important code line that we are gonna use in the arduino code those are

#define BLYNK_TEMPLATE_ID "TMPhpLNlXu5g"

#define BLYNK_DEVICE_NAME "greenuinoo"

7) click on the search icon from the menu on the left side and click on new device then chose the template we created and give the device a name then click create. after that you will get similar to this three code lines

#define BLYNK_TEMPLATE_ID "TMPLdu5g"

#define BLYNK_DEVICE_NAME "greensnoo"

#define BLYNK_AUTH_TOKEN "YG5WN1mOfBsddfaSVP_BGGMFoBTCUHhY"

copy them and paste it in the arduino ide



Make Our Web and Mobile Dashboard in BLYNK

b10.jpg
b9.png
1655776169223.jpg

there are two ways to control our system eather by WEB or APP

To create the web dashboard

go to template and choose the template we created then click edit

from the widget box drag drop 3 slide from the control section and 3 gauge from the Display section.

we will control the fan, led and water pump and we will display the sensor value in the gauges.

Hover over any widget and click on the setting icon you will see that each widget has a datastream you will need to write this in the arduino code and will be explained later.


To create the mobile dashboard


Open Blynk.App

Log In to your account

Switch to Developer Mode ( at the top)

Find a template you just created on the web and tap on it.

do the same as we did in the web dashboard.




Uploading the Arduino Code

after we are done with the blynk dashboard its time to upload our arduino code.

make sure to install few libraries from the arduino ide go to Tools then choose manage library and search for

DHT11

ESP8266

Blynk

copy the code below or download the ino file


//BLYNK library codes copy yours and past it here

#define BLYNK_TEMPLATE_ID          "TMPLohG14Lnr"

#define BLYNK_DEVICE_NAME          "greenuino"

#define BLYNK_AUTH_TOKEN           "8vQSBcd39zYOEFdf1q5I0uWUcsHfw_9P"

#define BLYNK_PRINT Serial

char auth[] = BLYNK_AUTH_TOKEN;

//ESP library

#include <ESP8266_Lib.h>

#include <BlynkSimpleShieldEsp8266.h>

//write your wifi name and password

char ssid[] = "TurkTelekom_ZR99K";

char pass[] = "aAa7fD0A64aE9";

// Hardware Serial

#define EspSerial Serial1

// Your ESP8266 baud rate:

#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

//DHT library code and define pen 3 as our data pin

#include <DHT.h>

#define DHTTYPE DHT11

#define DHTPIN 3

DHT dht(DHTPIN, DHTTYPE);

BlynkTimer timer;

BlynkTimer timer2;

//motor driver pins defining

const int IN1 = 7;

const int IN2 = 6;

const int IN3 = 5;

const int IN4 = 4;

const int ENA = 8;

const int ENB = 9;

int pumpaspeed = 100;

//DHT reading from our DHT sensor

void sendSensor()

{

 int h = dht.readHumidity();

 int t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

 if (isnan(h) || isnan(t)) {

   Serial.println("Failed to read from DHT sensor!");

   return;

 }

 // set your temp and humidity gauge datastream to V3 and V2 and your will get the data on your display.

 Blynk.virtualWrite(V3, t);

 Blynk.virtualWrite(V2, h);

 }

 //reading from moisture sensor and sending to display

void sendSensor2()

{

  int tn = analogRead(A0);

  tn = map(tn, 0, 1023, 100, 0);

 // set your moisture datastream value in the app to V1 to get the data to display.

 Blynk.virtualWrite(V1, tn);

 }

//pressing the fan bottun from our API will turn the fan on or off

 BLYNK_WRITE(V4)

{

 int fan = param.asInt();

 if (fan ==1)

 {

 //analogWrite(ENA, 255);

 //analogWrite(ENB, 255);

 digitalWrite(IN1, HIGH);

 digitalWrite(IN2, LOW);

 analogWrite(ENA, speeed);

 Serial.println(fan);

   }

   else

   {

Serial.println(fan);

 digitalWrite(IN1, LOW);

 digitalWrite(IN2, LOW);

 analogWrite(ENA, speeed);

   }

   }

//pressing the water pump bottun from our API will turn the ater pump on or of

BLYNK_WRITE(V5)

{

 int pumpa  = param.asInt();

   Serial.print(pumpa);

 if (pumpa=1)

 {

 digitalWrite(IN3, LOW);

 digitalWrite(IN4, HIGH );

 analogWrite(ENB,pumpaspeed);

 //delay(3000);

   }

   else

   {

     digitalWrite(IN3, HIGH);

 digitalWrite(IN4,HIGH);

 analogWrite(ENB,pumpaspeed);

   }

   }

   //pressing the led bottun from our API will turn the led on or of

BLYNK_WRITE(V6)

{

 int relay = 11;

 pinMode(relay, OUTPUT);

 int ld = param.asInt();

 if (ld==1)

 {

   digitalWrite(relay, HIGH);  // turn the LED on (HIGH is the voltage level)

 Serial.print("Led is on ");

}

   else

   {

     digitalWrite(relay, LOW);  // turn the LED on (HIGH is the voltage level)

  Serial.print("Led is off ");

 }// assigning incoming value from pin V1 to a variable

   }

void setup()

{

 // Debug console

 Serial.begin(115200);

 pinMode (IN1, OUTPUT);

 pinMode (IN2, OUTPUT);

 pinMode (IN3, OUTPUT);

 pinMode (IN4, OUTPUT);

 pinMode (ENA, OUTPUT);

 pinMode (ENB, OUTPUT);

 // Set ESP8266 baud rate

 EspSerial.begin(ESP8266_BAUD);

 delay(10);

//blynk baglamasi

 Blynk.begin(auth, wifi, ssid, pass);

//DHT baslamasi

 dht.begin();

 // her saniye sensorden apiye bilgi gonderejek funksiyonu

 timer.setInterval(1000L, sendSensor);

 timer2.setInterval(1000L, sendSensor2);

}

void loop()

{

 Blynk.run();

 timer.run();

 timer2.run();

}

Downloads

Testing and Final Word

Testing Greenuino the smart garden project

we are done i hope this was eay for you. in the video i was testing the system to see that everything is working fine as you see.

hopefully i managed to explain everything in details and there ara no confussion however feel free to contact me for help and i will be more than happy to help you make this awesome project. thanks and i hope to see people click that "I made it" button.