22 lines
540 B
Python
22 lines
540 B
Python
# Moisture Sensor Class
|
|
from machine import ADC, Pin
|
|
|
|
|
|
class MoistureSensor:
|
|
moisture_sensor_pin_int = -1
|
|
|
|
moisture_sensor = None
|
|
|
|
most_recent_value = -1
|
|
|
|
def __init__(self, moisture_sensor_data):
|
|
self.moisture_sensor_pin_int = moisture_sensor_data['pin_int']
|
|
print("Hello from moisture sensor. Sensor pin is: " + str(self.moisture_sensor_pin_int))
|
|
self.moisture_sensor = ADC(Pin(self.moisture_sensor_pin_int))
|
|
|
|
def read(self):
|
|
self.most_recent_value = self.moisture_sensor.read_u16()
|
|
|
|
|
|
|