aquifer/sensors/watersensor.py

16 lines
346 B
Python
Raw Normal View History

2023-02-07 08:49:20 -05:00
import machine
class WaterSensor:
def __init__(self, pin):
self.waterSensor = machine.ADC(pin)
self.reading = self.waterSensor.read_u16()
self.threshold = 2000
def takeReading(self):
self.reading = self.waterSensor.read_u16()
def isWaterPresent(self):
return self.reading > self.threshold