The soile moisture sensors

The soile moisture sensors Titelbild

Folgende Teile braucht ihr für die Anleitung

Smart Plant kit for the Raspberry Produktbild

Smart Plant kit for the Raspberry | 19.95€

Measuring soil moisture

Every proud owner of a plant faces this one simple, but exhausting, problem. When does a plant need water? Both too much and not enough water can be quite deadly. This is a major problem for every plant which is dependent upon a human being to provide it with adequate water. We ourself have many times struggled with fulfilling this task. For everyone who has struggled, including ourselves, we now have the soil moisture sensor. With this sensor, similar to an air humidity sensor, we can measure the soil moisture.

But how does this sensor work? The sensor has two “legs” which are put into the soil. Contrary to soil, due to water’s conductivity properties, we are able to measure the resistance of the water as it is acting like a resistor. This basically means that dry soil is worse in conducting electricity than wet soil. With the knowledge of the measured resistance value, and the needs of a specific plant, we will be able to track when a watering is needed.

Connections Pi Connections Sensor
Analog signal -> CH1
import spidev
import time
import os
import RPi.GPIO as gpio

# Start SPI connection
spi = spidev.SpiDev(),0)

# Read MCP3008 data
def analogInput(channel):
  adc = spi.xfer2([1,(8+channel)<<4,0])
  data = ((adc[1]&3) << 8) + adc[2]
  return data

while True:
  print("Soil Moisture: "+str(analogInput(1)))

This program has the same logic as the photoresistor source code. The main change is that we connected the soil moisture sensor rather than the photoresistor. If the plant is really dry (or rather nearly dead) we measure a value around 900. With a healthy watered plant we get a value around 400. Keep in mind that the values that correspond to an adequately nurtured or neglected plant depend on the type of plant and how much water it needs.

Noch Fragen oder Feedback?

Bevor du eine Frage stellen kannst musst du dich zuerst Anmelden oder Regestrieren!