0% found this document useful (0 votes)
6 views6 pages

Iot Things

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Iot Things

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

leroy.frnacisco@aju.

ac IoT Things

IOT Project

Soil Moisture Sensor

Introduction

A soil moisture sensor is a tiny device that measures the water level in
soil. They can work alone or in automated systems for real-time
monitoring, making them crucial for several applications in agriculture,
gardening, environmental monitoring, and more.

There are different types of sensors, but we can divide them in two
groups: resistance-based and capacitance-based.

The resistance-based devices have two electrodes. When inserted into the
soil, these sensors measure the electrical resistance between the
electrodes. As the soil moisture increases, its conductivity also increases,
so the resistance between the electrodes go down. Then, this change in
resistance is converted into a moisture reading.

On the other hand, the capacitance-based sensors measure the dielectric


permittivity of the soil. The presence of water in the soil changes its
dielectric permittivity, which in turn affects the capacitance of the sensor.
Later, this change is measured to determine the soil moisture.

Components:
[email protected] IoT Things

%18%‫ﺘ‬葞ː葠‫ﺘ‬梇䢈.逄Ũ
萏֠萑‫ﺘ‬葞֠葠‫ﺘ‬梇䢈.鈂Ũ
萏ࡰ萑l葞ࡰ葠l梇䢈.退Ũ
萏ୀ萑‫ﺘ‬葞ୀ葠‫ﺘ‬梇䢈.逄Ũ
萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬梇䢈.鈂Ũ
萏რ萑l葞რ葠l梇䢈.退Ũ
萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬梇䢈.逄Ũ
萏 萑‫ﺘ‬葞 葠‫ﺘ‬梇䢈.鈂Ũ
萏ᥐ萑l葞ᥐ葠l梇䢈.ဗŨ萏ː萑‫ﺘ‬葞ː葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ栀ᤀကༀꂄᄅ预廾ꂄ怅预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ࡰ萑‫ﺘ‬葞ࡰ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀ǰ
ᜀ栀ᔀကༀ䂄ᄋ预廾䂄怋预俾Ŋ儀Ŋ漀(梇䢈逗Ũ萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬䩏䩑䩞⡯蜀h蠀HĀ漀Āᜀ栀ᔀကՊ儀Պ漀(梇䢈逗Ũ萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬䩏䩑
⡯蜀h蠀HĀ뜀ǰᜀ栀ᤀကༀ肄ᄖ预廾肄怖预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ᥐ萑‫ﺘ‬葞ᥐ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀˰਀籪꬀ṅj＀˿＀˿ሀༀऀᤰऀᬰऀ༰ऀᤰऀᬰऀ༰ऀᤰऀᬰऀሰ
Āऀ̰ऀ԰ऀİऀ̰ऀ ԰ऀİऀ̰ऀ԰ऀ̰찀╺ȁȀ氀ᑺ# Arduino IDE
%18%‫ﺘ‬葞ː葠‫ﺘ‬梇䢈.逄Ũ
萏֠萑‫ﺘ‬葞֠葠‫ﺘ‬梇䢈.鈂Ũ
萏ࡰ萑l葞ࡰ葠l梇䢈.退Ũ
萏ୀ萑‫ﺘ‬葞ୀ葠‫ﺘ‬梇䢈.逄Ũ
萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬梇䢈.鈂Ũ
萏რ萑l葞რ葠l梇䢈.退Ũ
萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬梇䢈.逄Ũ
萏 萑‫ﺘ‬葞 葠‫ﺘ‬梇䢈.鈂Ũ
萏ᥐ萑l葞ᥐ葠l梇䢈.ဗŨ萏ː萑‫ﺘ‬葞ː葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ栀ᤀကༀꂄᄅ预廾ꂄ怅预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ࡰ萑‫ﺘ‬葞ࡰ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀ǰᜀ栀ᔀ
ကༀ䂄ᄋ预廾䂄怋预俾Ŋ儀Ŋ漀(梇䢈逗Ũ萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬䩏䩑䩞⡯蜀h蠀HĀ漀Āᜀ栀ᔀကՊ儀Պ漀(梇䢈逗Ũ萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ
栀ᤀကༀ肄ᄖ预廾肄怖预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ᥐ萑‫ﺘ‬葞ᥐ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀˰਀籪꬀ṅj＀˿＀˿ሀༀऀᤰऀᬰऀ༰ऀᤰऀᬰऀ༰ऀᤰऀᬰऀሰĀऀ̰ऀ԰
ऀİऀ̰ऀ԰ऀİऀ̰ऀ ԰ऀ̰찀╺ȁȀ氀ᑺ# Arduino board
%18%‫ﺘ‬葞ː葠‫ﺘ‬梇䢈.逄Ũ
萏֠萑‫ﺘ‬葞֠葠‫ﺘ‬梇䢈.鈂Ũ
萏ࡰ萑l葞ࡰ葠l梇䢈.退Ũ
萏ୀ萑‫ﺘ‬葞ୀ葠‫ﺘ‬梇䢈.逄Ũ
萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬梇䢈.鈂Ũ
萏რ萑l葞რ葠l梇䢈.退Ũ
萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬梇䢈.逄Ũ
萏 萑‫ﺘ‬葞 葠‫ﺘ‬梇䢈.鈂Ũ
萏ᥐ萑l葞ᥐ葠l梇䢈.ဗŨ萏ː萑‫ﺘ‬葞ː葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ栀ᤀကༀꂄᄅ预廾ꂄ怅预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ࡰ萑‫ﺘ‬葞ࡰ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀ǰᜀ栀ᔀ
ကༀ䂄ᄋ预廾䂄怋预俾Ŋ儀Ŋ漀(梇䢈逗Ũ萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬䩏䩑䩞⡯蜀h蠀HĀ漀Āᜀ栀ᔀကՊ儀Պ漀(梇䢈逗Ũ萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ
栀ᤀကༀ肄ᄖ预廾肄怖预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ᥐ萑‫ﺘ‬葞ᥐ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀˰਀籪꬀ṅj＀˿＀˿ሀༀऀᤰऀᬰऀ༰ऀᤰऀᬰऀ༰ऀᤰऀᬰऀሰĀऀ̰ऀ԰
ऀİऀ̰ऀ԰ऀİऀ̰ऀ ԰ऀ̰찀╺ȁȀ氀ᑺ# Breadboard
%18%‫ﺘ‬葞ː葠‫ﺘ‬梇䢈.逄Ũ
萏֠萑‫ﺘ‬葞֠葠‫ﺘ‬梇䢈.鈂Ũ
萏ࡰ萑l葞ࡰ葠l梇䢈.退Ũ
萏ୀ萑‫ﺘ‬葞ୀ葠‫ﺘ‬梇䢈.逄Ũ
萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬梇䢈.鈂Ũ
萏რ萑l葞რ葠l梇䢈.退Ũ
萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬梇䢈.逄Ũ
萏 萑‫ﺘ‬葞 葠‫ﺘ‬梇䢈.鈂Ũ
萏ᥐ萑l葞ᥐ葠l梇䢈.ဗŨ萏ː萑‫ﺘ‬葞ː葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ栀ᤀကༀꂄᄅ预廾ꂄ怅预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ࡰ萑‫ﺘ‬葞ࡰ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀ǰᜀ栀ᔀ
ကༀ䂄ᄋ预廾䂄怋预俾Ŋ儀Ŋ漀(梇䢈逗Ũ萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬䩏䩑䩞⡯蜀h蠀HĀ漀Āᜀ栀ᔀကՊ儀Պ漀(梇䢈逗Ũ萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ
栀ᤀကༀ肄ᄖ预廾肄怖预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ᥐ萑‫ﺘ‬葞ᥐ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀˰਀籪꬀ṅj＀˿＀˿ሀༀऀᤰऀᬰऀ༰ऀᤰऀᬰऀ༰ऀᤰऀᬰऀሰĀऀ̰ऀ԰
ऀİऀ̰ऀ԰ऀİऀ̰ऀ ԰ऀ̰찀╺ȁȀ氀ᑺ# Jumper wires
[email protected] IoT Things

%18%‫ﺘ‬葞ː葠‫ﺘ‬梇䢈.逄Ũ
萏֠萑‫ﺘ‬葞֠葠‫ﺘ‬梇䢈.鈂Ũ
萏ࡰ萑l葞ࡰ葠l梇䢈.退Ũ
萏ୀ萑‫ﺘ‬葞ୀ葠‫ﺘ‬梇䢈.逄Ũ
萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬梇䢈.鈂Ũ
萏რ萑l葞რ葠l梇䢈.退Ũ
萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬梇䢈.逄Ũ
萏 萑‫ﺘ‬葞 葠‫ﺘ‬梇䢈.鈂Ũ
萏ᥐ萑l葞ᥐ葠l梇䢈.ဗŨ萏ː萑‫ﺘ‬葞ː葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ栀ᤀကༀꂄᄅ预廾ꂄ怅预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ࡰ萑‫ﺘ‬葞ࡰ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀ǰᜀ栀ᔀ
ကༀ䂄ᄋ预廾䂄怋预俾Ŋ儀Ŋ漀(梇䢈逗Ũ萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬䩏䩑䩞⡯蜀h蠀HĀ漀Āᜀ栀ᔀက Պ儀Պ漀(梇䢈逗Ũ萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ
栀ᤀကༀ肄ᄖ预廾肄怖预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ᥐ萑‫ﺘ‬葞ᥐ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀˰਀籪꬀ṅj＀˿＀˿ሀༀऀᤰऀᬰऀ༰ऀᤰऀᬰऀ༰ऀᤰऀᬰऀሰĀऀ̰ऀ ԰
ऀİऀ̰ऀ԰ऀİऀ̰ऀ԰ऀ̰찀╺ȁȀ氀ᑺ# Resistance-based soil moisture sensor
%18%‫ﺘ‬葞ː葠‫ﺘ‬梇䢈.逄Ũ
萏֠萑‫ﺘ‬葞֠葠‫ﺘ‬梇䢈.鈂Ũ
萏ࡰ萑l葞ࡰ葠l梇䢈.退Ũ
萏ୀ萑‫ﺘ‬葞ୀ葠‫ﺘ‬梇䢈.逄Ũ
萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬梇䢈.鈂Ũ
萏რ萑l葞რ葠l梇䢈.退Ũ
萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬梇䢈.逄Ũ
萏 萑‫ﺘ‬葞 葠‫ﺘ‬梇䢈.鈂Ũ
萏ᥐ萑l葞ᥐ葠l梇䢈.ဗŨ萏ː萑‫ﺘ‬葞ː葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ栀ᤀကༀꂄᄅ预廾ꂄ怅预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ࡰ萑‫ﺘ‬葞ࡰ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀ǰᜀ栀ᔀ
ကༀ䂄ᄋ预廾䂄怋预俾Ŋ儀Ŋ漀(梇䢈逗Ũ萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬䩏䩑䩞⡯蜀h蠀HĀ漀Āᜀ栀ᔀက Պ儀Պ漀(梇䢈逗Ũ萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ
栀ᤀကༀ肄ᄖ预廾肄怖预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ᥐ萑‫ﺘ‬葞ᥐ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀˰਀籪꬀ṅj＀˿＀˿ሀༀऀᤰऀᬰऀ༰ऀᤰऀᬰऀ༰ऀᤰऀᬰऀሰĀऀ̰ऀ ԰
ऀİऀ̰ऀ԰ऀİऀ̰ऀ԰ऀ̰찀╺ȁȀ氀ᑺ# Three LEDs (red, yellow, green)
%18%‫ﺘ‬葞ː葠‫ﺘ‬梇䢈.逄Ũ
萏֠萑‫ﺘ‬葞֠葠‫ﺘ‬梇䢈.鈂Ũ
萏ࡰ萑l葞ࡰ葠l梇䢈.退Ũ
萏ୀ萑‫ﺘ‬葞ୀ葠‫ﺘ‬梇䢈.逄Ũ
萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬梇䢈.鈂Ũ
萏რ萑l葞რ葠l梇䢈.退Ũ
萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬梇䢈.逄Ũ
萏 萑‫ﺘ‬葞 葠‫ﺘ‬梇䢈.鈂Ũ
萏ᥐ萑l葞ᥐ葠l梇䢈.ဗŨ萏ː萑‫ﺘ‬葞ː葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ栀ᤀကༀꂄᄅ预廾ꂄ怅预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ࡰ萑‫ﺘ‬葞ࡰ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀ǰᜀ栀ᔀ
ကༀ䂄ᄋ预廾䂄怋预俾Ŋ儀Ŋ漀(梇䢈逗Ũ萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬䩏䩑䩞⡯蜀h蠀HĀ漀Āᜀ栀ᔀက Պ儀Պ漀(梇䢈逗Ũ萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ
栀ᤀကༀ肄ᄖ预廾肄怖预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ᥐ萑‫ﺘ‬葞ᥐ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀˰਀籪꬀ṅj＀˿＀˿ሀༀऀᤰऀᬰऀ༰ऀᤰऀᬰऀ༰ऀᤰऀᬰऀሰĀऀ̰ऀ ԰
ऀİऀ̰ऀ԰ऀİऀ̰ऀ԰ऀ̰찀╺ȁȀ氀ᑺ# Three 220 ohm resistors
%18%‫ﺘ‬葞ː葠‫ﺘ‬梇䢈.逄Ũ
萏֠萑‫ﺘ‬葞֠葠‫ﺘ‬梇䢈.鈂Ũ
萏ࡰ萑l葞ࡰ葠l梇䢈.退Ũ
萏ୀ萑‫ﺘ‬葞ୀ葠‫ﺘ‬梇䢈.逄Ũ
萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬梇䢈.鈂Ũ
萏რ萑l葞რ葠l梇䢈.退Ũ
萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬梇䢈.逄Ũ
萏 萑‫ﺘ‬葞 葠‫ﺘ‬梇䢈.鈂Ũ
萏ᥐ萑l葞ᥐ葠l梇䢈.ဗŨ萏ː萑‫ﺘ‬葞ː葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ栀ᤀကༀꂄᄅ预廾ꂄ怅预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ࡰ萑‫ﺘ‬葞ࡰ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀ǰᜀ栀ᔀ
ကༀ䂄ᄋ预廾䂄怋预俾Ŋ儀Ŋ漀(梇䢈逗Ũ萏ฐ萑‫ﺘ‬葞ฐ葠‫ﺘ‬䩏䩑䩞⡯蜀h蠀HĀ漀Āᜀ栀ᔀက Պ儀Պ漀(梇䢈逗Ũ萏Ꮀ萑‫ﺘ‬葞Ꮀ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ뜀ǰᜀ
栀ᤀကༀ肄ᄖ预廾肄怖预俾ъ儀ъ帀ъ漀(梇䢈o逗Ũ萏ᥐ萑‫ﺘ‬葞ᥐ葠‫ﺘ‬䩏䩑⡯蜀h蠀HĀ꜀˰਀籪꬀ṅj＀˿＀˿ሀༀऀᤰऀᬰऀ༰ऀᤰऀᬰऀ༰ऀᤰऀᬰऀሰĀऀ̰ऀ ԰
ऀİऀ̰ऀ԰ऀİऀ̰ऀ԰ऀ̰찀╺ȁȀ氀ᑺ# Glass of water
Connect the 5V and GND ports of the Arduino to the breadboard.
Attach the sensor power supply pins to the 5V and GND rows and the signal pin to A5.
Set up the LEDs with resistors on the breadboard, connecting them to GND and ports 2,
3, and 4.
[email protected] IoT Things

Connect Arduino 5V and GND pins to the breadboard


/
Connect wires to sensor pins A0, GND, and VCC.
/

Connect the sensor power supply pins to the breadboard.


/
Attach the A0 pin to A5.
/

Attach the LEDs and 220 Ohm resistors on the breadboard


/
Connect the LEDs to GND and ports 2, 3, and 4 (green, yellow, and red LEDs
respectively)
/

Results
After diving the sensor legs completely into the glass of water, we have an extremely wet
situation. Diving only a small part of the sensor, gives us the wet scenario and the
system responds accordingly. Now if we remove the sensor from the water, the reading
value is so low that the red LED is turned on, indicating a extremely dry scenario.
Dive the sensor completely in the water
/
The green LED is turned on.
/

Dive the sensor partially in the water


/
The yellow LED is turned on.
/

Remove the sensor from the water


/
The red LED is turned on
/
[email protected] IoT Things

Code for Arduino IDE:


//
=====================================================
===========================
// Read values from a soil moisture sensor and blink LEDs accordingly
// This code works with resistance-based soil moisture sensors
// Created on 17 July 2024
// Created by Lucas Fernando (https://www.youtube.com/@lucasfernandochannel)
// You are free to use this code the way you want
//
=====================================================
===========================

#define GREEN_LED 2 // Green LED connected to digital pin 2


#define YELLOW_LED 3 // Yellow LED connected to digital pin 3
#define RED_LED 4 // Red LED connected to digital pin 4
#define SENSOR_PIN A5 // Soil moisture sensor connected to analog pin A5
// Defining soil moisture readings thresholds
// From 0 to 500 - extremely wet
// From 501 to 800 - wet
// From 801 - dry
#define DRY_THRESHOLD 800
#define WET_THRESHOLD 500

void setup() {
pinMode(GREEN_LED, OUTPUT);
pinMode(YELLOW_LED, OUTPUT);
pinMode(RED_LED, OUTPUT);

digitalWrite(GREEN_LED, LOW);
digitalWrite(YELLOW_LED, LOW);
digitalWrite(RED_LED, LOW);

Serial.begin(9600);
}

void loop() {
int sensorValue = analogRead(SENSOR_PIN);
// Print the sensor reading values
Serial.print("Soil moisture sensor value: ");
Serial.println(sensorValue);

if(sensorValue > 0 && sensorValue <= WET_THRESHOLD) {


// Extremely wet (green LED)
digitalWrite(GREEN_LED, HIGH);
digitalWrite(YELLOW_LED, LOW);
digitalWrite(RED_LED, LOW);
} else if (sensorValue > WET_THRESHOLD && sensorValue <= DRY_THRESHOLD) {
// Wet (yellow LED)
digitalWrite(GREEN_LED, LOW);
digitalWrite(YELLOW_LED, HIGH);
digitalWrite(RED_LED, LOW);
} else {
// Extremely dry (red LED)
digitalWrite(GREEN_LED, LOW);
[email protected] IoT Things

digitalWrite(YELLOW_LED, LOW);
digitalWrite(RED_LED, HIGH);
}
}

You might also like