We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 2df8a67 + e604940 commit a60e576Copy full SHA for a60e576
adafruit_seesaw/seesaw.py
@@ -236,6 +236,17 @@ def moisture_read(self):
236
self.read(_TOUCH_BASE, _TOUCH_CHANNEL_OFFSET, buf, .005)
237
ret = struct.unpack(">H", buf)[0]
238
time.sleep(.001)
239
+
240
+ # retry if reading was bad
241
+ count = 0
242
+ while ret > 4095:
243
+ self.read(_TOUCH_BASE, _TOUCH_CHANNEL_OFFSET, buf, .005)
244
+ ret = struct.unpack(">H", buf)[0]
245
+ time.sleep(.001)
246
+ count += 1
247
+ if count > 3:
248
+ raise RuntimeError("Could not get a valid moisture reading.")
249
250
return ret
251
252
def pin_mode_bulk(self, pins, mode):
0 commit comments