Project tutorial

Arduino Indoor Garden © Apache-2.0

In this project, I will make an indoor gardening system to take care of my sweet plant and its beautiful flowers.

  • 10,958 views
  • 6 comments
  • 33 respects

Components and supplies

About this project

Gardening in the modern age means making things more complicated and arduous, with electrons, bits, and bytes. Combining microcontrollers and gardening is a really popular idea. I think that’s because gardens have very simple inputs and outputs that are easy to wrap your head around. I guess people (myself included) see a notoriously simple and relaxed hobby and can’t help but feel compelled to overcomplicate it.

In this project I will show you how to build a simpler version of indoor garden using an Arduino dev board.

I’m providing a full step-by-step guidance to show you how to make your own beautiful garden, and I'm explaining in details both hardware and software parts in order to turn this guidance the simplest way that leads you to try your own skills in electronic making. This project is so handy to make specially after getting the customized PCB that we’ve ordered from JLCPCB to improve the appearance of our car and also there is enough documents and codes in this guide to allow you create your automatic garden system.

We've made this project in just 7 days only, just three days to finish the hardware making and the assemble, then 4 days to prepare the code and the android app. in order to control the garden through it. Before starting let’s see first

What you will learn from this tutorial :

  • Choosing the right components depending on your project functionalities
  • Making the circuit to connect all the choosen components
  • Assemble all the project parts and start testing
  • Using the Android app. to connect through Bluetooth and start manipulating the system

Step 1: What Is an Indoor Garden!

Most plants have simple needs. As guests go, they're relatively undemanding. There are only three basic things you need to understand before you decide to invite a plant home: light, water and air. If you can master these four elements, from a plant's perspective, you can create an indoor garden just about anywhere in the world and during any season of the year.

  • Light - Most garden plants need at least six hours of light a day. But it has to be good light. If you put your hand in front of the window and it doesn't cast a shadow, chances are the light isn't adequate for most plants to live a happy life. However, you can always supplement low light conditions with grow lights.If you have modest natural light in your home and don't want to fuss with special lighting, stick to plants that normally need low-light conditions, or try moving your garden to a sunny windowsill.
  • Water - Plants need conditions close to those in their native habitats. A plant that calls the desert home will need less frequent watering than a plant that lives in a bog. Knowing what water conditions a plant prefers is a good first step to keeping a successful indoor garden. It's easier than you think because the plants themselves will often give you clues. Plants with thick rubbery leaves are water hoarders and can typically survive with less water than plants with thin, delicate leaves. If you hate to water your plants, choose varieties that can thrive on less, or pick plant-pots with hidden reservoirs to cut down on your watering chores.
  • Air - As a byproduct of photosynthesis, plants produce oxygen and filter nasty gasses, like formaldehyde, from your home environment via their leaves. To keep plants healthy, you need to keep their leaves clean and keep the air around them moving and moist. To do this, you can place them in a spot with good air flow or provide them with a small fan.

I will make an Arduino based system to supervise the temperature and humidity status of my plant and automatically provide its necessary needs like light intensity, water, and pure fresh air and in order to do this I need some sensors to control some actuators. For example I will control the light intensity depending on the signals received from the light brightness sensor the same for watering I used a moister sensor to turn on and off a water pump and temperature/humidity sensor for on and off controlling of a 12V DC fans.

Step 2: Sensors and Actuators

Making this system is the Assembling of some sensors and actuators in order to access the physical data arround the plant and to be able to find which thing is requested by the plant and when should you supply it.

This is the reason why you should use some sensors and actuators all connected to one Arduino board:

Sensors

  • Light sensor BH1750 : BH1750FVI Is a Digital Light sensor , which is an digital Ambient Light Sensor IC for I2C bus interface. This IC is the most suitable to obtain the ambient light data for adjusting LCD and Keypad backlight power of Mobile phone. It is possible to detect wide range at High resolution.( 1 - 65535 lx ).
  • Soil moisture sensor : Moisture sensors that measure the resistance or conductivity across the soil matrix between two contacts are essentially junk. First of all, resistance is not a very good indicator of moisture content, because it is highly dependent on a number of factors which might vary from garden to garden including soil ph, dissolved solids in the water, and temperature. Second, most of them are of poor quality with contacts that easily corrode. For the most part you'd be lucky to get one to last through an entire season.
  • Temperature & Humidity sensor : The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed). Its fairly simple to use, but requires careful timing to grab data. The only real downside of this sensor is you can only get new data from it once every 2 seconds, so when using our library, sensor readings can be up to 2 seconds old.

