Interfacing Raspberry Pi 3 with Soil Moisture Sensor π± π― Objective Use the Soil Moisture Sensor with Raspberry Pi 3 to measure soil humidity levels. This setup is ideal for building smart irrigation systems for gardens and farms. πΎ π§° Components Required Component Quantity Raspberry Pi 3 1 Soil Moisture Sensor (Analog) 1 MCP3008 ADC 1 Breadboard 1 Jumper Wires As required ⚡ Circuit Connections Sensor to MCP3008: Soil Sensor Pin Connect To VCC 3.3V (RPi) GND GND (RPi) Analog Out CH0 of MCP3008 MCP3008 to Raspberry Pi: MCP3008 RPi3 GPIO Pin VDD, VREF 3.3V AGND, DGND GND CLK GPIO11 DOUT GPIO9 DIN GPIO10 CS GPIO8 π§ Python Code import spidev import time spi = spidev.SpiDev() spi.open(0, 0) spi.max_speed_hz = 1350000 def read_channel(channel): adc = spi.xfer2([1, (8 + channel) << 4, 0]) data = ((adc[1] & 3) << 8) + adc[2] return data try: while True: moisture_lev...
|LEARN | EXPLORE | INNOVATE | I.O.T | A.I | ROBOTICS |