I am using the YL-69 with a MCP3008 and a Raspberry Pi 3:
I am using the sensor for soil moisture measurement (plant monitoring). This is the code which gets analogue sensor values:
os.system('modprobe w1-gpio') os.system('modprobe w1-therm') spi = spidev.SpiDev() spi.open(0,0) def getAdc (channel): if ((channel>7)or(channel<0)): return -1 r = spi.xfer([1, (8+channel) << 4,0]) adcOut = ((r&3) << 8) + r percent = int(round(adcOut/10.24)) return percent moist_value = getAdc(0)
The code is not mine I took it from here. The script is run every 30 minutes via a Cronjob.
I have been watering the plant for about three weeks. Then I suddenly got values like this although I have not been watering for days:
After further inspection I saw that one of the LEDs on the YL-69 PCB was off. Also one of the pins on the sensor itsef fell off. It looks a lot like corrosion.
I did some research and fond that:
Continuously powering the sensor module will corrode the moisture sensor overtime. Therefore control the power to the moisture sensor using a GPIO pin of ESP8266
So I wonder can I turn the power on and off without using a ESP8266. I dont see any code for setting GPIO pins to high or low, so I suppose that they are set to high on default and I can change them back to low. Would that power off the YL-69?