Actuators

  • Light white LED : A light-emitting diode (LED) is a two-lead semiconductor light source. It is a p–n junction diode that emits light when activated.[5] When a suitable voltage is applied to the leads, electrons are able to recombine with electron holes within the device, releasing energy in the form of photons.
  • Water pump : A pump is a device that moves fluids (liquids or gases), or sometimes slurries, by mechanical action. Pumps can be classified into three major groups according to the method they use to move the fluid: direct lift, displacement, and gravity pumps.Pumps operate by some mechanism (typically reciprocating or rotary), and consume energy to perform mechanical work by moving the fluid. Pumps operate via many energy sources, including manual operation, electricity, engines, or wind power, come in many sizes, from microscopic for use in medical applications to large industrial pumps.
  • DC 12V cooling fan : It is important to understand cooling techniques that can be used to preserve the life of your plant by moving fresh air arround the plant when it is required to keep the plant in a healthy conditions.

Step 3: The PCB Making (Produced by JLCPCB)

About JLCPCB

JLCPCB(Shenzhen JIALICHUANG Electronic Technology Development Co., Ltd.), is the largest PCB prototype enterprise in China and a high-tech manufacturer specializing in quick PCB prototype and small-batch PCB production.

With over 10 years of experience in PCB manufacturing, JLCPCBhas more than 200,000 customers at home and abroad, with over 8,000 online orders of PCB prototyping and small quantity PCB production per day. The annual production capacity is 200,000 sq.m. for various of 1-layer, 2-layer or multi-layer PCBs. JLC is a professional PCB manufacturer featured of large scale, well equipment, strict management and superior quality.

Back to our project

In order to produce the PCB, I have compared the price from many PCB producers and I chose JLCPCB the best PCB suppliers and the cheapest PCB providers to order this circuit. All what I need to do is some simple clicks to upload the gerber file and set some parameters like the PCB thickness color and quantity, then I’ve paid just 2 Dollars to get my PCB after 3 days only and I’ve noticed that there is some free shipping offers from time to time in this online ordering platform.

You can get the Circuit (PDF) file from here.

As you can see in the pictures above the PCB is very well manufactured and I’ve got the same PCB leaf shape that we’ve designed and all the labels and logos are there to guide me during the soldering steps.

Step 4: Ingredients

Now let’s review the necessary components for this project and you can find all the related links for an online ordering so we will need:

  • - The PCB that we've order it from JLCPCB

Step 5: The Assemble

Show All 9 Items

We are ready now so let’s start soldering the components and don’t forget to follow the labels to avoid soldering mistakes. We start by soldering Arduino connector to test the power supply and you can also write some basic test code to verify the right connection for each sensor like the Light sensor and its the same for the LEDs because they are all connected directly to the board (Arduino) so you have a full acces to them.

Note: You need to keep your soldering iron nice and clean. That means wiping it on the sponge every time you use it. The tip of your soldering iron should be clean and shiny. Whenever the you see the tip becoming dirty with flux or oxidizing, that means loosing it's shinyness, you should clean it. Even if you are in the middle of soldering. Having a clean soldering tip makes it A LOT easier to transfer heat to the soldering target.

The PCB that we ordered from JLCPCBwill guide you keep everything in the right placement so do not hesitate to visit this link if you want to view the PCB that we've made and make an online ordering.

As you can see, using this PCB is so handy because of its quality and for sure all the labels there provide the best guidance for you, so you will be 100% sure that you will not make any soldering mistakes.

I’ve soldered each component to its placement and you can use both sides of the PCB to solder you electronic parts.

Now we have the PCB ready and all the components soldered very well, after that I prepared this design to make a CNC laser cutting in order to insert the electronic part and the plant in one support, so if you want to make the same design as mine find the (DXF) files here

Step 6: The Android App.

This app will allow you to connect to your Arduino through Bluetooth, and using the Manual mode you can have access to the fans, and lights and also the water pump for ON and OFF controlling, without forgetting the sensors that you can read them data by pressing the “get data” button and all the appropriate data will be displayed on your smartphone screen.

You can get this android app for free from this link

Step 7: The Arduino Code and Test Validation

the code is available and as usual you can download it from this link. And as you can see in the photos the code is so simple and very well commented so you can understand it you own.

As you can see guys each button has a functionality with the system but what I really appreciate is the automatic mode for light brightness control I placed the light sensor at the lower base of the house then when we select this mode the system will control the brightness of the front light LEDs depending on the sensor signals. Also we can read the temperature and humidity values directly on the screen of the smart phone which is really impressive.

Code

