Smart Garden Automation with Arduino
In this tutorial, we will create a smart garden automation system using an Arduino board. The system will monitor the soil moisture level, temperature, and humidity, and control the watering of plants using a water pump. We will display the sensor readings on an LCD screen for real-time monitoring. Let's get started!
Components:
Arduino Uno board
Soil moisture sensor
DHT11 temperature and humidity sensor
Relay module
I2C LCD display (16x2)
Connections:
Connect the soil moisture sensor:
Connect the VCC pin to +5V on the Arduino.
Connect the GND pin to GND on the Arduino.
Connect the A0 pin to A0 on the Arduino.
Connect the relay module:
Connect the VCC pin to +5V on the Arduino.
Connect the GND pin to GND on the Arduino.
Connect the IN pin to digital pin 11 on the Arduino.
Connect the I2C LCD display:
Connect the SDA pin to the SDA (A4) pin on the Arduino.
Connect the SCL pin to the SCL (A5) pin on the Arduino.
Connect the VCC pin to +5V on the Arduino.
Connect the GND pin to GND on the Arduino.
Connect the DHT11 sensor:
Connect the VCC pin to +5V on the Arduino.
Connect the GND pin to GND on the Arduino.
Connect the OUT pin to digital pin 7 on the Arduino.
Library Installation:
To use the DHT11 sensor and the LCD display, we need to install the following libraries:
DHT Library by Adafruit: To install this library, open the Arduino IDE, go to "Sketch" -> "Include Library" -> "Manage Libraries". Search for "DHT" and click the "Install" button.
LiquidCrystal_I2C Library: To install this library, go to "Sketch" -> "Include Library" -> "Manage Libraries". Search for "LiquidCrystal_I2C" and click the "Install" button.
Code:
Code Explanation:
We start by including the necessary libraries: Wire for I2C communication, LiquidCrystal_I2C for the LCD display, and DHT for the DHT11 sensor.
The pin connections for the soil moisture sensor, relay module, LCD display, and DHT11 sensor are defined.
The LCD and DHT objects are initialized with their respective pins and parameters.
In the
setup()
function, we set up the serial communication, initialize the LCD, and configure the relay pin as an output.The
loop()
function reads the soil moisture level using the analogRead() function and maps it to a percentage value using themoistureMin
andmoistureMax
variables.The temperature and humidity are read from the DHT11 sensor using the
readTemperature()
andreadHumidity()
functions.The sensor readings are printed to the serial monitor for debugging purposes.
Based on the moisture threshold, the relay is controlled to turn the water pump on or off. The LCD displays the corresponding message.
The moisture percentage, temperature, and humidity values are displayed on the LCD.
Conclusion:
In this tutorial, we have learned how to create a smart garden automation system using Arduino. We have connected and configured various sensors and modules to monitor soil moisture, temperature, and humidity. The system controls the watering of plants based on the moisture level and displays sensor readings on an LCD screen. With this project, you can efficiently automate and monitor your garden, ensuring optimal plant health.
Feel free to experiment with different sensor thresholds and customize the system according to your specific requirements.
This final code has been inspired on the Techatronic tutorial. https://techatronic.com/how-to-make-smart-irrigation-project/
Last updated