Skip to main content

How to control RGB LED using Arduino Uno

RGB LED is the abbreviation of ‘’Red Green Blue Light Emitting Diode’’. RGB LED is the most amazing type of LED which has the ability to create millions of different shades of light colors using red, green, and blue colors.

How to operate soil moisture sensor with Arduino


The soil moisture sensor is the most amazing sensor used to measure the quantity of water present in the soil and defines the moisture level of the soil as the output. Because of its amazing operating principle, this sensor is used in applications such as automatic irrigation systems, agriculture research applications, landscape irrigation, indoor planting system, and lawns. I have also made an advanced level project "Smart Plant Watering System" using a soil moisture sensor.
In this article, I will explain to you some basic fundamentals which will help you to understand the working of the soil moisture sensor. The soil moisture sensor can be operated in both analog and digital modes. Here I will explain to you how soil moisture sensors can be operated in both modes.  

Interfacing with Arduino:

Soil moisture sensor contains two parts one is sensor part and the other one is the control board. The sensor part is made up of two conductive probes which are used to measure the moisture content in the soil. The Control board contains LM393 IC (voltage comparator), power LED, output LED, and potentiometer such as important components which help conductive probes to measure the moisture level of the soil.

1. Analog mode:

In this mode, I will show the real-time soil moisture sensor values on the serial monitor. In this project, you will learn how sensor value varies with the change in the moisture level of the soil.

Required components:

  • 1 x Arduino Uno board...............................BUY
  • Few jumper wires.......................................BUY
  • 1 x Soil moisture sensor..............................BUY
  • 1 x USB cable.............................................BUY
  • 1 x Breadboard............................................BUY

Connection diagram :




Circuit Description:

According to the connection diagram, the Vcc pin of the soil moisture sensor is connected with the 5V power supply pin of the Arduino board. GND pin of the soil moisture sensor is connected with one of the GND pins of the Arduino board. A0 analog pin of the soil moisture sensor is connected with the analog pin A2 of the Arduino board.

Code: Click here

In analog mode, I have used the analog pin of the sensor instead of the digital pin. In this mode, the sensor provides values from 0 to 1023 and these values will be shown on the serial monitor. As soil is dry then we will get higher values. When we add some water to it due to which soil will get wet then we will achieve lower values on the serial monitor.

Output video:



We can also measure the moisture level of the soil in percentage using the map function with the same connection circuit. In this case, I have mapped the values of the soil moisture sensor between 0 to 100 to calculate the moisture level as the percentage. While using the analog mode experiment I got 840 values on the serial monitor for dry soil and 120 value for wet soil. I used these values in the map function to calculate the moisture level in percentage. These values may vary according to the soil. You can change them according to your need. 

Code to calculate sensor values in percentage (click here)

2. Digital mode:

In digital mode, the soil moisture sensor will provide only two sensor output values HIGH or LOW (1 or 0). In this mode, I will operate the buzzer with the help of sensor values.

Required components:

  • 1 x Arduino Uno board:...............................BUY
  • Few jumper wires........................................BUY
  • 1 x Soil moisture sensor...............................BUY
  • 1 x USB cable...............................................BUY
  • 1 x Buzzer.....................................................BUY

Connection diagram :


Circuit Description:

According to the circuit diagram, the VCC and GND pins of the soil moisture sensor are connected with the 5V power supply and GND pins of the Arduino Uno board respectively. Digital pin D0 of the soil moisture sensor is connected with digital pin 8 of the Arduino Uno board. The buzzer is a two-terminal device one is longer and another one is shorter. The longer pin is connected with the output pin 8 and the shorter pin is connected with the GND pin of the Arduino board. 

CodeClick here

According to the code I have used the soil moisture sensor as an input device and the buzzer as the output device. Sensor values are compared with the specified threshold value (HIGH). If the sensor value is equal to the threshold value then the buzzer will be generated a beep sound otherwise buzzer will be off.

This concept can be used in interior home-based plant watering systems. As if the soil is dry then the buzzer will generate a beep sound and remind us to water the plant. As we provide water to the plant then the sensor will observe low value and stop the buzzer automatically. I have made an advance level project using a soil moisture sensor working in digital mode.



Comments

  1. I have gone through this article and its code with interest; I want to incorporate a pH (atlas Scientific pH sensor)and Temperature and humidity Sensor probe DHT 22 with LCD readout so that the parameters can be displayed. How to incorporate in the above programme ? Can some one help me with codes so that I can try to automate my kitchen garden (presently watered by manually by me). I have with me the soil moisture sensor, DHT22,16x2 LCD module( bought for distance sensor) with the Arduino R3 board ; only I have to go in for the atlas scientific pH sensor.
    Please kindly help me (I am a retired electronic teacher ans service personal ).
    V.Ramakrishnan
    pawanivr@yahoo.com
    +91 8105843368

    ReplyDelete
  2. I had already provided a separate article to understand the basics of LCD module (https://www.arduinounomagic.com/2019/01/how-to-use-lcd-with-arduino-uno.html?m=1). You will find solution for your issue after understanding the basics of LCD.

    I had also provided the article named "How to use temperature sensor with Arduino Uno" (https://www.arduinounomagic.com/2019/01/how-to-use-temperature-sensor-with.html?m=1) in which you will find all the basic concepts.

    Hope these articles will help you.

    ReplyDelete

Post a Comment

Popular posts from this blog

Smart Plant Watering System Using ARDUINO UNO

As we all know, plants play an important role in our life, there are countless benefits we get from plants but the most important is fresh air and the pleasant atmosphere on the earth. Hence,   It is not only our social duty as well as the responsibility that we should plant trees as much as we can and also take care of them. But  the biggest challenge we face, is, taking care of them,

How to use temperature sensor with Arduino Uno

The temperature sensor is the most popular measuring device which is capable to sense the intensity of heat generated by the object to which it is connected. These sensors are most frequently used by us through our household devices such as microwaves, refrigerators, air conditioners, and so on. In this tutorial, we will learn about LM35 (LM means linear monolithic) temperature sensor which is an integrated circuit analog temperature sensor.

ad

ad