Arduino source codeArduino
/************************************************************************************************************************************************************************                                              
 * - Author               : BELKHIR Mohamed              *                                               
 * - Profession           : (Developer) MEGA DAS owner   *                                                                                              
 * - Main purpose         : Industrial Application       *                                                                                 
 * - Copyright (c) holder : All rights reserved          *
 * - License              : BSD 2-Clause License         * 
 * - Date                 : 20/11/2017                   *
 * ***********************************************************************************************************************************************************************/
 
 /*********************************** NOTE **************************************/
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

// * Redistributions of source code must retain the above copyright notice, this
//  list of conditions and the following disclaimer.

// * Redistributions in binary form must reproduce the above copyright notice,
//  this list of conditions and the following disclaimer in the documentation
//  and/or other materials provided with the distribution.

// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED

/*
________________________________________________________________________________________________ (`v)
________________________________________________________________________________________________(`())__(`v)
_________________________________________________________________________________________________(_.^._)__(`())
___________________________________________________________________________________________________(`v)(_.^._)
__________________________________________________________________________________________________(`())(`v)
___________________________________________________________________________________________________(_.^._)(`())
______________________________________________________________________________________________(`v)_____ (_.^._)(`v)
_____________________________________________________________________________________________ (`())_ (`v)___(`())
______________________________________________________________________________________________ (_.^._)_(`())___(_.^._)
______________________________________________________________________________________________ (`v) (_.^._) (`v)
______________________________________________________________________________________________(`())____(`())
_______________________________________________________________________________________________(_.^._)_____(_.^._)
_____________________________________________________________________________________________________
___________________________________________________________________________________________________
_____________________________________________________________________________________________________.
___________________________________________________________________________________________________
___________________________________________________________________________________________________
____________________________________________________________________________________________________ 
______________________________________________________________________________________________________
_______________________________________________________________________________________________________
____________________________________________________________________________________________________________
____________________________________________________________________________________________.________
_________________________________________________________________________________________________
__________________________________________________________________________________________________ 
___________________________________________________________________________________________ ___________
___________________________________________________________________________________________________________
____________________________________________________________________________________________________
______________________________________________________________________________________________
__________________________________________________________________________________________(`v)
__________________________________________________________________________________________(`())
__________________________________________________________________________________________ (_.^._)
___________________________________________________________________________________________ (`v)
____________________________________________________________________________________________ (`())
______________________________________________________________________________________________ (_.^._)
________________________________________________________________________________________________(`v)
__________________________________________________________________________________________________(`())
__________________________________________________________________________________________________(_.^._)______
_____________________________________________________________________________________________
_______________________________________________________________________________________________

 */
#include "DHT.h"                                             // Include the dht library to interface with the DHT sensor
#include <Wire.h>                                            // IC library to use the light sensor
#include <BH1750.h>                                          // Import BH1750 library in order to be able to use the light sensor
//------------------------------------------------ Define the control pins --------------------------------------------------------
const int Pump=4;                                            // We've used this pin to control the motor pump 
const int Fan=5;                                             // Use this pin as a PWM output to control the Fan speed
const int Light=6;                                           // Use this pin in order to control the LED brightness
const int TempHum=7;                                         // Input pin for DHT sensor
const int Moisture=8;                                        // Digital Input pin to read the moisture command signals
const int TestLED=9;                                         // Use this output pin to test the right soldering on your PCB by turning on and off the test LEDs
const int Brightness=12;                                     // Input pin to read the light sensor signals
const int analogMoistue=0;                                   // Analog Input to read the analog signal from moisture sensor
//---------------------------------------------------------------------------------------------------------------------------------
#define DHTTYPE DHT11                                        // DHT 22  (AM2302), AM2321
DHT dht(TempHum, DHTTYPE);                                   // Temperature and humidity sensor constructor
BH1750 lightMeter;                                           // Light sensor constructor
char Data='x';                                               // Store Serial data in this variable
String cmd="";                                               // Read the full instruction sent from the android app
int flagModeAuto=0;                                          // flag to activate the auto mode
int sprayCMD=0;                                              // CMD limit spray
int LightCMD=0;                                              // CMD limit brightness
int lightLevelPlus=0;                                        // Variable to control the light brightness
float temperature=0;                                         // Variable to store the temperature value
float humidity=0;                                            // Variable to store the humidity value
uint16_t lux=0;                                              // Variable to read light brightness from the light sensor
//------------------------------------------------ Start the pin configuration --------------------------------------------------------
void setup() 
{
  
  Wire.begin();                                              // Initialize the I2C bus (BH1750 library doesn't do this automatically)
  dht.begin();                                               // Start the temperature and humidity sensor reading
  lightMeter.begin();                                        // Start the light sensor reading
  Serial.begin(9600);                                        // Set the baudrate up to 9600 BPS to comunicate with the android app through Bluetooth
  Serial.setTimeout(100);                                    // Set the time to wait for data before closing the Serial port (after 100 ms)
  pinMode(Pump,OUTPUT);
  pinMode(Fan,OUTPUT);
  pinMode(Light,OUTPUT);
  pinMode(Moisture,INPUT);
  pinMode(TestLED,INPUT);
  delay(1000);
  digitalWrite(Pump,LOW);
  digitalWrite(Fan,LOW);
  digitalWrite(Light,LOW);
}

