2022-07-06 16:34:46 +00:00
|
|
|
import time
|
2022-07-09 22:13:45 +00:00
|
|
|
import signal
|
|
|
|
import sys
|
2022-07-06 16:34:46 +00:00
|
|
|
|
2022-07-09 22:13:45 +00:00
|
|
|
sys.path.append('./SDL_Adafruit_ADS1x15')
|
|
|
|
|
|
|
|
import SDL_Adafruit_ADS1x15
|
|
|
|
|
|
|
|
def signal_handler(signal, frame):
|
|
|
|
sys.exit(0)
|
|
|
|
|
2022-07-09 22:24:05 +00:00
|
|
|
signal.signal(signal.SIGINT, signal_handler)
|
2022-07-09 22:13:45 +00:00
|
|
|
|
2022-07-09 22:24:05 +00:00
|
|
|
def get_moisture():
|
|
|
|
ADS1115 = 0x01
|
|
|
|
gain = 6144
|
|
|
|
sps = 250
|
|
|
|
adc = SDL_Adafruit_ADS1x15.ADS1x15(ic=ADS1115)
|
2022-07-09 22:13:45 +00:00
|
|
|
|
2022-07-10 16:58:12 +00:00
|
|
|
return adc.readADCSingleEnded(0, gain, sps) / 1000 + adc.readADCSingleEnded(1, gain, sps) / 1000 + adc.readADCSingleEnded(2, gain, sps) / 1000 + adc.readADCSingleEnded(3, gain, sps) / 1000
|
2022-07-09 22:24:32 +00:00
|
|
|
|
|
|
|
while True:
|
2022-07-10 16:35:12 +00:00
|
|
|
print(get_moisture())
|
|
|
|
time.sleep(1)
|