Plant watering system based on soil moisture using Raspberry Pi
Call for Price
Plant watering system based on soil moisture using Raspberry Pi
Description
ABSTRACT
Nowadays everything becomes autonomous, thus to turn watering system for plants in fields or home plants to autonomous this beginner Raspberry Pi project helps you to interface Soil moisture sensor and motor with the Raspberry Pi using MCP3008 and also by interfacing the water level sensor with Raspberry Pi, over flow of water can be prevented. When the system begins to run the program it will check for soil moisture using moisture sensor, if it doesn’t have any moisture in the soil, motor turned on and water get passed to the field. Then priority hands over to level sensor, if the water level reaches the threshold, motor get turned off. So this Raspberry Pi system makes watering system to be autonomous.
HARDWARE REQUIRED
- Raspberry Pi
- SD card
- Power supply
- VGA to HDMI converter (Optional)
- MCP3008 (ADC IC)
- Moisture sensor
- Level sensor
- Motor
SOFTWARE REQUIRED
- Raspbian Stretch OS
- SD card Formatter
- Win32DiskImager (or) Etcher
PYTHON LIBRARIES USED
- RPi.GPIO as GPIO (To access the GPIO Pins of Raspberry Pi)
- Time library (For Time delay)
CODE
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) # read SPI data from MCP3008 chip, 8 possible adc's (0 thru 7) def readadc(adcnum, clockpin, mosipin, misopin, cspin): if ((adcnum > 7) or (adcnum < 0)): return -1 GPIO.output(cspin, True) GPIO.output(clockpin, False) # start clock low GPIO.output(cspin, False) # bring CS low commandout = adcnum commandout |= 0x18 # start bit + single-ended bit commandout <<= 3 # we only need to send 5 bits here for i in range(5): if (commandout & 0x80): GPIO.output(mosipin, True) else: GPIO.output(mosipin, False) commandout <<= 1 GPIO.output(clockpin, True) GPIO.output(clockpin, False) adcout = 0 # read in one empty bit, one null bit and 10 ADC bits for i in range(12): GPIO.output(clockpin, True) GPIO.output(clockpin, False) adcout <<= 1 if (GPIO.input(misopin)): adcout |= 0x1 GPIO.output(cspin, True) adcout >>= 1 # first bit is 'null' so drop it return adcout # change these as desired - they're the pins connected from the # SPI port on the ADC to the Cobbler SPICLK = 18 SPIMISO = 23 SPIMOSI = 24 SPICS = 25 motor=21 # set up the SPI interface pins GPIO.setup(SPIMOSI, GPIO.OUT) GPIO.setup(SPIMISO, GPIO.IN) GPIO.setup(SPICLK, GPIO.OUT) GPIO.setup(SPICS, GPIO.OUT) GPIO.setup(motor, GPIO.OUT) while True: # read the analog pin Moisture_level = readadc(0, SPICLK, SPIMOSI, SPIMISO, SPICS) print("Moisture_level:", Moisture_level) Water_level = readadc(1, SPICLK, SPIMOSI, SPIMISO, SPICS) print("Water_level:", Water_level) if((Moisture_level>500)and(Water_level<500)): GPIO.output(motor, True) else: GPIO.output(motor, False)
Additional information
Weight | 0.000000 kg |
---|
Reviews
There are no reviews yet.