SOIL MOISTURE SENSOR FOR PLANTS (V1.2 / V2.0) - Arduino tutorial #31

preview_player
Показать описание
The capacitive soil moisture sensor allows you to measure the moistness of soil. The biggest advantage over a traditional moisture sensor is that the capacitive sensor doesn't corrode. In this tutorial I'll explain how you can read the soil moisture sensor and what the advantages are. Further you learn how to work with the map() function and how to calculate the soil moisture in percentage.

Many ask what the difference is between v1.2 and v2.0, this is what I found:
- The spelling of the out pin: AOUT on v1.2 and AUOT on the v2.0
- The top of the PCB shows a tiny circle on v2.0

🤓 Fun fact: One pin on my sensor is labeled AUOT which should be AOUT for Analog OUT.

The Arduino for beginners tutorials series guides you through the world of Arduino. A video is around 10 minutes and shows you step-by-step how to build the circuit and write the code. The website contains the course material, circuit diagram, Arduino code and shopping list of all the components used in the tutorial.

CHAPTERS:
00:00 Introduction
00:15 Components
00:30 Capacitive soil moisture sensor
02:57 Building the circuit
03:34 Arduino code - part 1
04:42 Arduino code - part 2

COMPONENTS
🇨🇳 Arduino Uno (clone) with cable - AliExpress

🇳🇱 Arduino Uno (clone) - Opencircuit

🇳🇱 Arduino Uno SMD (original) - Opencircuit

🇳🇱 Arduino Uno Chip (original) - Opencircuit

🇨🇳 1x breadboard small - AliExpress

🇳🇱 1x breadboard small - Opencircuit

🇨🇳 1x breadboard large - AliExpress

🇳🇱 1x breadboard large - Opencircuit

🇨🇳 Jumper wire assortment (MM/MF/FF) - AliExpress

🇨🇳 Jumper wire male-male - AliExpress

🇳🇱 Jumper wire male-male - Opencircuit

🇨🇳 128x64 I2C OLED (blue) - AliExpress

🇳🇱 128x64 I2C OLED (blue) - Opencircuit

🇨🇳 128x64 I2C OLED (white) - AliExpress

🇳🇱 128x64 I2C OLED (white) - Opencircuit

🇨🇳 128x64 I2C OLED (yellow-blue) - AliExpress

🇳🇱 128x64 I2C OLED (yellow-blue) - Opencircuit

🇨🇳 20x colored tactile switches - AliExpress

🇳🇱 5x colored tactile switches - Opencircuit

VIDEO SUMMARY:
In this tutorial, Bas will show you how to use a capacitive soil moisture sensor. You'll need an Arduino board, the sensor, a sensor cable, jumper wires and a glass of water. He explains that the sensor works by measuring the resistance between two pins which changes based on the water level in the soil. However, he warns that fertilizers and corrosion can affect the sensor's accuracy. Instead of measuring resistance, this sensor works like a capacitor, measuring charge and discharge timing. The sensor also has a chip called a 555 timer chip which helps with timing. Bas will guide you on how to connect the sensor to the Arduino board and run the code. Finally, he'll show you how to calculate the percentage of moisture in the soil by adjusting the code and measuring the total range of the sensor.

#arduino #BasOnTech
Рекомендации по теме
Комментарии
Автор

Many ask what the difference is between v1.2 and v2.0. There isn't much information available. This is what I found out so far myself:
- The spelling of the out pin: AOUT on v1.2 and AUOT on the v2.0
- The tip on the top-side of the PCB shows a tiny circle on v2.0

BasonTech
Автор

The reason for the slow response time at the end is because your sensor is faulty, there is no pulldown resistor on the analogue output.

At 0:01, on the bottom right of the sensor, just below C4 and R4, the via hole is breaking the trace. You need to run a wire from the right side of R4 (nearest to the end), to the analogue output pin. Check out the video by “flora” on capacitance soil sensors

techheck
Автор

Well I got my sensor in the mail, copied the code, plugged it in, calibrated it, stuck it in some almost dry potting mix and got a reading of 35% and then added some water to the pot and got a reading of 57%.

So for me if the reading is less than 20%, water is needed, if more than 20% it doesn't need water.

Your code works a treat, your explanations were terrific. Thank you very very much !

Now all I have to do is solve my wretched SD card and RTC issue and I have myself a hand dandy watering controller.

malcolmmcgrath
Автор

Man!!! You explained that map() function so clearly. Thanks a lot!

FerneyManrique
Автор

Such a great tutorial. I loved how thorough your explanation was. Subscribed!

drumak
Автор

Overlooking the nonlinearity in capacitance and hydration, map is a nice function. Not knowing better but wanting the same result, I would have done hydration=100×(measured - dry)/(wet-dry)

kreynolds
Автор

Mapping the values directly to percentages assumes that the change is linear, which is not the case. I wish more tutorials would point out this fact.
Better way would be a calibration test, where a dry soil sample is watered by tiny amounts of water until its fully saturated. This will give you a nonlinear function. Then you could fit a curve (e.g. a logarithmic function) to your observed values and apply a proper calibration.

mosquitsch
Автор

If you have questions, don't hesitate to ask them in de comments. Remember: There are no stupid questions 😃
🔔 Want to stay up-to-date with the latest videos? Subscribe to the Bas on Tech channel!

BasonTech
Автор

Thanks for teaching and sharing. May the force be with you :)

BorisSiber
Автор

At 2:00 the video is wrong. The output of the circuit is tied to ground. So there will not be a signal to measure at 2:14.
What happens is this: When capacity increases (more moisture), the voltage swing across the capacitor will decrease. Vice versa, when capacity decreases (less moisture), the swing will increase.

willempje
Автор

Well a smarter way to do it, is self adjusting the moisture, like saving the variable in a permanent memory (store even when turn off) and re-ajust by when a higher or lower score hits than the stored range. (Button of reset is needed if change the circuit)

nveloper
Автор

Best explanation so far ; you just gained a like on the video and a sub in your channel

nounouak
Автор

Thank you for your explanation of a capacitive sensor very good

MrBobWareham
Автор

Your videos are pretty awesome! Thank you.

jakoblecker
Автор

Very cool Bas. I just stumbled upon your Channel today!,

daryldyehouse
Автор

Thanks for the great explanation

A few questions:
1. Is this solution scalable for a large garden with about 50 pots. What is the proper way to measure multiple pots at once?

2. How do you protect the sensore from water in case you want to keep it constantly in soil even when raining?

tomkregenbild
Автор

Can you add to this a water pump that will be triggered when soil dry. It will pump water until sensor detects water added then auto shut off pump. The pump can be small as it will water a single plant. Disabled, I need to make 100 of these set ups to grow food.. Most Humble Appreciation! Alton

smartassist
Автор

Noting the length of time for the reading to go from 0 to 100% hydration. Maybe the delay could be a problem with automatic watering. Anyway to reduce the delay?

kreynolds
Автор

Thank you so much! This is very helpful!

parthgoel
Автор

ook here is the thing, your values are changing very slowly which are supposed to change just after the change in moisture. The reason is the resistor which is not connected to the ground, Due to this the capacitor discharges very slowly. To get the accurate value you'll have to connect the resistor(R4) with the ground.

noobality