//------------------------------------------------ Start the Process code --------------------------------------------------------
void loop() 
{
  while(Serial.available())                                  // Read the serial data once available
  {
    delay(10);
    Data=Serial.read();
    cmd+=Data;
  }
  if(cmd=="dt")                                              // Send the humidity value to the android app                                 
  {
    Serial.print(humidity);
  }
  if(cmd=="dh")                                              // Send the brightness value to the android app
  {
    Serial.print(lux);
  }
  if(cmd=="db")                                              // Send the temperature value to the android app
  {
    Serial.print(temperature);
  }
  if(cmd=="o")                                              // Activate the automatic mode
  {
    flagModeAuto=1;
  }
  if(cmd=="m")                                              // Disactivate the automatic mode
  {
    flagModeAuto=0;
  }
  if(flagModeAuto==1)
  {
    autoPump();
    lightBrightness();
    autoFan();
  }
  if(flagModeAuto==0)
  {
    if(cmd=="f")                                             // Turn ON the FAN
    {
      analogWrite(Fan,255);
    }
    if(cmd=="x")                                             // Turn OFF the FAN
    {
      analogWrite(Fan,0);
    }
    if(cmd=="l")                                             // Turn ON the Lights
    {
      analogWrite(Light,255);
    }
    if(cmd=="k")                                             // Turn OFF the Lights
    {
      analogWrite(Light,0);
    }
    if(cmd=="w")                                             // Turn ON the Pump
    {
      analogWrite(Pump,255);
    }
    if(cmd=="y")                                             // Turn OFF the Pump
    {
      analogWrite(Pump,0);
    }
  }
  cmd="";                                                    // Clear the cmd variable to make it available for the next instruction
  lux = lightMeter.readLightLevel();                         // Get the brightness level from the light sensor
  temperature=dht.readTemperature();                         // Get the temperature value from the DHT sensor (C)
  humidity=dht.readHumidity();                               // Get the humidity value from the DHT sensor (%)
}
//------------------------------------------------ Auto control function for Pump spray --------------------------------------------------------
void autoPump()
  {
    if(analogRead(analogMoistue)<sprayCMD)
    {
      digitalWrite(Pump,HIGH);
      delay(1000);
      digitalWrite(Pump,LOW);
      delay(1000);
    }
  }

//------------------------------------------------ Auto control function for Brightness LED --------------------------------------------------------
void lightBrightness()
{ 
  while(lux<LightCMD)
    {
      analogWrite(Light,lightLevelPlus);                         // Increase the light brightness
      delay(100);
      lightLevelPlus++;
      lux = lightMeter.readLightLevel();                         // Read the light brightness level
    }
}
//------------------------------------------------ Auto control function for FAN --------------------------------------------------------
void autoFan()
{
  if(temperature>30)
  {
    analogWrite(Fan,255);                                        // Turn ON the fan if the temperature exceed 30C
  }
  else
  {
    analogWrite(Fan,0);                                          // Turn OFF the fan if the temperature exceed 30C
  }
}

Custom parts and enclosures

House DXF Files
dxf_mdf_5mm_s0PEHuez4w.rar

Schematics

Schematic

Comments

Similar projects you might like

Alexa Controlled LEDs Through Raspberry Pi

Project tutorial by vincent wong

  • 634 views
  • 3 comments
  • 5 respects

WiFi To Your Website

Project showcase by Projecter

  • 2,954 views
  • 4 comments
  • 4 respects

SERENA: Alarm Control Panel

Project tutorial by Michael Marinis

  • 4,492 views
  • 0 comments
  • 10 respects

Measuring temperatures with LM35 and DS18B20

Project tutorial by jomar

  • 41 views
  • 0 comments
  • 1 respect

Digital & Binary Clock In 8 Digits x 7 Segments LED Display

Project tutorial by LAGSILVA

  • 256 views
  • 0 comments
  • 3 respects
Add projectSign up / Login