11. Input Devices

water level based on the amount of moisture present

Soil Moisture Sensor Hygrometer Arduino

This moisture sensor can read the amount of moisture present in the surrounding soil. It is a low-tech sensor, but it is ideal for monitoring an urban garden. It is an indispensable tool for a contact garden!

This sensor uses the two probes to pass current through the soil, and then reads the resistance to get the moisture level. More water makes the soil conduct electricity more easily (less resistance), while dry soil is a poor conductor of electricity (more resistance).

It will be useful to remind you to water houseplants or to monitor soil moisture in your garden.

Features



Sensitivity adjustable by adjusting the digital potentiometer (blue).

Operating voltage: 3.3V ~ 5V

Dual output mode, digital output and more accurate analog output.

Mounting holes for easy installation.

PCB dimensions: 30mm * 16mm

Probe dimensions: 60mm * 30mm

Power indicator. Power indicator (red) and digital switching output indicator (green).

The module has a LM393 amplifier.

Pin definition



VCC (5V)

GND

Digital output interface (0 and 1)

Analog output interface AO

Translated with www.DeepL.com/Translator (free version)

Capacitive Soil Moisture Sensor

This sensor reads the amount of moisture present in the surrounding soil. It is a capacitive type sensor, which makes it more resistant to corrosion and more reliable in long term measurements. Special for use with Arduino or any microcontroller with analog - digital converter.

Features:

Model: Capacitive Soil Moisture Sensor V1.2 - Capacitive Soil Moisture Sensor V1.2
DC Operating Voltage: 3.3V ~ 5.5 V
Analog Output: 0V ~ 3V
Connector Type: PH2.0-3P
Dimensions: 98 mm x 23 mm

Arduino: Soil moisture sensor

This sensor has the ability to measure soil moisture. By applying a small voltage between the terminals of the module, it passes a current that basically depends on the resistance generated in the soil, and this is highly dependent on the humidity. Therefore, as the humidity increases the current increases and as the humidity decreases the current decreases.

Technical characteristics

It has two types of outputs, one analog and one digital. The digital output will deliver a low pulse when there is sufficient conductivity between each of the tips. The trigger threshold can be set by moving the potentiometer of the control circuit. On the analog output the voltage level will depend directly on how much moisture is in the soil. That is, depending on how much conductivity (product of water in the soil) there is between the tips of the module, so will vary the value delivered by Arduino (between 0 and 1023).

In this example, we have only connected to the analog output, since we want to know if the soil is dry, wet or very wet:

0 -300 very wet
300-700 wet
700-1023 dry

These values depend on the plant that you want to irrigate, since it is not the same a captus that a calla, although for most of the plants these values are valid.

A very important note is that it depends on the module we have, maybe the values close to 0 is because the plant is dry and those close to 1023 is because it is very watery. I recommend that when loading the program you test how your sensor acts by putting it in a glass of water.

The Code

for the code we use the language provided by the Arduino.
Arduino Code, an open project written, debugged, and supported by Arduni and his community

THE CODE

#include
#include
#include

#define pinAnalogo A0
#define pinDigital 7
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

int valor_analogo;
bool valor_digital;

String analogo, digital;

void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
pinMode(pinDigital, INPUT);
}


void loop() {
saludo();
leer_sensores();
lcd_sensor();
}

void leer_sensores() {
valor_analogo = analogRead(pinAnalogo);
Serial.print(valor_analogo);
Serial.print(" ,");

if ( valor_analogo > 300) {
analogo = "Nivel Bajo";
}
else {
analogo = "Nivel Alto";
}

valor_digital = digitalRead(pinDigital);
Serial.println(valor_digital);
if ( valor_digital == false) {
digital = "Nivel Alto";
}
else {
digital = "Nivel Bajo";
}
}

void lcd_sensor() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(10, 0);
display.print("DIG: ");
display.print(valor_digital);
display.print(" ");
display.print(digital);

display.setCursor(10, 16);
display.print("AN: ");
display.print(valor_analogo);
display.print(" ");
display.print(analogo);
display.display();
delay(5000);
}

void saludo() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(30, 0);
display.println("SENSOMANIAC");
display.setTextSize(2);
display.setCursor(0, 16);
display.println("By:Volkmar");
display.display();
delay(2000);
}

The Result

Phone

(+57) 305-257 10 63