I'm building a little automated hydroponics system using a raspberry pi zero, a 5 volt relay, a pump and a soil moisture sensor from adafruit. So far everything is working, I can pull the pin to high and engaged the pump via the relay, I can get data from the soil-sensor.
I wrote a test to see if I could make it only print the readout from the sensor if the value of the read was over a certain amount and then activate it with my finger. This works great, it starts and stops if the value is greater than 600 or less than 600... However if I add the line to pull the pin to high in place of the Print function, it simply pulls the pin to high until I kill the program. What am I missing here?
My Test program:
import time import board from board import SCL, SDA import busio import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) RELAIS_1_GPIO = 18 GPIO.setup(RELAIS_1_GPIO, GPIO.OUT) # GPIO Assign mode from adafruit_seesaw.seesaw import Seesaw i2c_bus = busio.I2C(SCL, SDA) ss = Seesaw(i2c_bus, addr=0x36) while True: # read moisture level through capacitive touch pad touch = ss.moisture_read() if touch > 600: GPIO.output(RELAIS_1_GPIO, GPIO.HIGH) print("moisture: " + str(touch))